Proposol: Adding getAttributes/getAttribute method to RealmBean

338 views
Skip to first unread message

Björn Eickvonder

unread,
Feb 8, 2021, 7:29:29 PM2/8/21
to Keycloak Dev
Hi,
I'd like to propose a tiny change regarding RealmBean, namely to add getAttributes/getAttribute method as it is already available in ClientBean.

We already use the ClientBean attributes to make our login theme more flexible (e.g. customer logo url) without having to define new themes for each customer. But this obviously won't work for Account or Realm Admin Console because we don't have a client there, but we have a realm.
So I'd like to have your opinion if that is a tiny change that you would accept. If that is the case I will provide a PR.

Björn 


Björn Eickvonder

unread,
Oct 15, 2021, 4:12:39 AM10/15/21
to Keycloak Dev
I'm still stuck with this, can I open a PR to add access to attributes in the RealmBean?

Thomas Darimont

unread,
Oct 15, 2021, 5:20:05 AM10/15/21
to Björn Eickvonder, Keycloak Dev
Hi Björn,

Realm attributes are currently used to store Keycloak internal realm information, however there are tools like keycloak-config-cli that use the realm attributes to maintain state information about the realm.
If you store custom data in realm attributes, then you need to use some kind of namespacing or prefix for your custom attributes in order to avoid potential clashes with Keycloak internal data.

I think it would be useful to have direct access to realm attributes in templates via form beans if this would be officially supported.

In the meantime, you can create your own LoginFormsProvider that inherits from FreeMarkerLoginFormsProvider. In the "processTemplate" method, you can 
add your own beans to the "attributes" map that is passed to the template engine. With this you can effectively wrap / extend the RealmBean and add the attribute access logic there.

Here is an example for this:

Cheers,
Thomas

--
You received this message because you are subscribed to the Google Groups "Keycloak Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keycloak-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/keycloak-dev/8be6ac60-7a69-49cf-b211-43b4d1ad8e33n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages