Policy Conditions
Variables
Inside conditions you can access two variables, which are records to call attributes on:
object
, which translates to the object of the Resource type the user is trying to gain access to. The attributes that can be called on the object differ per Resource type. See the Resources page to find all of them.subject
, which is the current user trying to gain access. The attributes that can be called on the subject areid
,name
andemail
.
Attribute Value Types
The values attributes that can be called on the resources are always one of these types:
number
, an integer, like an id, or relation_id.string
, a textbool
, boolean, true or falsedatetime
, a date & time object. This can be passed as a string, but gets evaluated as a datetime, so the string must be able to parse to a Datetime. See also: Date Standard 8601 - SS64.com
Each resource page contains documentation of which attributes are applicable, with the correct type.
In order to force the correct evaluation of a value type inside the policy JSON, the root key inside the conditions
block is always the value type, like this:
...
"statement": {
...
"condition": {
"number": {
"==": {"object.site_id": 1234},
">": {"object.id": 9876}
}
"string": {
"==": {"subject.email": "test@email.com"}
}
}
...
}
Since the parsing is forced you are able to for example send strings inside the number
block. This will work, because the values get parsed according to which block they’re in.
Evaluation Operators
The way the policy gets evaluated is determined by the value types, and by which operator is used. The policy condition operators are:
==
, equals to. Applicable to all attribute value types.!=
, does not equal to. Applicable todatetime
,number
,string
>=
, greater than or equals to. Applicable todatetime
,number
>
, greater than. Applicable todatetime
,number
<=
, less than or equals to. Applicable todatetime
,number
<
, less than. Applicable todatetime
,number
like
, regular expression. Applicable tostring
like_ic
, case insensitive regular expression (ignore case flag). Applicable tostring
Inside the policy JSON, the operators are used as a key inside the value type block, and as a value it has a single key/value object with the attribute and the value to evaluate. See the example above.