Attribute functions
You can use the configuration API samples and syntax, to author custom functions.
Overview
Use functions to reference, transform, and combine attribute values before they are passed to an application in the form of a single sign-on authentication token or when provisioning accounts. Functions can access the identity source credential that is used to authenticate to IBM® Verify, the user object (in SCIM form) that is stored in Cloud Directory and any external API endpoint. For example, an attribute that is calledformalDisplayName can be created as a fixed value
attribute and a function can be specified that concatenates the user.name.givenName
and user.name.familyName in a specified manner.To configure advanced rule attributes, in the Admin console go to . Then map these attributes in the application configuration similar to mapping all other attribute types.
Accessing domain objects
The term, domain objects, is a catch-all phrase that is used to indicate all possible objects that can be accessed in an attribute's custom function.
- Cloud Directory user
-
For every user that authenticates to Verify a user account is created in Cloud Directory. This account is represented as a SCIM object. In the following examples, the following Cloud Directory user account is used.
The following SCIM object is the user account.{ "id": "600000A3DD", "userName": "google-oauth2|1033116550041553242@jke.samlfed.com", "emails": [ { "type": "work", "value": "jessica@jke.com" } ], "meta": { "created": "2019-04-26T09:21:35Z", "location": "https://jke.cloudidentity.com/v2.0/Users/600000A3DD", "lastModified": "2019-04-26T09:21:35Z", "resourceType": "User" }, "schemas": [ "urn:ietf:params:scim:schemas:core:2.0:User", "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User", "urn:ietf:params:scim:schemas:extension:ibm:2.0:User" ], "name": { "formatted": "Jessica Hill", "familyName": "Hill", "givenName": "Jessica" }, "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User": { "manager": { "value": "6030101TP6" } }, "urn:ietf:params:scim:schemas:extension:ibm:2.0:User": { "userCategory": "federated", "twoFactorAuthentication": false, "realm": "jke.samlfed.com", "unqualifiedUserName": "google-oauth2|1033116550041553242", "customAttributes": [ { "name": "car", "values": [ "Ford Mustang Mach-E", "Maruti Suzuki 800" ] }, { "name": "hobbies", "values": [ "Reading", "Running", "Gaming", "Star Wars" ] } ] }, "active": true }Note: In the SCIM object, two custom attributes are defined -carandhobbies. These attributes are schema extensions that can be configured through the Admin Console. Values can be added to the user object through the Verify Users API.Syntax Description Examples user.$propertyAccess $property. Both .and[".."]can be used.user.name.familyName + ", " + user.name["givenName"]Result:
Hill, Jessicauser.$values.filter(x, $condition)$values: A list. filterfunction extracts values based on$condition.user.emails.filter(x, x.type == "work")[0].valueResult:
jessica@jke.comuser.getCustomValues($attrName)Function to get custom attribute values as a list. $attrName: The name of the attribute in the user object returns null if the attribute does not exist.user.getCustomValues("car")Result:
["Ford Mustang Mach-E","Maruti Suzuki 800"]user.getCustomValue($attrName)Function to get the first custom attribute value in the list. $attrName: The name of the attribute in the user object Returns empty string ("") if the attribute does not exist.user.getCustomValue("hobbies")Result:
Readinguser.getManager()Function to get the manager information of the current user. The function returns the manager's user account (as a SCIM object). If no manager is specified for the user, it returns an empty JSON object. If a manager object is returned, it can be used like the user object, that is, the various functions can be called on this object. user.getManager().name.formattedResult:
Jacob Jonesuser.getRoles()Function to get the entitlements of the current user. The function returns the list of user's entitlements as a JSON object. If the list of entitlements is returned, it can be used as a JSON object. user.getRoles().resources[0].nameResult:
Basic accessuser.getFIDO2Registrations($search)Function to get the FIDO2 registrations of the current user. The function returns the list of FIDO2 registrations that belong to the user. Search parameters $searchcan optionally be provided. The supported search parameters can be found here: https://docs.verify.ibm.com/verify/reference/getfidoregistrations_v20user.getFIDO2Registrations("enabled=true").fido2[0].enabledResult:
trueuser.getFIDO2RegistrationByID($id)Function to get the FIDO2 registration of the current user with the ID $id.user.getFIDO2RegistrationByID("e8bf1dac-8245-452b-b7c4-8a700a1eb078").fido2[0].idResult:
e8bf1dac-8245-452b-b7c4-8a700a1eb078user.getDynamicGroups()Function to get the dynamic groups of the current user. The function returns the list of user's dynamic groups as a JSON object. user.getDynamicGroups().resources[0].nameResult:
Security department manager - User Management Functions
-
The following functions are made available in CELx if there is a need to perform Read, Create, and Update operations against users in Cloud Directory.
The response of these functions is a map object as defined below. This allows flexibility to perform error handling in the CELx function. An empty string forerrormeans that the operation was successful.{ "result": <result of the operation>, "error": <error message, in case of failures> }Syntax Description Examples findUsers($filter)The function returns a list of users that match the given filter. $filter: String that defines the match criteria in the format as defined in GET Users API. A maximum limit of 10 users is enforced for the search response.An empty list is returned if no user was matched.
findUsers('emails ew "@jke.com"')findUsers($filter, $attributes)The function returns a list of users that match the given filter. Each matched user returns the attributes that are specified in the $attributesargument.$filter: The string that defines the match criteria.$attributes: The string array of scimNames that should be returned in the result.Refer to the format of query parameters defined in GET Users API. A maximum limit of 10 users is enforced for the search response.
An empty list is returned if no user was matched.
findUsers('emails ew "@jke.com"', ["emails", "name.givenName"])findUsers($filter, $attributes, $count)The function returns a list of users that match the given filter with a max limit of $count. Each matched user returns only the attributes that are specified in the $attributesargument.$filter: The string that defines the match criteria.$attributes: A string array of scimNames that should be returned in the result.$count: Integer to specify the max number of users to be returned, with a maximum of 10. Any value above 10 is ignored and set to 10. Refer to the format of query parameters defined in GET Users API.An empty list is returned if no user was matched.
findUsers('emails ew "@jke.com"', ["emails", "name.givenName"], 3)findUser($filter)The function returns a single user that matches the given filter. $filter: The string that defines the match criteria in the format as defined in GET Users API.An error is returned if either multiple users were matched, or no user was matched.
findUser('emails eq "jessica@jke.com"')findUser($filter, $attributes)The function returns a single user that matches the given filter. The user only returns the attributes that are specified in the $attributesargument.$filter: String that defines the match criteria.$attributes: String array of scimNames that should be returned in the result. Refer to the format of query parameters defined in GET Users API.An error is returned if either multiple users were matched, or no user was matched.
findUser('emails eq "jessica@jke.com"', ["emails", "name.givenName"])getUser($uid)The function returns the user who is associated with the given $uid. An error is returned if the user does not exist.getUser("504K8664N6")createUser($m)The function creates a user with the given attribute values. $m: A map of attribute ID/name and the wanted value for the user.The attribute IDs can be found in the response of GET Attributes API. The ID and the name of the attribute can be used interchangeably.
The
emailandusernameattribute values are required. The rest of the values are optional.To specify the new user's password, include a property in $m with name
passwordand the plaintext password as the value.On success, the created user SCIM object is returned in
result.createUser({'3':'jessica@jke.com', 'userName':'Jessica', '3f31edcf-19e8-46a4-b87e-e50c25dc1358':'Manager', 'hobbies':['Reading', 'Swimming'], '6': 'Jessica', '7': 'Doe'})createUser($m, $opts)The function creates a user with the given attribute values and additional options. $m: A map of attribute ID/name and the wanted value for the user.$opts: A map of additional options that can be specified when creating a user.The attribute IDs can be found in the response of GET Attributes API. The ID and the name of the attribute can be used interchangeably.
The
emailandusernameattribute values are required. The rest of the values are optional. To specify the new user's password, include a property in$mwith namepasswordand the plaintext password as value.The following properties are currently allowed in $opts:
- notifyType: The property specifies the type of notification to send to the user. Default
is
EMAIL. - notifyPassword: Boolean to indicate whether the user's password is included in the
notification that is sent to the user. Default is
true. This attribute does not apply ifnotifyTypeis set toNONE. - notifyManager: Boolean to indicate whether the notification should be sent to the user's
manager (if one is set) when a user's password is set or modified. Default value is
false. This attribute does not apply ifnotifyTypeis set toNONE. - acceptInitialPassword: If set to true, the user is not required to change the password upon first login.
On success, the created user SCIM object is returned in
result.createUser({'3':'jessica@jke.com', 'userName':'Jessica', '3f31edcf-19e8-46a4-b87e-e50c25dc1358':'Manager', 'hobbies':['Reading', 'Swimming'], '6': 'Jessica', '7': 'Doe'}, {'notifyType':'NONE', 'acceptInitialPassword': 'true'})updateUser($uid, $m)The function updates the given user with the specified attribute values.
$uid: The ID of the user to be updated.$m: A map of attribute ID/name and the wanted value for the user.The attribute IDs can be found in the response of GET Attributes API. The ID and the name of the attribute can be used interchangeably.
A successful update returns
successstring as result. The user object is not returned.updateUser('6050007SGF', {'3':'jessica@redbank.com', '3f31edcf-19e8-46a4-b87e-e50c25dc1358':'President', 'mobile_number': '502513585', 'work_country': 'Singapore'}) - notifyType: The property specifies the type of notification to send to the user. Default
is
- Identity source credential
- When a user logs in to Verify, the identity source
credential attributes are added into the login session and can be accessed in a custom function.
Consider that the user logs in with a SAML federated identity provider and the SAML assertion
contains an attribute statement that is called
userRolesand it is set tomarketingandhelpdesk.Theidsuserattribute is available as a map with a string key and a string array value. For example,{ "userRoles": ["marketing", "helpdesk"], "displayName": ["Jessica J. Hill"], "phone": ["+12324321234"], "employeeId": "eid1234" }Syntax Description Examples idsuser.$propertyAccess $property. The value inidsuseris always an array of strings.idsuser.userRoles[1]Result:
helpdeskidsuser.getValue($property)Returns the value of $propertyas a string. If the value array has multiple entries, the first item is returned. If the$propertydoes not exist, an empty string is returned.idsuser.getValue('userRoles')Result:
"Marketing"idsuser.getValues($property)Returns all the values of $propertyas a string array. If the$propertydoes not exist, anilobject is returned.idsuser.getValues('userRoles')Result:
["Marketing", "helpdesk]" - HTTP request context
-
When a user logs in to IBM Verify, the incoming HTTP request context can be accessed in a custom function. If the user logs in with an OAuth flow and the client sends
client-ipanduser-agentinformation,requestContextcan extract the information. It can be used to call out to an external endpoint to determine the risk score for the user.requestContextis available as a map with a string key and a string array value. For example,{ "User-Agent": ["Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405"], "devicePlatform": ["MACOS"], "x-forwarded-for": ["116.15.12.181"] }Table 1. HTTP request context Syntax Description Example requestContext.$propertyAccess $property. The value inrequestContextis always an array of strings.requestContext.devicePlatform[1]Result:
MACOSrequestContext.getValue($property)Returns the value of $propertyas a string. If the value array has multiple entries, the first item is returned. If the$propertydoes not exist, an empty string is returned.requestContext.getValue('x-forwarded-for')Result:
116.15.12.181requestContext.getValues($property)Returns all the values of $propertyas a string array. If the$propertydoes not exist, a nil object is returned.requestContext.getValues('x-forwarded-for')Result:
["116.15.12.181"] - Attribute context
- The context object holds key-value pairs of certain properties of the attribute that can be used
when writing functions. The values of these properties are valid only in the context of that
attribute's lookup. This object can be accessed with the
ctxkey.The following properties are available with the context object:Syntax Description Examples ctx.currentValueAccess the attribute value evaluated before running this function. The data type of this value is specified in the attribute configuration. If the value cannot be casted to the data type, this value is set to null. ctx.currentValue.toUpper
Standard operators
+, -, *,
/, >, <. The + can be used
to concatenate strings.
| Operator | Description | Examples |
|---|---|---|
== |
Equals comparison |
|
!= |
Not equals comparison |
|
|| |
Logical OR comparison |
|
&& |
Logical AND comparison |
|
[ ] |
Map access |
|
+ |
Concatenation and addition, depending on the type |
|
- |
Subtraction |
|
* |
Multiplication |
|
/ |
Division |
|
> |
Greater than condition |
|
< |
Less than condition |
|
>= |
Greater than or equal to |
|
<= |
Less than or equal to |
|
? |
Ternary if operator |
|
Standard functions
| Syntax | Description | Examples |
|---|---|---|
$string.contains($fragment) |
Checks if $fragment is found in the $string. |
Result: true |
$string.endsWith($fragment) |
Checks if $string ends with $fragment. |
Result: false |
$string.matches($regex) |
Checks if the $regex matches the pattern in
$string. |
Result: false |
$string.toUpper() |
Converts $string to uppercase. |
Result: HELLO |
$string.toLower() |
Converts $string to lowercase. |
Result: hello |
$string.base64Encode() |
Base64 encodes $string. |
Result: aGVsbG8= |
$string.base64Decode() |
Base64 decodes $string. |
Result: hello |
$string.base64URLEncode() |
Base64URL encodes $string. |
Result:
|
$string.base64URLDecode() |
Base64URL decodes $string. |
Result:
|
$string.size() |
Size of the $string |
Result: 5 |
$string.substring($begin,$end) |
Returns the string between the $begin index (including) and $end
index (excluding). |
Result: ell |
$string.split($delim) |
Returns the array of strings that are split by the $delim. |
Result: ["h","llo"] |
$string.replaceAll($old,$new) |
Replaces all occurrences of $old with $new. |
Result: heppo
|
$string.matchAndReplaceAll($regex, $newStr) |
Replaces all matches of $regex with $newStr. |
Result: some-text
|
$string.indexOf($str) |
Returns the index of the first occurrence of $str. |
Result: 2 |
$string.lastIndexOf($str) |
Returns the index of the last occurrence of $str. |
Result: 3 |
| Syntax | Description | Examples |
|---|---|---|
$values.size() |
Size of the list $values |
Result:
|
$values.filter(x, $condition) |
Filters $values by $condition. |
Result:
|
$values.all(x, $condition) |
Checks if all $values satisfy $condition. |
Result:
|
$values.exists(x, $condition) |
Checks if any value satisfies $condition. |
Result:
|
$values.exists_one(x, $condition) |
Checks if exactly one value satisfies $condition. |
Result:
|
$values.map(x, $op) |
Runs $op on each value. |
Result:
|
stringToJson($s) |
Converts the string $s into a JSON array. |
Result:
|
jsonToString($json) |
Convert the list $json into a string. |
Result:
|
joinStrings($values, $s) |
Joins the strings in the list $values with the separator $s. |
Result:
|
$values.flatten() |
Converts a list of lists $values into a single list. |
Result:
|
{
idsuser: {
"attr1":"value1",
"attr2":"value2"
}
} then for function idsuser.exists(x, $condition), x is [
"attr1", "attr2" ]. | Syntax | Description | Examples |
|---|---|---|
sha256($value) |
Computes the sha256 hash value for the specified string. |
Result:
|
sha512($value) |
Computes the sha512 hash value for the specified string. |
Result:
|
hmacSha1($value, $key) |
Computes the HMAC-SHA1 value with the key $key for the given string. |
Result: |
| Syntax | Description | Examples |
|---|---|---|
base64ToHex($value) |
Converts the base64-encoded string $value to a hexadecimal value. |
Result:
|
hexToBase64($value) |
Converts the hexadecimal value $value to a base64-encoded string. |
Result:
|
base64URLEncodedToHex($value) |
Converts the base64URL-encoded string $value to a hexadecimal value. |
Result:
|
hexToBase64URLEncoded($value) |
Converts the hexadecimal value $value to a base64URL-encoded string. |
Result:
|
| Syntax | Description | Examples |
|---|---|---|
has($m.$p) |
Check if the map $m contains the property $p. |
Result:
|
has($m, $p) |
Checks whether the map $m contains the property $p. This is
convenient for property names with special characters (for example, dots). |
Result:
|
jsonToString($m) |
Convert the map $m into a string |
Result:
|
stringToJson($s) |
Converts the string $s into a map. |
Result:
|
jsonToFormURLEncoded($m, $doUrlEncode) |
Converts the map $m into a form. If $doUrlEncode is set to
true, the form is URL-encoded. |
Result:
|
$m.put($k, $v) |
Inserts the key $k of type string with value $v of type
object into the map $m. If the map $m previously contained a value for the key
$k, the old value is replaced with the new value $v. |
Result: "{"hello": "world", "key1":
"value1"} |
$m.putAll($v) |
Inserts the contents of the map $v into the map $m. If the
map $m previously contained a value for a key present in the map
$v, the old value in the map $m is replaced with the value in the
map $v. |
Result: "{"hello": "world", "key1": "value1", "test":
true} |
$m.remove($k) |
Removes the mapping for the key $k of type string from the map
$m if present. |
Result: {"hello":
"world"} |
$m.removeAll($l) |
Removes all mappings for the list of keys $l from the map
$m if present. |
Result: {"hello":
"world"} |
exists List function.
idsuser.exists(x, x == "ext:idsource_attr1") It returns true
if the property exists and false otherwise.| Syntax | Description | Examples |
|---|---|---|
now |
Returns a timestamp object of the current time. | Result: "2021-08-17T08:24:58Z" |
timestamp($s) |
Returns a timestamp object by converting the input string $s according to RFC3339. |
Result:
|
$t.getDate() |
Returns the day of the month from the timestamp $t as an integer, one-based
indexing. |
Result: 17 |
$t.getDayOfMonth() |
Returns the day of the month from the timestamp $t as an integer, zero-based
indexing. |
Result: 16 |
$t.getDayOfWeek() |
Returns the day of the week from the timestamp $t as an integer, zero-based,
zero for Sunday. |
Result: 2 |
$t.getDayOfYear() |
Returns the day of the year from the timestamp $t as an integer, zero-based
indexing. |
Result: 228 |
$t.getMonth() |
Returns the month from the timestamp $t as an integer, zero-based
indexing. |
Result: 7 |
$t.getFullYear() |
Returns the year from the timestamp $t as an integer. |
Result: 2021 |
$t.getHours() |
Returns the hours from the timestamp $t as an integer. |
Result: 8 |
$t.getMinutes() |
Returns the minutes from the timestamp $t as an integer. |
Result: 24 |
$t.getSeconds() |
Returns the seconds from the timestamp $t as an integer. |
Result: 58 |
$t.getMilliseconds() |
Returns the milliseconds from the timestamp $t as an integer. |
Result: 642 |
int($t) |
Converts the timestamp to int64 in seconds since UNIX epoch. |
Result: 1629188698 |
duration($d) |
The duration $d must be given as a string ending with "s", which denotes the
duration in seconds. |
Result: "2021-08-17T09:24:58Z" |
formatTime($t, $s) |
Returns the timestamp $t in the format $s. The
$s must use the reference time "Monday, 02-January-06 15:04:05 MST" in the format
that is wanted. |
Result:
|
| Syntax | Description | Examples |
|---|---|---|
encodeURI($uri) |
Returns a string representing the provided string $uri encoded as a URI. This method escapes
all characters except: A-Z a-z 0-9 ; , / ? : @ & = + $ - _ . ! ~ * ' ( )
#. |
Result: "test.html?name=J%C3%BCrgen&car=audi" |
decodeURI($uri) |
Returns a string representing the decoded version of the encoded URI
$uri. |
Result: "test.html%3Fname%3DJ%C3%BCrgen%26car%3Daudi" |
encodeURIComponent($uri) |
Returns a string representing the provided string $uri encoded as a URI component. This
method escapes all characters except: A-Z a-z 0-9 - _ . ! ~ * ' ( ). |
Result: "test.html%3Fname%3DJ%C3%BCrgen%26car%3Daudi" |
decodeURIComponent($uri) |
Returns a string representing the decoded version of the encoded URI component
$uri. |
Result: "test.html?name=Jürgen&car=audi" |
UUID Functions
| Syntax | Description | Examples |
|---|---|---|
genUUID() |
Generates a UUID based on RFC 4122 and DCE 1.1: Authentication and Security Services. | Result: 4eb1a3f3-5461-4b91-8d69-69e25f2a1b6a |
Type and Conversion Functions
| Syntax | Description | Examples |
|---|---|---|
type($value) |
Returns the type of $value. |
Result: Result: "string" |
bool($string) |
Converts the string $string into a boolean. The accepted values for
true are "true", "True", and
"TRUE".The accepted values for |
Result: true
Result: false |
bytes($string) |
Converts the string $string to bytes. |
Result: "aGVsbG8=" |
double($value) |
Converts the value $value into a double. The $value can be
one of the following types: int, uint, or string. |
Result: 2.5
Result:
|
int($value) |
Converts the value $value into an int. The $value can be
one of the following types: double, uint, string, enum, or timestamp. If a timestamp is provided,
the value returned is the second due to Unix Epoch. |
Result:
Result:
Result: 123
Result: 1742801032 |
uint($value) |
Converts the value $value into an unsigned int. The $value
can be one of the following types: double, int, or string. |
Result: 3
Result: 123 |
string($value) |
Converts the value $value into a string. The $value can be
one of the following types: bool, int, uint, double, bytes, timestamp, or duration. If a duration is
provided, the value is converted to seconds and fractional seconds with an "s" suffix. If a
timestamp is provided, the value is covered to the RFC3339 format. |
Result:
Result: "1234"Result: "hello"Result: "60.1s"
Result: "2025-03-24T07:42:51Z" |
HTTP client
- The Authorization header token must be generated by the consumer. For example, it can be a long-lived API key that is baked into the function.
| Syntax | Description | Examples |
|---|---|---|
hc.GetAsString($url, $headers) |
Returns the response as a serialized string. $url: URL of the API endpoint
must be a full URL $headers: JSON object in the form
{"headerName":"headerVal"}. |
Result:
|
hc.GetAsJson($url, $headers) |
Parses the response as a JSON object. $url: URL of the API endpoint must be
a full URL $headers: JSON object in the form
{"headerName":"headerVal"}. |
Result:
|
hc.Post($url, $headers, $body) |
Returns the status code, response headers and response body, The response body is returned as
a JSON object if the content type is application/json or as a string for any other
content type.
|
Result:
|
hc.Patch($url, $headers, $body) |
Returns the status code, response headers and response body, The response body gets returned
as a JSON object if the content type is application/json or as a string for any other content type.
|
Result:
|
hc.Put($url, $headers, $body) |
Returns the status code, response headers and response body, The response body will be
returned as a JSON object if the content type is application/json or as a string for any other
content type.
|
Result: {"statusCode": "200", "responseHeaders": {"header": ["value1", "value2"]},
"responseBody": {"message": "success"}} |
hc.Delete($url, $headers) |
Returns the status code, response headers, and response body. The response body will be
returned as a JSON object if the content type is an application/JSON or a string for any other
content type.
{"headerName":"headerVal"} |
Result:
|
hc.Opts($options) |
$options:
Eight flags are currently supported:
hc instance, so GetAsJSON and
GetAsString can be called. |
|
$protocol://$host[:$port].- The
$protocolmust be either 'http' or 'https'. - The
$hostmust be a fully qualified domain name(FQDN). IP addresses are not allowed. - The port number
$portis optional. The following ports are supported by the HTTP client. The use of any other ports results in a timeout.- Ports 80, 443, and 8088
- Port range 7000-7050
- Port range 8000-8050
HTTP response
caching is enabled by default for GET calls (GetAsString and
GetAsJSON) with a default cache expiry of 1 minute. It is disabled by default for
POST calls. To override the default settings for HTTP client response caching, the flag
cache must be included in the hc.Opts with the value of either
true or false. The cache lifetime is set to 60 seconds by default.
To override the default cache lifetime, the flag cacheExpiry must be included in
the hc.Opts with the value in seconds, up to a maximum of 3600 seconds (one
hour).
Adaptive risk
Use Adaptive access risk functions to access the current user session risk level and associated authorization data.
An Adaptive access policy must be evaluated at least once in the session before using the custom
attribute to ensure that the data is populated, otherwise the value “NOT_AVAILABLE”
is returned.
The Adaptive access risk functions provide access to the corresponding Access policy conditions displayed in the Policy Editor as described in Managing Adaptive Access policy rules.
Details of the Risk indicators are described in Risk indications.
The key indicators of the risk data is structured as JSON and can be seen in the following
example. This JSON structure can be accessed by using the
risk.getAdaptiveSessionData() function.
The full adaptive risk data response that is related to the user session can be accessed by using
the risk.getRawAdaptiveSessionData() function.
{
"riskLevel": "LOW",
"isNewDevice": false,
"isRiskyDevice": false,
"isRiskyConnection": false,
"remoteIP": "122.143.222.333",
"country": "ISR",
"city": "Jerusalem",
"isp": "013 Netvision",
"isNewLocation": false,
"behavioralAnomaly": false,
"userBehavioralScore":"100"
}
| Syntax | Description | Examples |
|---|---|---|
risk.getAdaptiveSessionLevel() |
The function returns the user session's adaptive risk level. |
Result:
|
risk.getAdaptiveSessionData() |
Returns a JSON array of the Adaptive risk data that is related to the user session. Properties that have the prefix is return a Boolean value. All others return string. |
Result: "behavioralAnomaly":false, "city":"Bundall", "country":"AUS", "isNewDevice":false, "isNewLocation":false, "isRiskyConnection":false, "isRiskyDevice":false, "isp":"Network Technology (AUST) P/L", "remoteIP":"120.29.43.158", "riskLevel":"LOW", "userBehavioralScore":"100" |
risk.getAdaptiveSessionData().($p) |
The function returns the individual property $p from the
risk.getAdaptiveSessionData(). |
Result: true
Result:
|
string.For example:
To return a string
value of the risk_score for evaluation in an access policy, it must first be cast
to a
string.
string(risk.getRawAdaptiveSessionData()[1].message.pinpoint_assessment.risk.risk_score)
To perform a mathematical or logic operation or evaluation in an Advanced rule, a JSON number must
first be cast to an
int
int(risk.getRawAdaptiveSessionData()[1].message.pinpoint_assessment.risk.risk_score) > 900
or evaluated as a double
risk.getRawAdaptiveSessionData()[1].message.pinpoint_assessment.risk.risk_score > 900.0Application
For certain use cases (provisioning and reconciliation), the app object is
available for use in the CELx rules. This object represents the application JSON that is being used
for account sync.
app object can be treated as a map on its own in the rule, and also has the
following helper methods.
| Syntax | Description | Examples |
|---|---|---|
app.getSupportingData() |
Returns the supporting data of the application. |
Result:
|
OAuth
| Syntax | Description | Examples |
|---|---|---|
oauth.GetBearerToken($url, $clientId, $clientSecret) |
The function makes a call to the specified token endpoint $url using the
client_credentials grant type, providing the clientId $clientId, and clientSecret
$clientSecret and returns the access token if successful. |
Result:
|
JWT Functions
| Syntax | Description | Examples |
|---|---|---|
jwt.sign($payload, $headers) |
The function generates a signed JSON web token (JWT). The function takes in two parameters:
Note: Default behavior:
|
Result:
|
Debug Functions
Debug functions can be used to evaluate an expression and generate a trace log at the same time. The trace log will be generated if a rule is executed with enabled trace mode. For more information on enabling trace mode and viewing trace logs, see trace Settings in Creating a flow and Managing Trace view.
| Syntax | Description | Examples |
|---|---|---|
debug($expr, $logString) |
Evaluates the expression $expr and generates the debug log
$logString.The function takes in two parameters:
|
Result: jke.comThe
following trace log will also be generated: " |
debug($expr, $logString, $metadata) |
Evaluates the expression $expr and generates the debug log
$logString with the additional custom metadata.The function takes in three parameters:
|
Result: jke.comThe following trace log will also be generated: "
The email
domain is jke.com" with the following metadata fields:
|
Cache Functions
Cache functions can be used to utilize the cache in Rule service. There are two types of cache
functions: session and non-session based. The session based cache functions use
session, while the non-session based cache function use cache.
Values stored in the cache using the session based cache functions are tied to a user session.
The overall cache (session and non-session) has a maximum size limit. This limit may vary based on the tenant's configuration. Once the cache is full, any requests to add an entry to the cache will result in an error condition.
{
"isSuccessful": true/false, //indicates if the operation was successful or not
"value": "<string>", // the value obtained from the operation
"errorID": "<string>", // the error ID if any
"errorMessage": "<string>", // the error message if any
}| Syntax | Description | Examples |
|---|---|---|
session.Set($key, $value $ttlSec) |
Stores a value tied to the user session in the cache. This function takes in three parameters:
|
Result:
{"result":{"isSuccessful":true}} |
session.Get($key) |
Gets the value tied to the user session with the $key in the cache. |
Result:
{"result":{"isSuccessful":true, "value": "user1@web.com"}} |
session.Delete($key) |
Removes the value tied to the user session with the $key from the
cache. |
Result:
{"result":{"isSuccessful":true}} |
session.Exists($key) |
Checks if the $key tied to a user session exists in the cache. |
Result:
{"result":{"isSuccessful":true, "value":"true"}} |
session.GetAndDelete($key) |
Gets the value tied to the user session with the $key in the cache and
removes it from the cache. |
Result:
{"result":{"isSuccessful":true, "value": "user1@web.com"}} |
| Syntax | Description | Examples |
|---|---|---|
cache.Set($key, $value $ttlSec) |
Stores a value in the cache. This function takes in 3 parameters:
|
Result: {"result":{"isSuccessful":true}} |
cache.Get($key) |
Gets the value with the $key in the cache. |
Result:
{"result":{"isSuccessful":true, "value": "DunderMifflin"}} |
cache.Delete($key) |
Removes the value with the $key from the cache. |
Result:
{"result":{"isSuccessful":true}} |
cache.Exists($key) |
Checks if the $key exists in the cache. |
Result:
{"result":{"isSuccessful":true, "value":"true"}} |
cache.GetAndDelete($key) |
Gets the value with the $key in the cache and removes it from the
cache. |
Result:
{"result":{"isSuccessful":true, "value": "DunderMifflin"}} |
| Error | Result |
|---|---|
| The length of the key exceeds the limit |
|
| The length of the value exceeds the limit |
|
| The key is not found when getting the key from the cache |
|
| When the cache limit is exceeded |
|