[keycloak-dev] Using Client's Attributes in Custom Policy

Erik Berdonces Bonelo e.berdoncesbonelo at campus.tu-berlin.de
Wed Oct 5 10:00:17 EDT 2016


Hello,

I’m trying to implement a custom policy but I’m having a hard time with the Evaluation API. 

As I see, there is just some few available settings to get, but, I’m trying to fetch specifically a custom attribute of the client, let’s say FOO, which can be set through adding them in the representation when registering a new Client, which we will call BAR,  through the Registration API. Is it even possible?

Otherwise, I’m not sure in which case would the client attributes be used.
In the settings of the client BAR, in policies, in the test tab, there is in the ‘Contextual Attributes' part, a ‘Custom Attribute’ option. Is there any possible to set them, or to use them? 

I’ve been trying to link them somehow to FOO attribute using a custom scripted policy in Javascript for the client BAR such as:


contextAttributes.containsValue(‘kc.client.attributes.FOO', ‘myFooAttributeValue')
But I’m not successful, plus it’s really difficult to debug so :(

Any advice on how to implement something like this? I’m just trying to create a policy, where one of the parameters is loaded from the client, and I want to save that property somewhere accessible such as a custom attribute, and not so hardcoded such as a javascript or Drool script.

Thanks a lot!

— 
Best regards, 

Erik Berdonces Bonelo


More information about the keycloak-dev mailing list