【问题标题】:ASP.NET Identity plugin UI (IdentityManager) for IdentityServer3 not working after deploying to Azure (WebApp)IdentityServer3 的 ASP.NET 身份插件 UI (IdentityManager) 在部署到 Azure (WebApp) 后无法正常工作
【发布时间】:2016-04-19 11:32:49
【问题描述】:

我使用提供的示例将 IdentityServer3 设置为使用 ASP.NET Identity。在本地一切正常,我可以通过“/admin”访问 Identity Manager UI,并可以添加/删除用户/角色。

但是,当我将它部署到 Azure 并尝试访问它时,什么也没有发生,而是将我带到一个如下所示的 URL: https://IdentityServer3/admin/authorize?state=11373557769572288&client_id=idmgr&response_type=token

无论我使用本地还是远程 (Azure SQL) 数据库,它都可以在本地正常工作。

IdentityManager 在首次访问时自动登录本地用户,我怀疑这在访问远程服务器时可能是个问题,但我不确定如何自定义/更改它。

我使用的示例在这里:https://github.com/IdentityServer/IdentityServer3.Samples/tree/master/source/AspNetIdentity

【问题讨论】:

  • 您是否已将 Identity Server 添加为 Identity Manager 的安全提供程序,还是按原样使用示例?
  • @ScottBrady 我按原样使用它。现在我正在观看这个视频vimeo.com/125427106 并意识到默认配置是我怀疑并且有意义的 LocalHostSecurity。是否有将 IdentityServer 添加为 IdentityManager 的安全提供程序的配置快捷方式,或者我必须将 IdentityManager 视为任何其他客户端?
  • 它应该被视为任何其他客户端。然而,IdentityManagerOptions 需要一些配置,外加一些自定义范围。我最近写了一篇文章,如果你有兴趣,我会写一篇文章:scottbrady91.com/ASPNET-Identity/…
  • @ScottBrady 您提到 IdentityManagerAdministrator 作为角色声明,但我看不到它在代码中的任何地方使用。这是 IdentityManager 默认理解的吗?我期望必须在 HostSecurityConfiguration.AdminRoleName 属性中对其进行配置。
  • 默认 AdminRoleName 是 IdentityManagerAdministrator (github.com/IdentityManager/IdentityManager/blob/…)

标签: c# asp.net azure asp.net-identity identityserver3


【解决方案1】:

好的,如果其他人偶然发现此问题,解决方案是将 IdentityManager 的 SecurityConfiguration 更改为 HostSecurityConfiguration,然后:

  1. 手动实现一个简单的身份验证机制,如下所示:https://vimeo.com/125427106

  2. 像配置任何其他 OIDC 客户端一样配置 IdentityManager。更多细节在这里:https://www.scottbrady91.com/ASPNET-Identity/Identity-Manager-using-ASPNET-Identity

以上所有内容都是必要的,因为默认情况下 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”提供程序。如果将其放在 IdentityManager 映射之后,则身份验证将不起作用。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2020-02-17
  • 1970-01-01
  • 2019-09-21
  • 1970-01-01
  • 2023-03-06
  • 1970-01-01
  • 2014-10-05
  • 2021-03-25
相关资源
最近更新 更多