C# IdentityServer3的ASP.NET标识插件UI(IdentityManager)在部署到Azure(WebApp)后不工作
我使用提供的示例设置IdentityServer3以使用ASP.NET标识。本地一切正常,我可以通过“/admin”访问Identity Manager UI,并可以添加/删除用户/角色 但是,当我将其部署到Azure并尝试访问它时,什么也没有发生,并将我带到一个URL,该URL如下所示: 无论我使用本地或远程(Azure SQL)数据库,它在本地都可以正常工作 IdentityManager在首次访问时自动登录本地用户,我怀疑这可能是访问远程服务器时出现的问题,但我不确定如何自定义/更改此问题C# IdentityServer3的ASP.NET标识插件UI(IdentityManager)在部署到Azure(WebApp)后不工作,c#,asp.net,azure,asp.net-identity,identityserver3,C#,Asp.net,Azure,Asp.net Identity,Identityserver3,我使用提供的示例设置IdentityServer3以使用ASP.NET标识。本地一切正常,我可以通过“/admin”访问Identity Manager UI,并可以添加/删除用户/角色 但是,当我将其部署到Azure并尝试访问它时,什么也没有发生,并将我带到一个URL,该URL如下所示: 无论我使用本地或远程(Azure SQL)数据库,它在本地都可以正常工作 IdentityManager在首次访问时自动登录本地用户,我怀疑这可能是访问远程服务器时出现的问题,但我不确定如何自定义/更改此问
我使用的示例如下:好的,如果其他人偶然发现了这一点,解决方案是将IdentityManager的安全配置更改为
主机安全配置,然后:
手动实现如下所示的简单身份验证机制:
或
像配置任何其他OIDC客户端一样配置IdentityManager。详情如下:
所有这些都是必需的,因为默认情况下,IdentityManager使用LocalhostSecurityConfiguration
,它只允许通过localhost
进行身份验证
对于第二个选项,IdentityManager的SecurityConfiguration最终将如下所示:
managerApp.UseIdentityManager(new IdentityManagerOptions()
{
SecurityConfiguration = new HostSecurityConfiguration
{
HostAuthenticationType = "cookies",
AdditionalSignOutType = "oidc",
NameClaimType = Constants.ClaimTypes.Name,
RoleClaimType = Constants.ClaimTypes.Role,
AdminRoleName = "IdentityManagerAdministrator" //default role name for IdentityManager
}
});
作为提示,如果在与IdentityServer本身相同的web应用程序中运行IdentityManager,请确保将IdentityManager的身份验证逻辑放在IdentityServer映射之后、IdentityManager映射之前:
app.Map("/identity", idsrvApp =>
//this sets IdentityManager to use IdentityServer as Idp
ConfigureIdentityManagerAuthentication(app);
app.Map("/manager", managerApp =>
如果将其放在IdentityServer映射之前,则会在IdentityServer登录页面中看到额外的外部“OpenId”提供程序。如果将其放在Identity Manager映射之后,则身份验证将不起作用。您是否已将Identity Server添加为Identity Manager的安全提供程序,还是按原样使用该示例?@ScottBrady我按原样使用它。现在我正在看这段视频,意识到默认配置是LocalHostSecurity,我怀疑这是有道理的。是否有配置快捷方式可以将IdentityServer添加为IdentityManager的安全提供程序,或者我必须将IdentityManager视为任何其他客户端?它应视为任何其他客户端。然而,identitymanageropions中还需要一些配置,以及一些自定义范围。我最近写了一篇文章,其中包括了如果你感兴趣的话如何做到这一点:@ScottBrady你提到IdentityManagerAdministrator作为角色声明,但我看不到它在代码中的任何地方使用。这是IdentityManager默认理解的吗?我希望必须在HostSecurityConfiguration.AdminRoleName属性中配置它。默认情况下,AdminRoleName为IdentityManagerAdministrator()scottbrady91.com不可用。谷歌缓存: