简体   繁体   English

Azure AD B2C 仅注册自定义策略不会在 .net MVC 应用程序中创建 session cookie

[英]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.

相关问题 在 .NET MVC 应用程序中验证 Azure AD B2C JWT - Validating Azure AD B2C JWT in a .NET MVC application .Net MVC 与 Azure Ad B2C 注册和密码重置自定义策略的集成返回 id_token 作为 url 中的#片段 - .Net MVC integration with Azure Ad B2C signuponly and password reset custom policy returns id_token as # fragment in the url Azure Ad B2C - 在 ASP .net MVC 应用程序中检索多个 Web API 的多个不记名令牌 - Azure Ad B2C - Retrieve multiple bearer token for multiple Web Apis in a ASP .net MVC application Azure ad b2c身份验证质询丢失了会话对象 - Azure ad b2c authentication challenge loses session object 将社交帐户链接到 Azure AD B2C 上的本地帐户,来自 .net MVC 中经过身份验证的用户 - Linking Social Account into Local Account on Azure AD B2C from authenticated user in .net MVC 将字段值从mvc应用程序传递到b2c注册自定义策略文件 - Pass field values from mvc application to the b2c sign up custom policy filelds ASP.NET 5 API - Azure AD B2C - ASP.NET 5 API - Azure AD B2C Azure AD B2C ASP.NET 重定向循环 - Azure AD B2C ASP.NET redirect loop Azure AD B2C-不重定向到登录/注册页面(login.microsoftonline.com…) - Azure AD B2C - Not redirecting to SignIn/SignUp Page(login.microsoftonline.com…) Azure AD B2C - 角色管理 - Azure AD B2C - Role management
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM