private static void InitializeDatabase(IDbBootstrapper dbBootstrapper) { if (dbBootstrapper.Setup()) { dbBootstrapper.AddResources(Config.GetIdentityResources()); } }
// 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, IDbBootstrapper dbBootstrapper) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); _loggingLevelSwitch.MinimumLevel = LogEventLevel.Verbose; } app.UseCheckXForwardHeader(); InitializeDatabase(dbBootstrapper); loggerFactory.AddSerilog(_logger); app.UseCors(FabricIdentityConstants.FabricCorsPolicyName); app.UseIdentityServer(); app.UseExternalIdentityProviders(_appConfig); app.UseStaticFiles(); app.UseStaticFilesForAcmeChallenge(ChallengeDirectory, _logger); JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); var options = app.ApplicationServices.GetService <IdentityServerAuthenticationOptions>(); app.UseIdentityServerAuthentication(options); app.UseMvcWithDefaultRoute(); var healthCheckService = app.ApplicationServices.GetRequiredService <IHealthCheckerService>(); app.UseOwin() .UseFabricMonitoring(healthCheckService.CheckHealth, _loggingLevelSwitch); // Enable middleware to serve generated Swagger as a JSON endpoint. app.UseSwagger(c => { c.RouteTemplate = "swagger/ui/index/{documentName}/swagger.json"; }); // Enable middleware to serve swagger-ui (HTML, JS, CSS etc.), specifying the Swagger JSON endpoint. app.UseSwaggerUI(c => { // this sets up the JSON endpoint (1 call to SwaggerEndpoint per version) c.SwaggerEndpoint("v1/swagger.json", "Health Catalyst Fabric Identity API V1"); c.RoutePrefix = "swagger/ui/index"; }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure( IApplicationBuilder app, IHostingEnvironment env, IDbBootstrapper dbBootstrapper) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); LogFactory.LoggingLevelSwitch.MinimumLevel = LogEventLevel.Verbose; } app.UseExceptionHandler("/Home/UnauthorizedError"); app.UseStatusCodePages( async context => { if (context.HttpContext.Response.StatusCode == 401) { context.HttpContext.Response.ContentType = "text/html"; await context.HttpContext.Response.WriteAsync( String.Format( "<script>window.location='/identity/home/UnauthorizedError'</script>", context.HttpContext.Request.QueryString)); } }); app.UseCheckXForwardHeader(); InitializeDatabase(dbBootstrapper); app.UseCors(FabricIdentityConstants.FabricCorsPolicyName); app.UseStaticFiles(); app.UseStaticFilesForAcmeChallenge(ChallengeDirectory, Log.Logger); JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); app.UseSerilogRequestLogging(); app.UseCookiePolicy(); app.UseAuthentication(); app.UseIdentityServer(); app.UseMvcWithDefaultRoute(); var healthCheckService = app.ApplicationServices.CreateScope().ServiceProvider.GetRequiredService <IHealthCheckerService>(); app.UseOwin() .UseFabricMonitoring(healthCheckService.CheckHealth, LogFactory.LoggingLevelSwitch); // Enable middleware to serve generated Swagger as a JSON endpoint. app.UseSwagger(c => { c.RouteTemplate = "swagger/ui/index/{documentName}/swagger.json"; }); // Enable middleware to serve swagger-ui (HTML, JS, CSS etc.), specifying the Swagger JSON endpoint. app.UseSwaggerUI(c => { // this sets up the JSON endpoint (1 call to SwaggerEndpoint per version) c.SwaggerEndpoint("v1/swagger.json", "Health Catalyst Fabric Identity API V1"); c.RoutePrefix = "swagger/ui/index"; }); }