A Keycloak Mapper that adds a configurable prefix to attributes based on a user's groups.
Place the generated jar-file into the Keycloak deployments folder.
In the Keycloak Wildfly distribution it is located at /opt/jboss/keycloak/standalone/deployments, while in the Quarkus distribution it is located at /opt/keycloak/providers.
To activate the mapper, you must configure it for your clients.
As an example, we configure the mapper in the following to modify the family_name claim by default.
Note that this guide is for the new admin console.
-
Go to the Admin Console under
Client Scopes. -
The
family_nameclaim is set by default by theprofileClient Scope. ClickEditon theprofilescope. -
In the
profiledetails view, go to theMapperstab. You should find the existingfamily namemapper there. -
Click on
Add mapperandBy configurationto add the custom mapper. Find theOIDC Claims Modification Mapperin the list. -
Configure the mapper as follows. With that configuration, users that are part of the group
Externewill have the suffix(extern)appended to theirlastNameattribute inside thefamily_nameclaim.
Similar to the family_name claim, you may add and modify any other claim.
If you want to modify an existing claim in the token, make sure to get the Claim Name correct and Property Name so that the user's property is properly resolved.
At best, simply copy the configuration from the existing mapper you want to overwrite.
