Azure B2C claims transformation, GetClaimFromJson, for standart OpenID Connect provider

Yauh Ask 0 Reputation points
2023-07-24T10:44:50.0166667+00:00


It looks like claims in Json Object as:

{
  "address": {
    "locality": "Brussels",
    "street_address": "Cookie street 103",
    "postal_code": "1000",
    "formatted": "Cookie street 103 1000 Brussels"
  }
}

can not be interpreted by Azure B2C. I struggle with claims transformation instruction to validate in reality. Ref https://learn.microsoft.com/en-us/azure/active-directory-b2c/json-transformations#getclaimfromjson & https://github.com/azure-ad-b2c/unit-tests/tree/main/claims-transformation/json

From github I see they use ExperimentalTechnicalProfile, would it mean it is not applicable for Openid Connect providers? How would you write a claim transformation config within base.xml for example above to parse if Openid Connect should work?

I tried multiple configuration, expecting Json object transformed to strings. But instead Azure errors with exception page.
Microsoft Security | Microsoft Entra | Microsoft Entra ID
{count} votes

1 answer

Sort by: Most helpful
  1. James Hamil 27,221 Reputation points Microsoft Employee Moderator
    2023-07-25T20:33:02.75+00:00

    Hi @Yauh Ask , try using the GetClaimFromJson transformation method. Here's a sample configuration for parsing the formatted field from the JSON object:

    <ClaimsTransformation Id="GetFormattedAddressFromJson" TransformationMethod="GetClaimFromJson">
      <InputClaims>
        <InputClaim ClaimTypeReferenceId="addressJson" TransformationClaimType="inputJson" />
      </InputClaims>
      <InputParameters>
        <InputParameter Id="claimToExtract" DataType="string" Value="address.formatted" />
      </InputParameters>
      <OutputClaims>
        <OutputClaim ClaimTypeReferenceId="formattedAddress" TransformationClaimType="extractedClaim" />
      </OutputClaims>
    </ClaimsTransformation>
    
    

    In this example, the addressJson claim should contain the JSON object you provided. The transformation will extract the formatted field and store it in the formattedAddress claim.

    Regarding the use of ExperimentalTechnicalProfile, it is not necessary for parsing JSON objects from OpenID Connect providers. The claims transformation configuration provided above should work within the base.xml file.

    If you're still encountering errors, please double-check your configuration and ensure that the input claims are correctly populated.

    Please let me know if you have any questions and I can help you further.

    If this answer helps you please mark "Accept Answer" so other users can reference it.

    Thank you,

    James


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.