azure-active-directorysingle-sign-onazure-ad-b2cauth0azure-ad-b2c-custom-policy

How to auto redirect to Auth0 IDP from Azure AD B2C custom polcieis based on certain condition


We have added Auth0 as IDP in Azure AD B2C using custom policies. We want to redirect to Auth0 based on condition instead of user pressing button on UI.

Below is UserJourney in Azure AD B2C custom policies:

    <UserJourneys>
        <UserJourney Id="Internal" DefaultCpimIssuerTechnicalProfileReferenceId="JwtIssuer">
            <OrchestrationSteps>
                <OrchestrationStep Order="1" Type="ClaimsExchange">
                    <ClaimsExchanges>
                        <ClaimsExchange Id="pre-hrd" TechnicalProfileReferenceId="SelfAsserted-EmailOrUsernameCollect" />
                    </ClaimsExchanges>
                </OrchestrationStep>
                <OrchestrationStep Order="2" Type="ClaimsExchange">
                    <Preconditions>
                        <Precondition Type="ClaimsExist" ExecuteActionsIf="true">
                            <Value>objectIdFromSession</Value>
                            <Action>SkipThisOrchestrationStep</Action>
                        </Precondition>
                    </Preconditions>
                    <ClaimsExchanges>
                        <ClaimsExchange Id="HRD" TechnicalProfileReferenceId="HRD_Api" />
                    </ClaimsExchanges>
                </OrchestrationStep>
                <OrchestrationStep Order="3" Type="ClaimsExchange">
                    <Preconditions>
                        <Precondition Type="ClaimsExist" ExecuteActionsIf="false">
                            <Value>objectIdFromSession</Value>
                            <Action>SkipThisOrchestrationStep</Action>
                        </Precondition>
                    </Preconditions>
                    <ClaimsExchanges>
                        <ClaimsExchange Id="SSO_HRD" TechnicalProfileReferenceId="HRD_Api_SSO" />
                    </ClaimsExchanges>
                </OrchestrationStep>
    
                <OrchestrationStep Order="4" Type="CombinedSignInAndSignUp" ContentDefinitionReferenceId="api.signuporsignin">
                    <Preconditions>
                        <Precondition Type="ClaimEquals" ExecuteActionsIf="false">
                            <Value>idp</Value>
                            <Value>none</Value>
                            <Action>SkipThisOrchestrationStep</Action>
                        </Precondition>
                <Precondition Type="ClaimEquals" ExecuteActionsIf="true">
                <Value>connection</Value>
                <Value>B2CLocalUser</Value>
                <Action>SkipThisOrchestrationStep</Action>
            </Precondition>
                    </Preconditions>
                    <ClaimsProviderSelections>                              
                        <ClaimsProviderSelection TargetClaimsExchangeId="Auth0Login" />             
                    </ClaimsProviderSelections>                     
                </OrchestrationStep>
    
                <OrchestrationStep Order="5" Type="ClaimsExchange">
                    <Preconditions>
                        <Precondition Type="ClaimEquals" ExecuteActionsIf="true">
                            <Value>connection</Value>
                            <Value>B2CLocalUser</Value>
                            <Action>SkipThisOrchestrationStep</Action>
                        </Precondition>                      
                    </Preconditions>
                    <ClaimsExchanges>                                        
                        <ClaimsExchange Id="Auth0Login" TechnicalProfileReferenceId="Auth0-OID" />           
                    </ClaimsExchanges>
                </OrchestrationStep>
    
             
                <OrchestrationStep Order="6" Type="ClaimsExchange">
                    <Preconditions>
                        <Precondition Type="ClaimEquals" ExecuteActionsIf="false">
                            <Value>idp</Value>
                            <Value>none</Value>
                            <Action>SkipThisOrchestrationStep</Action>
                        </Precondition>              
                    </Preconditions>
                    <ClaimsExchanges>
                        <ClaimsExchange Id="SignUpWithLogonEmailExchange" TechnicalProfileReferenceId="LocalAccountSignUpWithLogonEmail" />
                    </ClaimsExchanges>
                </OrchestrationStep>-->
    
                <OrchestrationStep Order="6" Type="ClaimsExchange">
                    <Preconditions>
                        <Precondition Type="ClaimEquals" ExecuteActionsIf="false">
                            <Value>idp</Value>
                            <Value>costcoaad</Value>
                            <Action>SkipThisOrchestrationStep</Action>
                        </Precondition>
                        <Precondition Type="ClaimsExist" ExecuteActionsIf="true">
                            <Value>objectId</Value>
                            <Action>SkipThisOrchestrationStep</Action>
                        </Precondition>
                    </Preconditions>
                    <ClaimsExchanges>
                        <ClaimsExchange Id="HintedAzureADExchange" TechnicalProfileReferenceId="Client-AAD" />
                    </ClaimsExchanges>
                </OrchestrationStep>

* further steps
**
***
     <OrchestrationSteps>
</UserJourney>
</UserJourneys>

This journey shows the button on the UI for Auth0 like shown below, but we want to redirect to Auth0 when "idp" value is "none" and "connection" is not "B2CLocalUser" on step 4

Instead of showing the button, we want to redirect automatically to Auth0 IDP login.

enter image description here

How can we do this? I tried to put some conditions but it did not work.

Appreacite any help.

Thanks.

Update: I was able to redirect to Auth0 without user interaction. I put step 4 as below and it redirects me to Auth0 based on the condition.

<OrchestrationStep Order="4" Type="ClaimsExchange">
            <Preconditions>
                <Precondition Type="ClaimEquals" ExecuteActionsIf="true">
                    <Value>connection</Value>
                    <Value>B2CLocalUser</Value>
                    <Action>SkipThisOrchestrationStep</Action>
                </Precondition> 
                <Precondition Type="ClaimsExist" ExecuteActionsIf="true">
                    <Value>objectId</Value>
                    <Action>SkipThisOrchestrationStep</Action>
                </Precondition>
            </Preconditions>
            <ClaimsExchanges>
                <ClaimsExchange Id="Auth0Login" TechnicalProfileReferenceId="Auth0-OID" />
            </ClaimsExchanges>
        </OrchestrationStep>

Solution

  • I was able to redirect to Auth0 without user interaction. I put step 4 as below and it redirects me to Auth0 based on the condition.

    <OrchestrationStep Order="4" Type="ClaimsExchange">
                        <Preconditions>
                            <Precondition Type="ClaimEquals" ExecuteActionsIf="true">
                                <Value>connection</Value>
                                <Value>B2CLocalUser</Value>
                                <Action>SkipThisOrchestrationStep</Action>
                            </Precondition> 
                            <Precondition Type="ClaimsExist" ExecuteActionsIf="true">
                                <Value>objectId</Value>
                                <Action>SkipThisOrchestrationStep</Action>
                            </Precondition>
                        </Preconditions>
                        <ClaimsExchanges>
                            <ClaimsExchange Id="Auth0Login" TechnicalProfileReferenceId="Auth0-OID" />
                        </ClaimsExchanges>
                    </OrchestrationStep>