How to set custom Attributes in keycloak JWT?

Viewed 1027

I am making a storage provider that federated user from my local database my question I need to set the attributes of my custom user in the returning JWT.

I need to carry the user from customStorageProvider to JWTMapper to map the attributes to JWT

1 Answers

You need to go to your realm:

  • then go to clients, and select the client that you will be authenticating against;
  • go to mappers;
  • click on create (right side) to create your own Mapper, or click on "Add Builtin" to use one of the Keycloak inbuilt Mappers.

These Mappers will map (among other things) user-related attributes into the token omitted by Keycloak.

Related