AD B2C 自定义策略重定向

时间:2021-02-05 09:21:11

标签: azure http single-page-application azure-ad-b2c azure-ad-b2c-custom-policy

我有一个 AD B2C 自定义策略,基本上是重置密码和重定向到 React 应用程序,基于此参考:https://medium.com/the-new-control-plane/invoking-the-azure-ad-b2c-custom-policy-journey-with-a-jwt-e9e3ff0560a3

当您重置密码并按接受时,您将被重定向到您在自定义策略中指定的 React URL 应用程序,但重定向恰好是带有要进行身份验证的 Id 令牌的帖子,但 React 应用程序不知道如何处理 POST 请求并返回 500 错误代码。

政策代码描述如下:

 <UserJourney Id="PasswordResetJWT">
  <OrchestrationSteps>
    <OrchestrationStep Order="1" Type="ClaimsExchange">
      <ClaimsExchanges>
        <ClaimsExchange Id="PasswordResetUsingEmailAddress" TechnicalProfileReferenceId="AAD-UserReadUsingEmailAddress" />
      </ClaimsExchanges>
    </OrchestrationStep>
    <OrchestrationStep Order="2" Type="ClaimsExchange">
      <ClaimsExchanges>
        <ClaimsExchange Id="NewCredentials" TechnicalProfileReferenceId="LocalAccountWritePasswordUsingObjectId" />
      </ClaimsExchanges>
    </OrchestrationStep>
    <OrchestrationStep Order="3" Type="SendClaims" CpimIssuerTechnicalProfileReferenceId="JwtIssuer" />
  </OrchestrationSteps>
  <ClientDefinition ReferenceId="DefaultWeb" />
</UserJourney>

1 个答案:

答案 0 :(得分:0)

我不是 React 专家,但您可以更改代码返回到您的应用程序的方式。

阅读您提供的文章后,作者明确声明要通过 POST 返回代码。但是,根据 B2C Documentation,您可以通过设置 response_mode 参数来指定要返回的代码。

  1. response_mode=query
  2. response_mode=fragment
  3. response_mode=form_post