我想问你澄清当IdentityServer 4与ASP.NET身份集成。ASP.NET核心标识和身份服务器4 - [角色,声明和身份资源]
我正在处理两个数据库上下文。 Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityDbContext<IdentityUser>
和IdentityServer4.EntityFramework.DbContexts.ConfigurationDbContext
。
Identity Server 4正在使用AspNetIdentity .AddAspNetIdentity<IdentityUser>()
。
所以IdentityUser
已经分配了IdentityUserClaims
,并且在成功验证之后它在JWT令牌中得到了正确的反映。
现在的问题是,来自IdentityServer4的IdentityResource
和IdentityClaim:UserClaim
是什么ConfigurationDbContext
?由于现在从aspnet身份使用声明,因此完全不使用此实体。我对吗?
另一个问题是ApiScopeClaims
如何在游戏中?它们仍然由Identity Server使用,因为ApiScope
为其颁发了令牌。对?但现在我要保持同步ApiScopeClaim
和IdentityUserClaim
这是来自不同的数据库上下文。
最后一个问题是关于IdentityRoles
和IdentityRoleClaims
,它们与IdentityUserClaims
不一样。背后有什么想法?在我的想法中,角色是针对特定业务角色的索赔分组,以便于管理,因此角色不应定义新索赔,但应参考IdentityUserClaims
。另外,我创建了分配给用户的角色,分配给范围的相应索赔类型,结果是 - 分配给角色和用户的索赔具有此角色,但未包含在JWT中。为什么?
谢谢你的回答。
它是如何与'IdentityRoleClaims'?它们是'AspNetIdentity'的一部分,但它们是否包含在由IdentityServer4发布的JWT令牌中?我尝试过,但他们不包括在内,也没有角色要求。 –
当API资源需要声明“角色”时,角色包含在适当的值中。但如何包括角色声明? –
将“角色”声明类型添加到“openid”身份资源 –