[英]Azure AD B2C signup only custom policy does not create a session cookie in the .net MVC application
I have .net mvc application which is integrated with Azure B2C using Owin Middleware.我有 .net mvc 应用程序,它使用 Owin 中间件与 Azure B2C 集成。 Azure AD B2C is setup with a custom signup only policy. Azure AD B2C 设置有自定义注册策略。
After Signup, id_token is been returned to the .net application.注册后,id_token 被返回给 .net 应用程序。 But session cookie is not created.但是没有创建 session cookie。 I noticed If click on login again and redirect user B2C,session cookie is created and logged in to the application.我注意到如果再次单击登录并重定向用户 B2C,则创建 session cookie 并登录到应用程序。
My policy includes following user journey.我的政策包括跟随用户旅程。 Do I need to include any additional steps to pass the session cookie to the application after Signup?注册后是否需要包含任何其他步骤才能将 session cookie 传递给应用程序?
<UserJourney Id="SignUp">
<OrchestrationSteps>
<OrchestrationStep Order="1" Type="ClaimsExchange">
<ClaimsExchanges>
<ClaimsExchange Id="SignUpWithLogonEmailExchange" TechnicalProfileReferenceId="LocalAccountSignUpWithLogonEmail" />
</ClaimsExchanges>
</OrchestrationStep>
<OrchestrationStep Order="2" Type="ClaimsExchange">
<ClaimsExchanges>
<ClaimsExchange Id="AADUserReadWithObjectId" TechnicalProfileReferenceId="AAD-UserReadUsingObjectId" />
</ClaimsExchanges>
</OrchestrationStep>
<OrchestrationStep Order="3" Type="SendClaims" CpimIssuerTechnicalProfileReferenceId="JwtIssuer" />
</OrchestrationSteps>
<ClientDefinition ReferenceId="DefaultWeb" />
</UserJourney>
"state" property was the key to the solution. “状态”属性是解决方案的关键。 Owin middleware maintains the state=OpenIdConnect.AuthenticationProperties%3dHxxxx in the URL. Owin 中间件在 URL 中维护 state=OpenIdConnect.AuthenticationProperties%3dHxxxx。
When the user clicked on the signup link.当用户点击注册链接时。 it was a JavaScript redirect to b2c signup page without the state properties.这是一个 JavaScript 重定向到没有 state 属性的 b2c 注册页面。 We had ignored the state property that was auto-generated by the middleware.我们忽略了中间件自动生成的 state 属性。
After signup when the user was redirected back to the home page.注册后,当用户被重定向回主页时。 Owin middleware will not create the session as it did not find the original state property it had added in the request. Owin 中间件不会创建 session,因为它没有找到它在请求中添加的原始 state 属性。
Its nowhere mentioned that's how OpenIdConnect middleware creates a cookie session.它没有提到OpenIdConnect中间件如何创建cookie session。 This comment was a bit of clue这条评论有点线索
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.