Boolean user attributes

In one of my clients, I want a token mapper which maps a user attribute admin to a token claim is-admin that is boolean.

Well, the problem is, whatever I put in user-attribute and however I configure the mapper, the value for the key token-claim in the token is never correct.

  • If in the token mapper I specify the claim JSON type to be “boolean”, then whatever I put in the user attribute admin gets converted to the false boolean, probably because the conversion relies on converting a string. I tried putting 1 and true into the attribute, nothing worked.
  • If in the token mapper I specifty the claim JSON type to be “JSON”, then it converts true into the integer 1, for some reason, which is also not what I want.

How do I solve this?

Don’t know what exactly you are doing wrong, it works as expected:

User attribute:
Bildschirmfoto 2024-04-08 um 08.33.10

Token Mapper:

Results in token:

{
  ...
  "isAdmin": true,
  ...
}

thank you for your quick reply and for trying it out!

well, i swear to nonexistent god, i did exactly what you did, and it didn’t work. and now i tried it, and it works. i tried for multiple hours yesterday. i have no idea what the issue was.

possibly my browser did weird stuff and didn’t put the exact letters true in the attribute field, i don’t know…