【发布时间】:2017-12-22 21:05:00
【问题描述】:
在将 IdentityServer 4 与 ASP.NET Identity 集成时,我想请您澄清一下。
我正在使用两个数据库上下文。
Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityDbContext<IdentityUser> 和 IdentityServer4.EntityFramework.DbContexts.ConfigurationDbContext。
Identity Server 4 正在使用 AspNetIdentity .AddAspNetIdentity<IdentityUser>()。
所以IdentityUser 已经分配了IdentityUserClaims,并且在成功认证后正确反映在 JWT 令牌中。
现在的问题是,来自 IdentityServer4 ConfigurationDbContext 的 IdentityResource 和 IdentityClaim:UserClaim 是什么?由于现在从 aspnet 身份使用声明,因此根本不使用此实体。我说的对吗?
另一个问题是ApiScopeClaims 现在在游戏中的情况如何?由于为其颁发了令牌的ApiScope,它们仍然被身份服务器使用。正确的?但现在我要让来自不同数据库上下文的 ApiScopeClaim 和 IdentityUserClaim 保持同步。
最后一个问题是关于IdentityRoles 和IdentityRoleClaims,它们与IdentityUserClaims 不同。背后的想法是什么?在我的想法中,角色是针对特定业务角色的声明分组以便于管理,因此角色不应定义新声明,而应定义 IdentityUserClaims 的引用集。另外,我创建了角色,分配给用户,分配给范围的相应声明类型,结果是 - 分配给角色和用户具有此角色的声明不包含在 JWT 中。为什么?
感谢您的回答。
【问题讨论】:
标签: asp.net entity-framework asp.net-identity identityserver4