// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var identityServerSettings = Configuration.GetSection(IdentityServerSettings.Section) .Get <IdentityServerSettings>(); var identityServerConfig = new IdentityServerConfiguration(identityServerSettings); services.Configure <AccountOptions>(e => { e.AutomaticRedirectAfterSignOut = true; }); services.Configure <ConsentOptions>(e => { e.EnableOfflineAccess = false; }); services.AddDbContext <IdentityDbContext>(options => options.UseSqlServer( Configuration.GetConnectionString(ConfigurationConstants.AuthDbConnectionString))); services.AddIdentity <IdentityUser, IdentityRole>(e => IdentityConfiguration.ConfigureOptions(e, Configuration)) .AddEntityFrameworkStores <IdentityDbContext>() .AddDefaultTokenProviders(); services.ConfigureApplicationCookie(e => { var controllerName = "Account"; e.Cookie.Name = "IdentityServer.Cookie"; e.LoginPath = $"/{controllerName}/Login"; e.LogoutPath = "/Home/Index"; e.AccessDeniedPath = $"/{controllerName}/AccesDenied"; }); services.AddIdentityServer() .AddInMemoryClients(identityServerConfig.Clients) .AddInMemoryIdentityResources(identityServerConfig.IdentityResources) .AddInMemoryApiResources(identityServerConfig.Apis) .AddInMemoryApiScopes(identityServerConfig.ApiScopes) .AddTestUsers(IdentityServerConfiguration.TestUsers.ToList()) .AddAspNetIdentity <IdentityUser>() .AddDeveloperSigningCredential(); services.AddControllersWithViews(); }