如何为身份服务器配置OpenIdConnect和OAuth?

时间:2019-06-01 22:16:05

标签: asp.net-core asp.net-identity identityserver4

我正在尝试配置OpenIdConnectOptionsOAuthOptions以便解决an issue where custom claims are not mapped to the cookie。我正在运行ASP.NET Core 3.0 Preview 5 react SPA template。基本上,身份配置的要旨如下:

services.AddDefaultIdentity<ApplicationUser>()
    .AddEntityFrameworkStores<ApplicationDbContext>();

services.AddIdentityServer()
    .AddApiAuthorization<ApplicationUser, ApplicationDbContext>();

services.AddAuthentication()
   .AddIdentityServerJwt();

services.Configure<IdentityOptions>(options => {
   // These options are set
});

services.Configure<OpenIdConnectOptions>(options => { 
   // These are not set
   options.ClaimActions.MapUniqueJsonKey("MyCustomClaim", "MyCustomClaim");
   options.GetClaimsFromUserInfoEndpoint = true;
});

services.Configure<OAuthOptions>(options => {
   // Neither are these
   options.ClaimActions.MapUniqueJsonKey("MyCustomClaim", "MyCustomClaim");
});

现在,从日志中,我可以验证是否执行了services.Configure<IdentityOptions>,但是根本没有执行services.Configure<OpenIdConnectOptions>services.Configure<OAuthOptions>。我的印象是,身份服务器基本上是OAuth服务器之上的OpenIdConnect实现。那么为什么不使用这些服务呢?如何为身份服务器设置这些选项?

0 个答案:

没有答案