如何在 B2C 自定义策略中阻止用户注册给定 IDP

How to block users signup for given IDP in B2C Custom Policy

我创建了一个使用两个 IDP 的自定义策略,我想允许用户只能从一个 IDP 注册并允许从两个 IDP 登录。

MS starter pack 的 SocialAccounts 开始,我正在尝试修改 SignUpOrSignIn UserJourney。

如果 objectId 不存在,OrchestrationStep 4 和 5 创建新用户。

<OrchestrationStep Order="4" Type="ClaimsExchange">
   <Preconditions>
     <Precondition Type="ClaimsExist" ExecuteActionsIf="true">
       <Value>objectId</Value>
       <Action>SkipThisOrchestrationStep</Action>
     </Precondition>
   </Preconditions>
   <ClaimsExchanges>
     <ClaimsExchange Id="SelfAsserted-Social" TechnicalProfileReferenceId="SelfAsserted-Social" />
   </ClaimsExchanges>
</OrchestrationStep>

<OrchestrationStep Order="5" Type="ClaimsExchange">
   <Preconditions>
      <Precondition Type="ClaimsExist" ExecuteActionsIf="true">
        <Value>objectId</Value>
          <Action>SkipThisOrchestrationStep</Action>
     </Precondition>
   </Preconditions>
   <ClaimsExchanges>
     <ClaimsExchange Id="AADUserWrite" TechnicalProfileReferenceId="AAD-UserWriteUsingAlternativeSecurityId" />
   </ClaimsExchanges>
</OrchestrationStep>

为了排除来自一个特定 IDP 的用户的注册,我在两个步骤中都添加了这个先决条件

      <Precondition Type="ClaimEquals" ExecuteActionsIf="true">
        <Value>identityProvider</Value>
        <Value>https://myIdpdprovider</Value>
        <Action>SkipThisOrchestrationStep</Action>
      </Precondition>

这是符合我的意图的正确解决方案吗?

感谢 Jas Suri - MSFT 和 Alex 提供的建议。将您的建议作为答案发布以帮助其他社区成员。

Custom policies are configuration files that define the behaviour of your Azure Active Directory B2C (Azure AD B2C) tenant. While user flows are predefined in the Azure AD B2C portal for the most common identity tasks, A custom policy is represented as one or more XML-formatted files. custom policies can be fully edited by an identity developer to complete many different tasks

为了排除特定 IDP 的用户注册,即已经在自定义策略修复中,在先决条件部分添加了 IDP 并对其应用了操作。