Execute Script Block

This block can be used to execute a java script within the context of constraint work flow.


Name

Specify the name for the block.


Description

Provide a description for this block.


Script Syntax

function(inputRequestContext, callback) {...}

The script template takes the following arguments:

  • inputRequestContext - Request Context data structure contains message and request information. More details on this data structure are included later.
  • callback - Callback should be called once the processing is complete in the script. Callback expects following argument:
    • outputRequestContext - request context map containing information as described below. If this is passed as null or empty then the original request Context passed to the function will be considered as the output.

Input Request Context Map

// inputRequestContext map
{
    "headers": {},
    "queryParams": {},
    "authzContext": {},
    "systemInfo": {},
    "messageContext": {},
    "obligations": {}
}

Headers

JSON map containing headers in following format:

{
    headerName1: headerValue1,
    headerName2: headerValue2
}

An example is as follows:

{
    "Accept-Language": "en-US,en;q=0.8",
    "Host": "52.25.176.12:8080",
    "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36",
    "Origin": "chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop",
    "Postman-Token": "5cc082fc-49cc-a1b1-f45b-0d95d740013c",
    "Accept": "*/*",
    "Cache-Control": "no-cache"
}

Query String Parameters

JSON map containing query string parameters in following format:

{
    paramName1: [paramValueA, paramValueB, ...],
    paramName2: [paramValueX, paramValueY, ...]
}

An example is as follows:

{
    "account_number": ["123456"],
    "account_type": ["checking"]
}

Authorization Context Parameters

Authorization Context is a JSON map that has been provided to allow additional context data that can be sent to Authority for request authorization. Just like header and query string parameters, it is a JSON map containing parameters in following format:

{
    stringParam: paramValue1,
    arrayParam: [paramValueX, paramValueY, ...],
    mapParam: {
        mapParamChildName : mapParamChildValue
    }    
}

An example is as follows:

{
    "user_role": "Admin",
    "user_groups": ["ec2-admins","ebs-admins"],
    "user_props": {
        "name": "John Doe",
        "Department": "Cyber Security",
        "Last Logged In": "01 Jan 2016 16:58:33GMT"
    }
}

System Information

System information map is a JSON map that has been provided to allow system related information that can be sent to Authority for request authorization. Just like header and query string parms, it is a JSON map containing parameters in following format:

{
    stringParam: paramValue1,
    arrayParam: [paramValueX, paramValueY, ...],
    mapParam: {
        mapParamChildName : mapParamChildValue
    }    
}

An example is as follows:

{
    "ipAddress": "192.168.1.1",
    "hostname": "rs.acmebank.com",
}

Message Context

Message Context is computed by AuthScope and following values are available in message context by default:

  • scope : Scope passed by Resource Server.
  • action: Action passed by Resource Server.
  • resource: Resource passed by Resource Server.
  • pathParams: Path Parameters computed by AuthScope.

Any variables created in a constraint chain via "Create Variable" block are also available in this object. Just like header and query string parameters, it is a JSON map containing parameters in following format:

{
    stringParam: paramValue1,
    arrayParam: [paramValueX, paramValueY, ...],
    mapParam: {
        mapParamChildName : mapParamChildValue
    }    
}

An example is as follows:

{
    "extarctedUserIdentity": "John Doe",
    "computedAPR": "8.65",
}

Obligations

Obligations map is used to hold obligations as speficied by previous blocks. Just like header and query string parms, it is a JSON map containing parameters in following format:

{
    stringParam: paramValue1,
    arrayParam: [paramValueX, paramValueY, ...],
    mapParam: {
        mapParamChildName : mapParamChildValue
    }    
}

An example is as follows:

{
    "timeBoundary": "9am-5pm PST",
    "errorCode": "OUTSIDE_TIME_BOUNDARY",
}

Example

{
    "headers": {
        "Accept-Language": "en-US,en;q=0.8",
        "Host": "52.25.176.12:8080",
        "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36",
        "Origin": "chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop",
        "Postman-Token": "5cc082fc-49cc-a1b1-f45b-0d95d740013c",
        "Accept": "*/*",
        "Cache-Control": "no-cache"
    },
    "queryParams": {
        "account_number": ["123456"],
        "account_type": ["checking"]
    },
    "authzContext": {},
    "systemInfo": {},
    "messageContext": {},
    "obligations": {}
}

Output Request Context Map

// outputRequestContext map
{
    "result": true/false
    "headers": {},
    "queryParams": {},
    "authzContext": {},
    "systemInfo": {},
    "messageContext": {},
    "obligations":{}
}

The output request context map is similar to input request context map but contains additional "result" Boolean variable. System will read this variable to consider the Script execution as succcess/failure. The other values in this map will be available in subsequent blocks.


results matching ""

    No results matching ""