using IdentityOIDCWebApplicationSample.Identity.Data; using IdentityOIDCWebApplicationSample.Identity.Models; using IdentityOIDCWebApplicationSample.Identity.Services; using Microsoft.AspNetCore.Authentication.Extensions; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Diagnostics.Identity.Service; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity.Service; using Microsoft.AspNetCore.Identity.Service.AzureKeyVault; using Microsoft.AspNetCore.Identity.Service.EntityFrameworkCore; using Microsoft.AspNetCore.Identity.Service.Extensions; using Microsoft.AspNetCore.Identity.Service.IntegratedWebClient; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; namespace IdentityOIDCWebApplicationSample { public class Startup { public Startup(IConfiguration configuration, IHostingEnvironment environment) { Configuration = configuration; Environment = environment; } public IConfiguration Configuration { get; } public IHostingEnvironment Environment { get; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); var builder = services.AddIdentity() .AddDefaultTokenProviders() .AddApplications() .AddEntityFrameworkStores() .AddClientInfoBinding(); services .AddWebApplicationAuthentication() .WithIntegratedWebClient(); services.AddTransient(); services.AddTransient(); services.AddMvc(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); app.UseDevelopmentCertificateErrorPage(Configuration); } else { app.UseExceptionHandler("/Home/Error"); } app.UseHttps(); app.UseStaticFiles(); app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); } } }