public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(Microsoft.AspNetCore.Mvc.CompatibilityVersion.Version_2_1); services.Configure <IISOptions>(options => { options.AutomaticAuthentication = false; options.AuthenticationDisplayName = "Windows"; }); services.AddCors(policies => policies.AddPolicy("default", options => { options.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin(); })); var builder = services.AddIdentityServer(options => { options.Events.RaiseErrorEvents = true; options.Events.RaiseInformationEvents = true; options.Events.RaiseFailureEvents = true; options.Events.RaiseSuccessEvents = true; }) .AddTestUsers(TestUsers.Users); // in-memory, code config builder.AddInMemoryIdentityResources(Config.GetIdentityResources()); builder.AddInMemoryApiResources(Config.GetApis()); builder.AddInMemoryClients(Config.GetClients()); builder.AddTestUsers(Config.GetTestUsers()); // in-memory, json config // builder.AddInMemoryIdentityResources(Configuration.GetSection("IdentityResources")); // builder.AddInMemoryApiResources(Configuration.GetSection("ApiResources")); // builder.AddInMemoryClients(Configuration.GetSection("clients")); if (Environment.IsDevelopment()) { builder.AddDeveloperSigningCredential(); } else { // Für Produktionsumgebungen sollte ein echtes trusted Zertifikat hinterlegt werden. // Mit diesem Zertifikat werden die Token verschlüsselt. throw new Exception("need to configure key material"); } // Es lassen sich externe Auth-Anbieter wie Azure AD, Github, Twitter, Google... einbinden // Im Prinzip jeder der OAuth 2.0 / OpenId Connect unterstützt. // Das Mapping von Claims kann von Anbieter zu Anbieter unterschiedlich sein. services.AddAuthentication() .AddGoogle(options => { options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme; // register your IdentityServer with Google at https://console.developers.google.com // enable the Google+ API // set the redirect URI to http://localhost:5000/signin-google options.ClientId = "copy client ID from Google here"; options.ClientSecret = "copy client secret from Google here"; }); }