2016-02-08 102 views
1

我在过去几天在Azure AD B2C上工作,获得了一个示例并使其运行。 我正面临的问题与AAD B2C issue点#3完全相同,但我可以在此问题中获得任何有价值的意见,这可能会解决我的问题。例如运行罚款与我,但是当我在我的解决方案来实现它,给AAD B2C凭据后我'结束了:Azure AD 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; 
     } 
    } 

在“其他”部分,AuthenticationResponseChallenge始终为空,这是抛一个错误。任何人都可以给我一个详细的答复,因为是什么导致了这个以及如何解决它?

+0

我有同样的问题。 ..你找到一个解决方案?下面的答案建议检查PolicyConfigurationManager.cs,但它是什么部分以及要查找什么?我穿过它,它似乎工作。 MS的示例表格也适用于我,但是当对我的项目进行浏览时,它不会 – kurasa

回答

0

我有同样的问题,因为实际的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"]); 
相关问题