How to load the claims in a second custom policy in AD B2C?

Pooranan Balasubramnian 0 Reputation points
2023-05-12T12:20:50.3133333+00:00

We have a built a member portal which onboards our customers using Azure B2C we have a custom policy which uses OIDC and generates the token. Once the user is in the portal we have outgoing links to external applications which all work with SAML and this whole set up uses SSO. So users once authenticated they can access these apps. Each of these apps - user journeys - have their own SAML policies since they need to get different values for each app so they use a REST API call. Now to call the API we need to read the claims set in the first policy without again interacting with the user so we can pass this to the REST call. What is the best option for this. Right now we have the first policy replicated and the REST Call happens automatically as there is a valid token but this seems redundant but i am not able to read the claims like email in any other way.

Microsoft Security | Microsoft Entra | Microsoft Entra External ID
{count} votes

1 answer

Sort by: Most helpful
  1. Akshay-MSFT 17,956 Reputation points Microsoft Employee Moderator
    2023-05-16T11:13:33.7666667+00:00

    @Pooranan Balasubramnian

    You can add a REST API call at any step in the user journey defined by a custom policy. For example, you can call a REST API:

    In this case it seems to be Immediately after sign-in to Azure AD B2C app. You need to Add an orchestration step in the existing signup-signin policy user journey.

    User journeys specify explicit paths through which a policy allows a relying party application to obtain the desired claims for a user. A user journey is represented as an orchestration sequence that must be followed through for a successful transaction. You can add or subtract orchestration steps. In this case, you will add a new orchestration step that is used to augment the information provided to the application after the user sign-up or sign-in via the REST API call.

    • Open the base file of your policy. For example, SocialAndLocalAccounts/TrustFrameworkBase.xml.
    • Search for the <UserJourneys> element. Copy the entire element, and then delete it.
    • Open the extensions file of your policy. For example, SocialAndLocalAccounts/TrustFrameworkExtensions.xml.
    • Paste the <UserJourneys> into the extensions file, after the close of the <ClaimsProviders> element.
    • Locate the <UserJourney Id="SignUpOrSignIn">, and add the following orchestration step before the last one.
    <OrchestrationStep Order="7" Type="ClaimsExchange">
      <ClaimsExchanges>
        <ClaimsExchange Id="RESTGetProfile" TechnicalProfileReferenceId="REST-GetProfile" />
      </ClaimsExchanges>
    </OrchestrationStep>
    
    • Refactor the last orchestration step by changing the Order to 8. Your final two orchestration steps should look like the following:
    <OrchestrationStep Order="7" Type="ClaimsExchange">
      <ClaimsExchanges>
        <ClaimsExchange Id="RESTGetProfile" TechnicalProfileReferenceId="REST-GetProfile" />
      </ClaimsExchanges>
    </OrchestrationStep>
    <OrchestrationStep Order="8" Type="SendClaims" CpimIssuerTechnicalProfileReferenceId="JwtIssuer" />				
    
    • Once done kindly follow Include a claim in the token. Please do let me know if you have any further queries by posting in the comments section. Thanks Akshay Kaushik Please "Accept the answer" (Yes), and share your feedback if the suggestion answers you’re your query. This will help us and others in the community as well.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.