[英]Azure Active Directory Sign Up Redirects to Sign In
I am creating a website using ASP.Net Core, and securing it with Azure AD B2C. 我正在使用ASP.Net Core创建一个网站,并使用Azure AD B2C保护它。
I have already implemented signing in and it is all working fine, but now I am attempting to setup sign up and it doesn't seem to be working. 我已经实现了登录,并且一切正常,但是现在我尝试设置注册,但似乎无法正常工作。
My website setup is based on this sample . 我的网站设置基于此示例 。
In that example they do not use a sign up policy as they use a shared signup and signin policy (which I would prefer not to), but they do use an edit profile and reset password policy, the API methods can be seen on the SessionController . 在该示例中,他们不使用注册策略,因为他们使用共享的注册和登录策略(我不希望这样做),但是他们确实使用了编辑配置文件和重置密码策略,因此可以在SessionController上看到API方法。
I am trying to implement my signup endpoint in the same way like so: 我试图以相同的方式实现我的注册端点:
var properties = new AuthenticationProperties() { RedirectUri = "/" };
properties.Items[AzureAdB2COptions.PolicyAuthenticationProperty] = AzureAdB2COptions.SignUpPolicyId;
await HttpContext.Authentication.ChallengeAsync( OpenIdConnectDefaults.AuthenticationScheme, properties, ChallengeBehavior.Unauthorized);
However, when I go here I simply get redirected to the sign in page instead of the sign up page. 但是,当我去这里时,我只是被重定向到登录页面而不是注册页面。
The sign up policy and the B2C directory in general is setup correctly as I am using it on another site with no issues. 通常,正确设置了注册策略和B2C目录,因为我正在其他站点上正常使用它,没有任何问题。
Can anyone advise what may be causing this? 谁能告诉我这可能是什么原因?
In my OnRedirectToIdentityProvider method I had: 在我的OnRedirectToIdentityProvider方法中,我有:
context.ProtocolMessage.IssuerAddress = context.ProtocolMessage.IssuerAddress.Replace(defaultPolicy, policy);
As the IssuerAddress here is lower case it wasnt finding and changing the policy. 由于此处的IssuerAddress为小写字母,因此未找到并更改策略。
I updated it to: 我将其更新为:
context.ProtocolMessage.IssuerAddress = context.ProtocolMessage.IssuerAddress.ToLower().Replace(defaultPolicy.ToLower(), policy.ToLower());
As is in the latest version of the sample 与该示例的最新版本一样
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.