示例#1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env,
                              ILoggerFactory loggerFactory, IPCS.Repositories.Context.IPCSContext context,
                              UserManager <User> userManager)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddFile(Configuration.GetSection("LoggingFile"));

            loggerFactory.AddDebug();

            if (string.IsNullOrWhiteSpace(env.WebRootPath))
            {
                env.WebRootPath = System.IO.Path.Combine(Directory.GetCurrentDirectory(), "wwwroot");
            }

            UseIdentityServerAuthenticationOptions opt = new UseIdentityServerAuthenticationOptions();

            Configuration.GetSection("UseIdentityServerAuthenticationOptions").Bind(opt);

            app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
            {
                Authority             = opt.Authority,
                ApiName               = opt.ApiName,
                RequireHttpsMetadata  = opt.RequireHttpsMetadata,
                AutomaticAuthenticate = opt.AutomaticAuthenticate,
                AutomaticChallenge    = opt.AutomaticChallenge,
                RoleClaimType         = ClaimTypes.Role,
                EnableCaching         = opt.EnableCaching,
                AuthenticationScheme  = opt.AuthenticationScheme,
                SupportedTokens       = IdentityServer4.AccessTokenValidation.SupportedTokens.Jwt,
                JwtBearerEvents       = new CustomJwtBearerEvents()
            });

            app.UseCors("CorsPolicy");

            app.UseMvc();


            var pathUploadProjectFolder = Path.Combine(env.WebRootPath, "upload", "project");

            if (!Directory.Exists(pathUploadProjectFolder))
            {
                Directory.CreateDirectory(pathUploadProjectFolder);
            }

            app.UseStaticFiles(new StaticFileOptions()
            {
                FileProvider = new PhysicalFileProvider(
                    Path.Combine(env.WebRootPath, "upload", "project")),
                RequestPath = new PathString("/project")
            });

            DBInitialize.Seed(context, userManager, Configuration.GetValue <bool>("SEED"));
        }
示例#2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env,
                              ILoggerFactory loggerFactory, IPCSOAuthContext context, UserManager <User> userManager)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddFile(Configuration.GetSection("LoggingFile"));
            loggerFactory.AddDebug();

            app.UseIdentity();
            app.UseIdentityServer();

            app.UseCors("CorsPolicy");
            app.UseMvc();
            DBInitialize.Seed(context, userManager);
        }