keycloak

Mapping user groups to JWT in keycloak maps realm roles instead


I am trying to map groups assigned to a user to a claim in the JWT provided by keycloak when signing in. I create the mapping under client -> client scopes -> client-dedicated. I create a new mapper from the predefined mappers. In the list I select groups. enter image description here

It also says here that user realm roles are going to be mapped to the claim. In my understanding this is wrong but I am very new to KeyCloak. Subsequently the new claims in my token are the realm roles and not the groups my user is a member of. enter image description here

These seem to be realm roles and not my groups: enter image description here

I am using KeyCloak version 22.0.5. Maybe a bug, maybe my understanding of groups is wrong.


Solution

  • Figured it out, had to create a mapper by configuration, selected "Group membership".

    enter image description here