I'm trying to map a realm-role attribute to a jwt token in keycloak using a client mapper. The idea is to assign certain default attributes to roles and the users that belong to the roles should inherit the attributes as well.
For instance, I have a realm-role called web-master
and set a role attribute called role-name
to 'Web master'
. I would like to see in my jwt token something like this {... role_name: 'Web master' ...}
.
I tried to use a token mapper and set the User Attribute field to role-name
and the Token Claim Name to role_name
but it did not worked.
I also tried with roleMappings['web-master'].attributes['role-name']
as User Attribute since the name maps to the UserModel but also didn't work.
I'm running out of options, is it a Script mapper the only possibility or there is an easier one?