【发布时间】:2021-10-02 16:34:34
【问题描述】:
我们正在迁移旧版网络应用,但希望保留存储在数据库中的特定于应用的用户信息。我们已经成功地针对我们的新 Azure AD 设置了身份验证——我们正在使用具有多个租户的 OIDC。用户登录后,我们将通过他们的电子邮件地址从数据库中查找相关的用户记录。问题在于将我们现有的用户数据映射到ClaimPrincipal。文档声称我们可以扩展 IdentityUser 并通过以下方式注册更改:
services.AddIdentity<AppUser, IdentityRole>(); //AppUser is our custom IdentityUser
现在,我们的Startup.cs 文件包含:
services.AddIdentity<AppUser, IdentityRole>();
services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApp(Configuration.GetSection("AzureAd"));
但是,服务解析器对此并不满意。
某些服务无法构建(验证时出错 服务描述符'ServiceType: Microsoft.AspNetCore.Identity.ISecurityStampValidator 生命周期:范围 实施类型: Microsoft.AspNetCore.Identity.SecurityStampValidator`1[GcfConnect.Application.Web.Security.Models.AppUser]': 无法解析类型的服务 'Microsoft.AspNetCore.Identity.IUserStore`1[GcfConnect.Application.Web.Security.Models.AppUser]' 尝试激活时...(SNIPPED)
如何在 Azure AD 身份验证中使用自定义 IdentityUser?我是否需要为整个身份系统(UserStore、UserManager 等)提供自定义替换?
【问题讨论】:
标签: c# azure asp.net-core identity