public void ConfigureServices(IServiceCollection services) { services.Configure <CookiePolicyOptions>(options => { options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddControllersWithViews(config => { var policy = new AuthorizationPolicyBuilder() .RequireAuthenticatedUser() .Build(); config.Filters.Add(new AuthorizeFilter(policy)); }); services.AddHsts(options => { options.Preload = true; options.IncludeSubDomains = true; options.MaxAge = TimeSpan.FromDays(365); }); services.AddHttpsRedirection(options => { options.RedirectStatusCode = StatusCodes.Status308PermanentRedirect; options.HttpsPort = _configuration.GetValue <int>("HttpsPort"); }); services.AddApplicationInsightsTelemetry(); var authenticationConfig = new AuthenticationConfiguration(services, _configuration, _environment); authenticationConfig.Configure(); var databaseConfig = new DatabaseConfiguration(services, _configuration, _environment); databaseConfig.Configure(); var dataAccessConfiguration = new DataAccessConfiguration(services, _configuration, _environment); dataAccessConfiguration.Configure(); var businessLogicConfiguration = new BusinessLogicConfiguration(services, _configuration, _environment); businessLogicConfiguration.Configure(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "DavidMorales.WebHost v1")); app.UseDeveloperExceptionPage(); app.UseCors(builder => { builder.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader(); }); } else { //app.UseExceptionHandler("/Error"); app.UseSwagger(); app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "DavidMorales.WebHost v1")); app.UseDeveloperExceptionPage(); app.UseCors(builder => { builder.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader(); }); } RestServiceConfiguration.Configure(app); DatabaseConfiguration.Configure(app); IdentityServiceConfiguration.Configure(app); AuthenticationConfiguration.Configure(app); AppAuthorizationConfiguration.Configure(app); }