public void ConfigureServices(IServiceCollection services) { services .AddIdentityServer() .AddDeveloperSigningCredential() .AddInMemoryApiResources(IdentityConfig.GetApiResources()) .AddInMemoryClients(IdentityConfig.GetClients()) .AddTestUsers(IdentityConfig.GetUsers()); }
// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.AddIdentityServer() .AddTemporarySigningCredential() .AddTestUsers(IdentityConfig.GetTestUsers()) .AddInMemoryApiResources(IdentityConfig.GetApiResources()) .AddInMemoryIdentityResources(IdentityConfig.GetIdentityResources()) .AddInMemoryClients(IdentityConfig.GetClients()); services.AddMvc(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddSingleton <IConfiguration>(Configuration); services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddAuthentication(sharedOptions => { sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; }) .AddAzureAd(Configuration.GetSection("IdentityProvider:AzureAd").Get <AzureAdConfig>()) .AddAzureAdB2C(Configuration.GetSection("IdentityProvider:AzureAdB2C").Get <AzureAdB2CConfig>()) .AddCookie(options => { options.Events.OnRedirectToLogin = context => { context.Response.Headers["Location"] = context.RedirectUri; context.Response.StatusCode = 401; return(Task.CompletedTask); }; }); // Identity Server services.AddIdentityServer() .AddDeveloperSigningCredential() .AddInMemoryPersistedGrants() .AddInMemoryIdentityResources(IdentityConfig.GetIdentityResources()) .AddInMemoryApiResources(IdentityConfig.GetApiResources(Configuration)) .AddInMemoryClients(IdentityConfig.GetClients(Configuration)) .AddProfileService <IdentityWithAdditionalClaimsProfileService>(); services.AddDistributedMemoryCache(); services.AddSession(options => { options.IdleTimeout = TimeSpan.FromHours(1); options.Cookie.HttpOnly = true; }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1) .AddSessionStateTempDataProvider();; }