【问题标题】:Azure AD B2C AuthenticationResponseChallengeAzure AD B2C AuthenticationResponseChallenge
【发布时间】:2016-02-08 04:34:09
【问题描述】:

过去几天我一直在研究 Azure AD B2C,获得了一个示例并让它运行起来。 我面临的问题与AAD B2C issue 第 3 点完全一样,但我可以在这个问题中得到任何有价值的评论,这可能会解决我的问题。示例对我来说运行良好,但是当我在我的解决方案中实施它时,在提供 AAD B2C 凭据后,我最终得到:

   private async Task OnRedirectToIdentityProvider(RedirectToIdentityProviderNotification<OpenIdConnectMessage, OpenIdConnectAuthenticationOptions> notification)
    {
        PolicyConfigurationManager mgr = notification.Options.ConfigurationManager as PolicyConfigurationManager;
        if (notification.ProtocolMessage.RequestType == OpenIdConnectRequestType.LogoutRequest)
        {
            OpenIdConnectConfiguration config = await mgr.GetConfigurationByPolicyAsync(CancellationToken.None, notification.OwinContext.Authentication.AuthenticationResponseRevoke.Properties.Dictionary[Startup.PolicyKey]);
            notification.ProtocolMessage.IssuerAddress = config.EndSessionEndpoint;
        }
        else
        {
            OpenIdConnectConfiguration config = await mgr.GetConfigurationByPolicyAsync(CancellationToken.None, notification.OwinContext.Authentication.AuthenticationResponseChallenge.Properties.Dictionary[Startup.PolicyKey]);
            notification.ProtocolMessage.IssuerAddress = config.AuthorizationEndpoint;
        }
    }

在 'else' 部分,AuthenticationResponseChallenge 始终为 null,这会引发错误。谁能给我一个详细的答复,是什么原因造成的以及如何解决?

【问题讨论】:

  • 我遇到了同样的问题...您找到解决方案了吗?下面的答案建议检查 PolicyConfigurationManager.cs 但它的哪一部分以及要寻找什么?我通过它,它似乎工作。示例表单 MS 也适用于我,但是当我的项目使用它时它不起作用

标签: azure-web-app-service azure-ad-b2c


【解决方案1】:

我遇到了同样的问题,因为实际的 PolicyKey 未正确启动,请确保您拥有“PolicyAuthHelpers”(由 Microsoft 提供作为修复,因为他们当前的库无法处理 B2C)。将代码单步执行到 PolicyConfigurationManager.cs 中,您可能会发现它中断的原因。还要验证您是否在 web.config 中配置了正确的策略,例如:

<add key="ida:SignInPolicyId" value="B2C_1_signin" />

如果这没有帮助,你当然可以硬编码:

 OpenIdConnectConfiguration config = await mgr.GetConfigurationByPolicyAsync(CancellationToken.None, notification.OwinContext.Authentication.AuthenticationResponseChallenge.Properties.Dictionary["b2cpolicy"]);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-09
    • 2023-03-06
    • 1970-01-01
    • 2021-12-01
    • 2017-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多