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_name
claim is set by default by theprofile
Client Scope. ClickEdit
on theprofile
scope. -
In the
profile
details view, go to theMappers
tab. You should find the existingfamily name
mapper there. -
Click on
Add mapper
andBy configuration
to add the custom mapper. Find theOIDC Claims Modification Mapper
in the list. -
Configure the mapper as follows. With that configuration, users that are part of the group
Externe
will have the suffix(extern)
appended to theirlastName
attribute inside thefamily_name
claim.
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.