【问题标题】:When using Azure AD B2C with Azure Mobile Apps, how is the password policy set?将 Azure AD B2C 与 Azure 移动应用一起使用时,密码策略是如何设置的?
【发布时间】:2017-07-27 08:39:03
【问题描述】:

在 Azure AD B2C 中,“注册/登录”和“密码重置”有不同的策略。我复制了“注册/登录”策略的元数据端点

并将其粘贴到 Azure 应用身份验证中

这基本上可以,但是没有地方可以放入具有密码重置模板的密码重置元数据。我认为因此,当您单击“忘记密码”时,您最终会得到

您无权查看此目录或页面。

在尝试访问 /xxx.onmicrosoft.com/B2C_1_b2c_sign_up_sign_in/api/CombinedSigninAndSignup/forgotPassword?csrf_token=xxx&p=B2C_1_b2c_sign_up_sign_in 时在 ~/.auth/login/aad/callback

为什么没有登录/注册/密码重置?

另外,另一个奇怪的事情是点击创建一个新帐户。

如果你按下取消,它会再次进入回调需要权限页面。

我下载了策略,并且密码重置有以下不在登录中的内容

<UserJourneys>
    <UserJourney Id="B2CPasswordResetV1">
      <OrchestrationSteps>
        <OrchestrationStep Order="1" Type="ClaimsProviderSelection" ContentDefinitionReferenceId="api.idpselections">
          <ClaimsProviderSelections>
            <ClaimsProviderSelection TargetClaimsExchangeId="PasswordResetUsingEmailAddressExchange" />
          </ClaimsProviderSelections>
        </OrchestrationStep>
      </OrchestrationSteps>
    </UserJourney>
  </UserJourneys>
  <RelyingParty>
    <DefaultUserJourney ReferenceId="B2CPasswordResetV1" />
    <TechnicalProfile Id="PolicyProfile">
      <DisplayName>PolicyProfile</DisplayName>
      <Protocol Name="OpenIdConnect" />
      <OutputClaims>
        <OutputClaim ClaimTypeReferenceId="objectId" />
        <OutputClaim ClaimTypeReferenceId="objectId" PartnerClaimType="sub" />
        <OutputClaim ClaimTypeReferenceId="emails" />
        <OutputClaim ClaimTypeReferenceId="displayName" />
        <OutputClaim ClaimTypeReferenceId="trustFrameworkPolicy" Required="true" DefaultValue="{policy}" />
      </OutputClaims>
      <SubjectNamingInfo ClaimType="sub" />
    </TechnicalProfile>
  </RelyingParty>

更新。我刚刚发现了这个

当您创建注册或登录策略(使用本地帐户)时, 消费者会看到“忘记密码?”第一页上的链接 经验。单击此链接不会自动触发 密码重置策略。相反,特定的错误代码 AADB2C90118 是 返回到您的应用程序。您的应用程序需要处理此问题并调用 特定的密码重置策略。一个演示这一点的示例 将政策联系在一起的方法就在这里。

看起来它已发布到回调。所以似乎 zumo 回调无法处理错误。如果 zumo 回调得到一个 state/code/id_token,那么它就完成了。

【问题讨论】:

    标签: azure azure-mobile-services azure-ad-b2c


    【解决方案1】:

    遗憾的是,对 B2C 的集成应用服务支持不允许您的应用处理错误回调以重定向到您的重置密码策略。此时您的选择是:

    1. 使用自定义 CSS 删除重置密码链接或
    2. 在 web.config 中配置一个自定义错误处理程序来处理错误并允许最终用户通过将其重定向到 /.auth/login/aad?p=B2C_1_B2CPasswordResetV1 来调用您的密码重置策略。

    我在这篇博文评论中写了一个#2 的快速示例:https://cgillum.tech/2016/08/10/app-service-auth-and-azure-ad-b2c-part-2/#comment-581

    这是我分享的 web.config sn-p,它显示了如何处理此错误并重定向到移动后端上的静态页面:

    <configuration>
      <system.webServer>
        <httpErrors defaultResponseMode="File" errorMode="Custom" >
          <clear />
          <error statusCode="401" subStatusCode="73" path="MyPage.html" />
        </httpErrors>
      <system.webServer>
    </configuration>
    

    还提供其他响应模式,包括 ExecuteURLRedirect。根据您的需要,其中之一可能比我使用 File 的示例更合适。有关 IIS 自定义错误的更多详细信息,请参见:https://www.iis.net/configreference/system.webserver/httperrors#005

    【讨论】:

    • 谢谢克里斯,我正要追捕你! :) - 集成应用服务是 Azure 内部的东西吗?似乎这是非常重要的功能!如果您在尝试创建新用户后按“取消”也会发生这种情况。
    • 我也试过&lt;error statusCode="401" path="mypage.html"/&gt; 无济于事。也许有东西被 Nancy/Zumo/SignalR 拦截了
    • 我想通了。这是南希的错。当我关闭 Nancy 时,拦截工作正常。
    • @cgillum 似乎无法区分取消的用户创建和忘记密码 401
    • 看起来这样做的方法是将错误发送给 asp 或 Nancy,然后解析引用者 - 从中​​检查代码并检查“forgotPassword”或“cancelled”,然后适当地重定向跨度>
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-09
    • 2021-06-25
    • 1970-01-01
    • 2019-07-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多