keycloak-api-key-demo
keycloak-api-key-demo copied to clipboard
Display attribute to user within keycloak
If a user visits their account area, they're able to view details about their account:
<domain>/auth/realms/<realm>/account/
Is it possible to include the API attribute in here? If so, what steps should I take?
Ideally I'd like to use this instead of a separate service for displaying their API key upon a successful authentication
Hi @Jarvvski, apologies for the late reply. Yes, this is absolutely possible. You need to override the keycloak theme, and customize the account page. All you need to do is to add the name of your attribute with and map it to a html input like:
<input id="user.attributes.my-custom-attribute" name="user.attributes.my-custom-attribute" value="${(account.attributes.my-custom-attribute!'')}" />
where my-custom-attribute
is the name of your attribute.
I will try to add an example in the coming days. In the meanwhile, you can take a look at https://www.keycloak.org/docs/latest/server_development/#creating-a-theme https://www.keycloak.org/docs/latest/server_development/#_custom_user_attributes
example added. Here is the commit for more details: 9d816c5f605a9420d4cc07158ef01245bd09e04c
Thanks @zak905
I ended up figuring this out in the end, through a lot of trial and error.
Though it's great to keep it here as a reference to anyone else who comes across the same problem!