2

I'm trying to extract a list from a JSON response and put it inside a variable so that I can later put this list as a claim in my custom generated JWT with GenerateJWT.

My current problem is that I'm always ending up with a stringified array as a string.

ExtractVariables

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="true" enabled="true" name="ExtractResponse">
    ...
    <JSONPayload>
        <Variable name="sysRoles">
            <JSONPath>$.sysRoles</JSONPath>
        </Variable>
    </JSONPayload>
    ...
</ExtractVariables>

GenerateJWT

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<GenerateJWT async="false" continueOnError="false" enabled="true" name="GenerateJWT">
    ...
    <AdditionalClaims>
        <Claim name="sysRoles" ref="sysRoles" wantFaultIfUnresolved="false"/>
    </AdditionalClaims>
    ...
</GenerateJWT>

The claim in my token is always a string: "sysRoles": "[\"something\",\"something-other\"]".

What I also tried and did not work out:

  1. using type and array on the extraction: <Variable name="sysRoles" type="string" array="true"> (puts the stringifyed list into an actual list)
  2. using type and array on the JWT generation: <Claim name="sysRoles" ref="sysRoles" wantFaultIfUnresolved="false" type="string" array="true"/> (also puts the stringifyed list into an actual list)
  3. using asterisk on the JSONPath: <JSONPath>$.sysRoles[*]</JSONPath> (no changes)

What is the correct way to do this without having some intermediate step doing some JS logic?

Edit actual problem is in the claim generation. The extracted variable is indeed a list of strings, but the claim always ends up with the stringifyed list.

tpschmidt
  • 2,479
  • 2
  • 17
  • 30

0 Answers0