public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews(); services.AddIdentityServer(options => { options.Events.RaiseErrorEvents = true; options.Events.RaiseInformationEvents = true; options.Events.RaiseFailureEvents = true; options.Events.RaiseSuccessEvents = true; }) // IdentityResources 用户相关权限 .AddInMemoryIdentityResources(InMemoryConfig.IdentityResources()) // api访问权限 .AddInMemoryApiScopes(InMemoryConfig.ApiScopes) // 客户端配置 .AddInMemoryClients(InMemoryConfig.Clients()) // 测试用户 .AddTestUsers(TestUsers.Users) //扩展在每次启动时,为令牌签名创建了一个临时密钥 .AddDeveloperSigningCredential(); services.AddAuthentication() //覆盖 Cookie 处理程序配置 .AddCookie("Cookies") //.AddGoogle("Google", options => // { // options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme; // options.ClientId = "clientID"; // options.ClientSecret = "clientSecret"; // }) //远程测试 .AddOpenIdConnect("oidc", "Demo IdentityServer", options => { options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme; options.SignOutScheme = IdentityServerConstants.SignoutScheme; options.SaveTokens = true; options.Authority = "https://demo.identityserver.io/"; options.ClientId = "interactive.confidential"; options.ClientSecret = "secret"; options.ResponseType = "code"; options.TokenValidationParameters = new TokenValidationParameters { NameClaimType = "name", RoleClaimType = "role" }; }); }