Azure AD B2C AuthenticationResponseChallenge
Azure AD B2C AuthenticationResponseChallenge
我最近几天在 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,即抛出错误。谁能给我一个详细的答复,这是什么原因造成的以及如何解决?
我遇到了同样的问题,因为实际的 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"]);
我最近几天在 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,即抛出错误。谁能给我一个详细的答复,这是什么原因造成的以及如何解决?
我遇到了同样的问题,因为实际的 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"]);