[keycloak-user] Resource attributes with API

Corentin Dupont corentin.dupont at gmail.com
Fri Jul 6 08:48:00 EDT 2018


Hello,
I'm trying to experiment with resource attributes...
However I don't find it in the doc (yet).
Creating attributes like this seems to work:

curl -X POST "
http://localhost:8080/auth/realms/waziup/authz/protection/resource_set" -H
"Authorization: Bearer $CLIENTTOKEN" -H "Content-Type: application/json" -d
'{"name":"Sensortest3", "attributes":{"isPrivate": ["true"]}}'

However, I'm not sure about the Javascript policy:

var context = $evaluation.getContext();
var permission = $evaluation.getPermission();
var identity = context.getIdentity();
if (permission.getResource().getAttributes().containsValue('isPrivate',
'false')) {
   $evaluation.grant();
}

Thanks!!


More information about the keycloak-user mailing list