Reputation: 438
How to create a user attribute based policy?
var context = $evaluation.getContext();
var identity = context.getIdentity();
var attributes = identity.getAttributes();
if (identity.location=='mumbai') {
$evaluation.grant();
}
A User has an attribute location and value as mumbai.
Upvotes: 2
Views: 656
Reputation: 9633
You could to some thing like this, as attributes are list, you can check first element
var context = $evaluation.getContext();
var identity = context.getIdentity();
var attributes = identity.getAttributes();
if (attributes.location !== null && attributes.location[0] == "mumbai") {
$evaluation.grant();
}
Upvotes: 1