gpt4 book ai didi

c# - IdentityServer3 的 ASP.NET 身份插件 UI (IdentityManager) 在部署到 Azure (WebApp) 后不起作用

转载 作者:行者123 更新时间:2023-11-30 23:26:55 26 4
gpt4 key购买 nike

我使用提供的示例将 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

最佳答案

好吧,如果其他人偶然发现了这一点,解决方案是将 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 映射之后,则身份验证将不起作用。

关于c# - IdentityServer3 的 ASP.NET 身份插件 UI (IdentityManager) 在部署到 Azure (WebApp) 后不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36717161/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com