Skip to main content

Conditional authentication - API reference

Cloud has the newest features. Some may not be in a release yet; the newest release is Identity & Access Management 7.3.0.

WSO2 Identity Platform provides a set of defined functions and objects to write your conditional authentication script. They are grouped as follows:

  • Core functions: These are the basic functions used in the script. These are used to identify the user who initiated the login flow, execute a step in the login flow, handle login failures, etc. Listed below are the core functions that can be used in conditional authentication scripts.


Core functions​

These are the basic functions that are required for defining the application login flow using an authentication script.

Initial login request​

onLoginRequest()

This function is called when WSO2 Identity Platform receives the initial login request. It includes the parameters given below.

  • Parameters

    contextThe authentication context, which contains the context information about the request.
  • Example

    onLoginRequest = function(context)

Execute a step​

executeStep()

This function is called to execute an authentication step in the login flow. You need to define your application's login flow before using this function.

This method accepts an object as a parameter and should include the details listed below.

<stepId>(Mandatory) The step number in the login flow.
<options>(Optional) A map that can configure step execution. Authentication option filtering is supported.
For more information, see the example on filtering connections in a step given below.
<eventCallbacks>(optional) The object that contains the callback functions, which are to be called based on the result of the step execution.
Supported results are onSuccess and onFail which can have their own optional callbacks as anonymous functions. For these callbacks, the [context](#context) and [data](#data) parameters are passed.
If the flow reaches the eventCallback stage and additional steps need to be executed, those steps should be included within the callback itself.

The following sample template shows how the above categorization can be used in a script.

executeStep(<stepId>,
{
<options>:[
//The objects of the option
]
},
{
<eventCallback>: function()> {
//eventCallback can be `onSuccess` or `onFail`
//Define what should be done
}
});

Parameters​

This section describes the options you can use to configure the executeStep() function, and the values you can use as local authenticators and federated IdPs in the function.

  • Options

    You can use these options when executing an authentication step through the script. See the examples given below for details.

    authenticationOptionsList the authentication methods that will be prompted for this step.
    authenticationOptions.authenticatorThe name of the local authenticator used.
    authenticationOptions.idpThe name of the federated identity provider used.
    authenticatorParamsPass the configuration for the step authenticators or identity providers.
    authenticatorParams.commonSpecify the common configurations for both local authenticators and federated identity providers.
    authenticatorParams.local.{authenticator-name}The name of the local authenticator used in the application. The configurations passed here will be available for that specific authenticator.
    authenticatorParams.local.{federated-identity-provider}The name of the federated identity provider used in the application. The configurations passed here will be available for that federated identity provider.
    note

    authenticatorParams configure the authenticators that WSO2 Identity Platform provides. They are not sent to the external service of a custom authenticator. To pass values to such a service, list the request parameters you want to forward in Allowed parameters of the custom authenticator configuration.

  • Connections: Local authenticators and federated IdPs

    When you want to access your configured connections in an authentication step, you can use the following values through the options explained above.

    See the example on filtering connections in a step given below for details.

    The local authenticators are represented by the authenticator parameter. The table shows the connection names (as displayed on the WSO2 Identity Platform Console) and the corresponding authenticator name you can use in the scripts.

    Connection NameAuthenticator
    Email OTPemail-otp-authenticator
    Identifier FirstIdentifierExecutor
    Magic LinkMagicLinkAuthenticator
    Security Key/BiometricsFIDOAuthenticator
    SMS OTPsms-otp-authenticator
    TOTPtotp
    Username & PasswordBasicAuthenticator

    The external identity providers are represented by the idp parameter. The federated connection names are generated based on the name you assign to the connection at registration.

    Example

    If you add a federated google connection with the name bifrost google, the value you can use in your authentication scripts is bifrost_google.

Examples​

Shown below are ways to define a login flow using the core functions.

  • Example 1: Use stepId

    This example uses only the stepId.

    executeStep(1)
  • Example 2: Use stepId and eventCallbacks

    This example uses only the stepId and eventCallbacks.

    executeStep(1, {
    onSuccess: function(context) {
    //Do something on success
    }
    });
  • Example 3: Use all parameters

    This example uses the stepId, options, and an empty eventCallbacks object. Different properties can be defined by the options object, such as authenticationOptions and authenticatorParams. However, you cannot write a script with only the stepId and options. See the following two examples:

    executeStep(1, {
    authenticationOptions:[{
    authenticator: 'totp'
    }]}, {}
    );
    executeStep(1, {
    authenticatorParams: {
    local: {
    email-otp-authenticator: {
    enableRetryFromAuthenticator: 'true'
    }
    }
    }, {}
    );
  • Example 4: Filter connections in a step

    The authenticationOptions array filters out connections (local authenticators and federated identity providers) of a step based on a condition.

    This can be achieved by specifying an array named authenticationOptions to the options map. You can have idp as an array item for federated connections and authenticator as an array item for local connections, as shown below.

    executeStep(1,{
    authenticationOptions:[{authenticator:'BasicAuthenticator'},{idp:'google'}]
    },{
    onSuccess: function (context) {
    // Do something on success
    };

Fail the login flow​

fail()

This function redirects the user to the redirect URI provided in the authorization request when the login flow fails.

This function takes a map as an optional parameter. When a map is provided as the parameter, the redirect URL will be appended with the following properties (which should be contained in the map). Otherwise, the default parameters are passed. All the properties passed in the map are also optional.

  • Parameters

    errorCodeThe error code to be appended in the redirect URL.
    errorMessageThe error message to be appended in the redirect URL.
    errorURIThe URI of a web page that includes additional information about the error.
  • Example

    var parameterMap = {'errorCode': 'access_denied', 'errorMessage': 'login could not be completed', "errorURI":'http://www.example.com/error'};
    if (!isAuthenticated) {
    fail(parameterMap);
    }

Redirect to error code​

sendError()

This function redirects the user to an error page.

  • Parameters

    urlThe URL of the error page that the user is redirected to. If the value is null, the user is redirected by default to the retry.do error page.
    Note that any relative URL is assumed to be relative to the host's root.
    parametersKey value map passed as parameters. These are converted to query parameters in the URL.
  • Example

    It is recommended to use an i18n key to describe the error messages so that they can be internationalized easily on the error page.

    var user = context.steps[1].subject;
    var isAdmin = hasRole(user, 'admin');
    if (!isAdmin) {
    sendError('http://www.example.com/error',{'status':'000403','statusMsg':'You are not allowed to login to this app.', 'i18nkey':'not.allowed.error'});
    }

Utility functions​

The implementation of utility functions can be found in the WSO2 extensions code repository.

Check group membership​

isMemberOfAnyOfGroups()

This function returns true if the specified user belongs to at least one of the given groups, and returns false if the user does not.

  • Parameters

    userA user object representing the user details.
    groupsA list of strings that contain the groups. Each string is a group name.
  • Example

    var groups = ['admin', 'manager'];
    var user = context.steps[1].subject;
    var isMember = isMemberOfAnyOfGroups(user, groups);
    if (isMember) {
    executeStep(2);
    }

setCookie(response, name, value, properties)

This function sets a new cookie.

  • Parameters

    responseThe HTTP response.
    nameName of the cookie.
    valueValue of the cookie.
    properties

    A map that may contain optional attributes of the cookie with the two custom attributes given below.

    • sign: The default value is false. If it is set to true, the value will be signed.
    • encrypt: The default value is false. If it is set to true, the value will be encrypted.
  • Example

    The size of the value has to be less than the RSA key pair length if 'encrypt' is enabled (set to true).

    setCookie(context.response, "name", "test", {"max-age" : 4000,
    "path" : "/",
    "domain" : "localhost",
    "httpOnly" : true,
    "secure" : true,
    'sameSite': 'LAX',
    "version" : 1,
    "comment" : "some comments",
    "encrypt" : true,
    "sign" : true})

getCookieValue(request, name, properties)

This function gets the plain-text cookie value for the cookie name if it is present.

  • Parameters

    requestHTTP authentication request.
    nameName of the cookie.
    properties

    A map that may contain optional attributes of the cookie:

    • decrypt: The default value is false. If it is set to true, the value will be decrypted.
    • validateSignature: The default value is false. If it is set to true, the signature will be validated before returning a response.
  • Example

    getCookieValue(context.request,"name", {"decrypt" : true,"validateSignature" : true })

Prompt​

prompt(templateId, data, eventHandlers)

This function prompts the user for different interactions.

  • Parameters

    templateIdIdentifier of the template that needs to be prompted.
    dataThe data associated with the template to be sent in the prompt.
    eventHandlersThe callback event handlers.

    The following table contains the supported templates and the associated data.

    Template IdDescriptionData
    genericFormPrompt for generic user input.
    • username: Username that will be used in a greeting
    • inputs: A list of input field objects in the form. For example: {id: “”, label: “”}
    externalRedirectRedirect users to an external static page.
    • redirectURL: The external URL to redirect the user.
    internalWaitKeep a user waiting for a predefined fixed time or until a status is completed.
    • waitingType: Waiting method. Can be one of FIXED_DELAY or POLLING. Default waitingType is FIXED_DELAY.

    • waitingConfigs: Waiting page configurations.

      • greeting: An optional greeting. Default text is Just a moment...
      • message: An optional message. Default text is We are setting things up for you..
      • timeout: Optional timeout period in seconds. Default timeout is 10 seconds and max timeout is 20 seconds.
      • waitingType
      • POLLING
        • pollingEndpoint: REST endpoint to poll a status.
        • pollingInterval: Time internal in seconds to poll the polling endpoint. Default value is 2 seconds.
        • requestMethod: Polling request method. Can be one of GET or POST. Default value is GET.
        • contentType: Content type of the polling request. Default value is application/x-www-form-urlencoded.
        • requestData: Data to be sent to the polling endpoint. Can specify a string or an object. If the HTTP method is GET, the data will be appended to the URL.
  • Examples

var onLoginRequest = function(context) {
executeStep(1, {
onSuccess: function (context) {
var username = context.steps[1].subject.username;
prompt("genericForm", {"username":username, "inputs":[{"id":"fname","label":"First Name"},{"id":"lname","label":"Last Name"}]}, {
onSuccess : function(context) {
var fname = context.request.params.fname[0];
var lname = context.request.params.lname[0];
Log.info(fname);
Log.info(lname);
}
});
}
});
}

Get user sessions​

getUserSessions()

This function returns a session object (i.e., all the active user sessions of the specified user or an empty array if there are no sessions).

  • Parameters

    userThis is a user object that represents the user details.
  • Example

    var user = context.currentKnownSubject;
    var sessions = getUserSessions(user);
    for (var key in sessions) {
    Log.info("Session ID: " + sessions[key].id);
    }

Terminate user session​

terminateUserSession()

This function returns a session object (i.e., all the active user sessions of the specified user or an empty array if there are no sessions).

  • Parameters

    userThis is a user object that represents the user details.
    sessionIdThis is the sessionId string of the session that needs to be terminated.
  • Example

    var user = context.currentKnownSubject;
    var sessions = getUserSessions(user);
    if (sessions.length > 0) {
    var result = terminateUserSession(user, sessions[0].id);
    Log.info("Terminate Operation Successful?: " + result);
    }

Evaluate device policy​

evaluateDevicePolicy()

This function evaluates a device assurance policy against the registered device that is making the login request, and returns the result. The device presents itself with a device token. See Enforce a device policy at login.

  • Parameters

    contextThe authentication context.
    policyNameThe name of the device assurance policy to evaluate.
  • Return value

    An object with the following properties:

    complianttrue if the device complies with the policy, and false otherwise.
    statusOne of COMPLIANT, NON_COMPLIANT, INCOMPLETE_DEVICE_DATA, or ERROR.
    failedFieldsThe device attributes that don't meet the policy.
    missingFieldsThe device attributes that the policy needs but the device didn't report.
    errorCodeSet when the status is ERROR. One of device_data_unavailable, policy_not_found, policy_error, or evaluation_error.
  • Example

    var result = evaluateDevicePolicy(context, "Corporate Device Policy");
    if (!result.compliant) {
    fail({"errorCode": "device_non_compliant", "errorMessage": "Device does not meet the policy."});
    }

Send email​

sendEmail()

This function sends an email to the specified user.

  • Parameters

    userAn object representing the user details.
    templateIdIdentifier of the email template. The email template specifies the body of the email that is sent out.
    placeholderParametersUsed to replace any placeholders in the template.
  • Example

    var user = context.steps[1].subject;
    var firstName = user.localClaims['http://wso2.org/claims/givenname'];
    sendEmail(user, 'myTemplate', {'firstName':firstName});

Call a WSO2 Developer Platform API​

This function invokes an API hosted in WSO2 Developer Platform.

Important

Note that to use the callChoreo function, the API should,

  • contain an endpoint that accepts POST requests.
  • return a status code of 2xx.
  • Parameters

    connectionMetadataAn object containing the necessary metadata to invoke the API. . See ConnectionMetadata for more information.
    payloadDataAn object representing the payload that needs to be sent in the API request body.
    eventHandlersAn object that contains the callback functions, which are to be called based on the result of API invocation.
    Supported results are onSuccess, onFail, and onTimeout.
  • Example

    var connectionMetadata = {
    "url": "<CWSO2 Developer Platform API URL>",
    "consumerKey": "<Consumer key of the WSO2 Developer Platform Application>",
    "consumerSecret": "<Consumer secret of the WSO2 Developer Platform Application>"
    };

    var requestPayload = {"example-key": "example-value"};

    callChoreo(connectionMetadata, requestPayload, {
    onSuccess: function(context, data) {
    Log.info("Successfully invoked the WSO2 Developer Platform API.");
    },
    onFail: function(context, data) {
    Log.info("Error occurred while invoking the WSO2 Developer Platform API.");
    },
    onTimeout: function(context, data) {
    Log.info("Invoking WSO2 Developer Platform API timed out.");
    }
    });
    Using WSO2 Identity Platform as the key manager

    If you are using WSO2 Identity Platform as the key manager in your WSO2 Developer Platform organization, append the asgardeoTokenEndpoint parameter to the connectionMetadata variable as follows:

    var connectionMetadata = {
    "asgardeoTokenEndpoint": "{{ product_url_format }}/oauth2/token"
    };

Get parameter value from JWT​

getValueFromDecodedAssertion(jwt, parameterName, isParameterInPayload)

This function returns a string containing the parameter's value in a decoded Json Web Token (JWT). It includes the following parameters:

  • Parameters

    jwtThe JWT to be decoded.
    parameterNameThe name of the parameter in the JWT for which the value should be retrieved.
    isParameterInPayloadIndicates whether the parameter to be retrieved is in the JWT header or body.
    Value should be true if the parameter to be retrieved is in the body.
  • Example

    var state = getValueFromDecodedAssertion(context.request.params.request[0],"state",true);
note

This function only decodes the JWT - it does not verify the signature, issuer, audience, or expiry.

Get unique user​

getUniqueUserWithClaimValues(claimMap, context)

The utility function will search the underlying user stores and return a unique user with the claim values. The claim map consists of the claim and value.

  • Parameters

    claimMapA map that contains the claim URI and claim value.
    contextThe authentication context, which contains the context information about the request.
  • Example

    var claimMap = {};
    claimMap[MAPPED_FEDERATED_USER_NAME_CLAIM] = federatedUserName;
    claimMap[MAPPED_FEDERATED_IDP_NAME_CLAIM] = idpName;
    var mappedUsername = getUniqueUserWithClaimValues(claimMap, context);

Get multiple users​

getUsersWithClaimValues(claimMap, context)

This function will search the underlying user stores and return a list of users with the expected claim values. The claim map consists of the claim and value.

  • Parameters

    claimMapA map that contains the claim URI and claim value.
    contextThe authentication context, which contains the context information about the request.
  • Example

    var claimMap = {};
    claimMap["http://wso2.org/claims/mobile"] = "1234567890";
    var usersList = getUsersWithClaimValues(claimMap, context);
    for (var key in usersList) {
    var userObj = userList[key];
    Log.info("Username: " + userObj.username):
    }

Get associated user​

getAssociatedLocalUser(federatedUser)

This function returns the local user associated with the federate username given as input.

  • Parameters

    federatedUserThe federated user object.

Do association with local user​

doAssociationWithLocalUser(federatedUser, localUsername, tenantDomain, userStoreDomain)

This function sets association to the local user with federated user. It includes the following parameters.

  • Parameters

    federatedUserThe federated user object.
    localUsernameThe username of the local user to be associated.
    tenantDomainThe tenant domain of the local user.
    userStoreDomainThe user store domain of the local user.

Remove associated local user​

removeAssociatedLocalUser(federatedUser)

This function removes the existing association of a federated user with the local user.

  • Parameters

    federatedUserThe federated user object.
  • Example

    var federatedUser = context.steps[1].subject;
    removeAssociatedLocalUser(federatedUser)

Get masked value​

getMaskedValue(value)

This utility function returns a masked value for the given input value. It can be used to mask sensitive content in logs.

  • Parameters

    valueValue needs to be masked.
  • Example

    If there is a requirement to add logs containing sensitive information (such as PII), those can be masked using this function as follows.

    var email = context.currentKnownSubject.username;
    Log.info("Email of the logged user : " + getMaskedValue(email));

HTTP GET​

httpGet(url, headers, authConfig, eventHandlers)

The HTTP GET function enables sending HTTP GET requests to specified endpoints as part of the adaptive authentication scripts in WSO2 Identity Platform. It's commonly used to interact with external systems or APIs to retrieve necessary data for authentication decisions.

  • Parameters

    urlThe URL of the endpoint to which the HTTP GET request should be sent.
    headersHTTP request headers to be included in the GET request (optional).
    authConfigAn object containing the necessary authentication metadata to invoke the API. See AuthConfig for information.
    eventHandlersThe object that contains the callback functions, which are to be called based on the result of the GET request.
    Supported results are onSuccess and onFail, which can have their own optional callbacks as anonymous functions.
  • Example

    var authConfig = {
    type: "basic",
    properties: {
    username: "admin",
    password: "adminPassword"
    }
    };

    var onLoginRequest = function(context) {
    httpGet('https://example.com/resource', {
    "Accept": "application/json"
    }, authConfig, {
    onSuccess: function(context, data) {
    Log.info("Successfully invoked the external API.");
    context.selectedAcr = data.status;
    executeStep(1);
    },
    onFail: function(context, data) {
    Log.info("Error occurred while invoking the external API.");
    context.selectedAcr = 'FAILED';
    executeStep(2);
    },
    onTimeout: function(context, data) {
    Log.info("Invoking external API timed out.");
    executeStep(2);
    }
    });
    }

HTTP POST​

httpPost(url, body, headers, authConfig, eventHandlers)

The HTTP POST function enables sending HTTP POST requests to specified endpoints as part of the adaptive authentication scripts in WSO2 Identity Platform. It's commonly used to interact with external systems or APIs to retrieve necessary data for authentication decisions.

  • Parameters

    urlThe URL of the endpoint to which the HTTP POST request should be sent.
    bodyHTTP request body to be included in the POST request.
    headersHTTP request headers to be included in the POST request (optional).
    authConfigAn object containing the necessary authentication metadata to invoke the API. See AuthConfig for more information.
    eventHandlersThe object that contains the callback functions, which are to be called based on the result of the GET request.
    Supported results are onSuccess, onFail and onTimeout which can have their own optional callbacks as anonymous functions. For these callbacks, the context and data parameters are passed.
  • Example

    var authConfig = {
    type: "clientcredential",
    properties: {
    consumerKey: "clientId",
    consumerSecret: "clientSecret",
    tokenEndpoint: "https://token-endpoint.com/token"
    }
    };

    var onLoginRequest = function(context) {
    httpPost('https://example.com/resource', {
    "email": "[email protected]"
    }, {
    "Authorization": "Bearer token",
    "Accept": "application/json"
    }, authConfig, {
    onSuccess: function(context, data) {
    Log.info("Successfully invoked the external API.");
    context.selectedAcr = data.status;
    executeStep(1);
    },
    onFail: function(context, data) {
    Log.info("Error occurred while invoking the external API.");
    context.selectedAcr = 'FAILED';
    executeStep(2);
    },
    onTimeout: function(context, data) {
    Log.info("Invoking external API timed out.");
    executeStep(2);
    }
    });
    }
note

WSO2 Identity Platform uses the following default connection configurations for httpPost requests:

ConfigurationDescriptionDefault Value
Connection timeoutThe maximum time (in milliseconds) to wait when establishing a connection to an external service.3000 ms
Read (socket) timeoutThe maximum time (in milliseconds) to wait for a response from an external service.3000 ms
Connection request timeoutThe maximum time (in milliseconds) to wait to obtain a connection from the connection pool.1000 ms
Retry countThe number of retry attempts for requests.2

Resolve multi attribute login identifier​

resolveMultiAttributeLoginIdentifier(loginIdentifier, tenantDomain)

If alternative login identifiers are enabled, this function resolves the username from the provided login identifier.

  • Parameters

    loginIdentifierUser provided login identifier.
    organizationOrganization name.
  • Example

    var loginIdentifier = context.request.params.username[0];
    var tenantDomain = context.tenantDomain;

    var username = resolveMultiAttributeLoginIdentifier(loginIdentifier, tenantDomain);

Update user password​

updateUserPassword(user, newPassword, eventHandlers, skipPasswordValidation)

This function updates the user password.

  • Parameters

    userThe user object.
    newPasswordNew user password.
    eventHandlersOptional callback event handlers.
    skipPasswordValidationOptional parameter to skip password pattern validation.
  • Example

    updateUserPassword(user, "newPassword");

    updateUserPassword(user, "newPassword", {
    onSuccess: function(context) {
    Log.info("Password updated successfully.");
    },
    onFail: function(context) {
    Log.info("Password update failed.");
    }
    });

    updateUserPassword(user, "newPassword", {
    onSuccess: function(context) {
    Log.info("Password updated successfully.");
    },
    onFail: function(context) {
    Log.info("Password update failed.");
    }
    }, true);

Object reference​

You can use the following objects in a conditional authentication script to read information about the login attempt and to set attributes on it.

Context​

Contains the authentication context information. The information can be accessed as follows:

context.steps[n]Access the authentication step information, where 'n' is the step number (1-based). See step for more information.

The step number is the one configured at the step configuration, not the actual order in which they get executed.

context.requestAccess the HTTP authentication request information. See request for more information.
context.responseAccess the HTTP response, which will be sent back to the client. See response for more information.
context.serviceProviderNameGet the application name.
context.currentKnownSubjectAccess the authenticated user from the subject identifier step. It resolves the user from the first completed step that is configured as the subject identifier step. If no subject identifier step is completed yet, it falls back to the user from the current step. Returns a user object or null if no step has been completed.
context.requestedAcrThe list of Authentication Context Class Reference (ACR) values requested by the application. For OIDC requests, these come from the acr_values parameter. For SAML SSO requests, these come from the samlp:AuthnContextClassRef elements.
context.selectedAcr(Read/Write)
The ACR value selected during the authentication flow. Set this to return the appropriate ACR value in the authentication response.
context.tenantDomainThe tenant domain of the application that initiated the authentication request.
context.deviceDataThe attributes reported by the registered device that sent a valid device token with the login request, for example context.deviceData.platform. Not available if the request had no valid device token. See Enforce a device policy at login.

Step​

Contains the authentication step information. It may be a null or invalid step number.

step.subjectContains the authenticated user's information from this step. It may be null if the step is not yet executed. See user for more information.
step.idpGives the name of the federated connection that is used to authenticate the user.
step.authenticatorGive the name of the authenticator that is used for authenticating te user. You can find the authenticator names from the connection names table.

User​

user.uniqueIdThe unique identifier of the user.
user.usernameThe user's username.
user.userStoreDomain(Read/Write)
The user store domain of the local user.
user.localClaims["local_claim_url"](Read/Write)
User's attribute (claim) value for the given "local_claim_url". If the user is a federated user, this will be the value of the mapped remote claim from the identity provider.
user.claims["local_claim_url"](Read/Write)
Sets a temporary claim value for the session.
user.localClaims["local_claim_url"]Updates the claim value in the user store as well. The user.claims["local_claim_url"] parameter is an alternative to setting a temporary claim.
user.remoteClaims["remote_claim_url"](Read/Write)
User's attribute (claim) as returned by the identity provider for the given remote_claim_url. Applicable only for federated users.

Request​

request.headers["header_name"]The request's header value for the given header name.
request.params.param_name[0]The request's parameter value for the given parameter name by the param_name index (param_name is an array).
request.cookies["cookie_name"]The request's cookie value for the given cookie name.
request.ipThe client IP address of the user who initiated the request. If there are any load balancers (eg. Nginx) with connection termination, the IP is retrieved from the headers set by the load balancer.

Response​

response.headers["header_name"](Write) The response header value for the given header name.

Session​

session.userAgentThe user agent object of the user session. See userAgent for more information.
session.ipThe session's IP address.
session.loginTimeThe session's last login time.
session.lastAccessTimeThe session's last accessed time.
session.idThe session's id.
session.applicationsThe list of application objects in the session. See application for more information.

Application​

application.subjectThis is the subject of the application.
application.appNameThis is the name of the application.
application.appIdThis is the ID of the application.

User agent​

userAgent.rawStringThis is the raw userAgent string.
userAgent.browserThis is the web browser property that is extracted from the raw userAgent string.
userAgent.platformThis is the operating system property that is extracted from the raw userAgent string.
userAgent.deviceThis is the device property that is extracted from the raw userAgent string.

ConnectionMetadata​

It contains the necessary metadata for invoking the API when calling the callChoreo function.

connectionMetadata.urlURL of the WSO2 Developer Platform hosted API.
connectionMetadata.consumerKeyThe consumer key of the WSO2 Developer Platform application.
connectionMetadata.consumerSecretThe consumer secret of the WSO2 Developer Platform application.

You can securely store consumer keys and secrets as secrets in conditional authentication scripts and refer to them in your conditional authentication scripts using the secrets.{secret name} syntax. For example, to retrieve a secret value, you may use:

var consumerSecret = secrets.clientSecret;

For more information on adding secrets, refer to the Add a secret to the script section in the documentation.

Change in behavior from 30th September 2024

Starting from 30th September 2024, you are no longer required to set the aliases for consumer keys and consumer secrets when calling the callChoreo command. Instead, you may directly reference them using the secrets.secretName notation. However, if you prefer, you may continue using the previous method as follows.

connectionMetadata.consumerKeyAliasThe name of the secret that stores the consumer key.
connectionMetadata.consumerSecretAliasThe name of the secret that stores the consumer secret.

AuthConfig​

When using httpGet or httpPost functions in WSO2 Identity Platform adaptive authentication scripts, the table summarizes each authentication type and its required properties:

Authentication TypePropertiesDescription
basicusername, passwordUses user credentials.
apikeyapiKey, headerNameUses an API key sent as a header.
clientcredentialconsumerKey, consumerSecret, tokenEndpoint, scope (optional, a space separated list of scopes)Uses client credentials to obtain an access token.
bearertokenUses a bearer token for authentication.

You can securely store sensitive values of properties like username, password, consumerKey, consumerSecret as secrets in conditional authentication scripts and refer to them in your conditional authentication scripts using the secrets.{secret name} syntax. For example, to retrieve a secret value, you can use:

var consumerSecret = secrets.clientSecret;

For more information on adding secrets, refer to the Add a secret to the script section in the documentation.

Data​

dataThe response data is a JSON object that contains the response data from the API call.

Was this page helpful?