
FlorijnB.50107 (Customer) asked a question.
Hi,
I was wondering if it is possible to use the Groups claim expression (Sign on -> OpenId Connect ID Token -> use "Expression" as Groups claim type) to map the names of groups that the user is member of.
Example:
If a user is a member of group "A", the token should include claims "abc" and "xyz" in the groups claim, and if he is a member of group "B" as well, claim "def" should also be added to the groups claim.
What I tried:
I have tried this with using ternary expressions, but no claim value was passed through. Is it possible to use ternary expressions in the Groups claim expression?
So far I tried Groups.contains("appId", "B", 100) ? "abc" : "def", and other group functions described at Okta Expression Language overview guide | Okta Developer. I also tried combining this with Arrays methods as shown at https://support.okta.com/help/s/article/How-to-Write-a-Groups-Claim-Expression-that-Will-Match-Against-Two-Differently-Named-Groups?language=en_US. However, in all cases no claim value was passed through.

Thank you very much for your answer, @Mihai N. (Okta, Inc.)! This helped me to set up the mapping I wanted.
My final mapping is:
Arrays.flatten(
Arrays.isEmpty(Arrays.toCsvString(Groups.startsWith("appVariableName","B",100))) ? {} : {"def"},
Arrays.isEmpty(Arrays.toCsvString(Groups.startsWith("appVariableName","A",100))) ? {} : {"abc", "xyz"}
)