← Back to plugin index

Scriptable Step

Description
A non-interactive flow step that runs the configured script. The script will be provided with inputs from the configured value providers. The result of the script is validated against the configured output map and is stored in the session. It can be retrieved using the "Script Execution Result Value Map Provider" plugin in subsequent steps.

IAM uses Lua as its scripting engine. Please refer to the official documentation on https://www.lua.org/ for more information about the Lua language and its features.

Type name
ScriptableStep
Class
com.airlock.iam.flow.shared.application.configuration.step.ScriptableStepConfig
May be used by
Properties
Inputs (inputs)
Description

Defines a mapping of input values that are made available to the lua script. The inputs can be accessed from inside the script as a table through the "iam" API object: iam.input_map

If a value cannot be provided by the configured map, its corresponding key will not exist in the resulting mapping. When writing a script, one should always first check if the key is present before trying to operate on its value.

If two value providers contain an entry with the same key, then only the entry of the provider that appears last in the list will be available within the script.

Note that simple date values without a specific time (i.e. LocalDate) are passed as string arguments in the format "yyyy-MM-dd", while more specific date-time values are provided as epoch time with millisecond precision.

Security Note: The inputs to the Scriptable Step may contain sensitive user data. Handle these inputs carefully and make sure that they are not forwarded to the logger. IAM will not obfuscate this data automatically.

Attributes
Plugin-List
Optional
Assignable plugins
Script (script)
Description

The Lua script that will be run when the step is initialized.

Each script must define the following function:

function iam_on_step_init ()
    return <output_map>
end

The values returned by this function can be accessed using the "Script Execution Result Value Map Provider" with matching namespace. Note that the outputs returned by the script must be declared in the "Outputs" property. If no outputs are expected, then the function's return statement can either be removed, or return an empty mapping.

Attributes
String
Mandatory
Multi-line-text
Outputs (outputs)
Description

Declares the mapping of key-value pairs that are expected to be returned by the Lua script. The outputs are made available under the namespace configured for the step.

The script's outputs are required to match the expected output exactly. If the script's output contains additional results, this will also produce an error.

Individual key-value pairs may be tagged as optional, in which case they are not required to be in the script's output. Note that the order in which the key-value pairs are listed does not matter.

If left undefined, then the output map is expected to be empty.

Attributes
Plugin-Map
Optional
Assignable plugins
Input Secrets (inputSecrets)
Description
Secret strings that are passed in plaintext as environment variables to the IAM script process.

The script is always executed on the server and therefore no secrets are transmitted to an external client, e.g. browser.

An example are HTTP basic authentication credentials for the configuration of a REST client.

Secrets must only be referenced in the script by calling the API method iam.secrets:get(identifier) with their configured string identifier.

Security Note: Secrets must be handled with care. Make sure that they are not forwarded to the logger, as IAM will not obfuscate them automatically.

Attributes
Plugin-List
Optional
Assignable plugins
Namespace (namespace)
Description

The namespace under which the output of the step is stored. If left empty, it is stored under the default namespace.

To retrieve the output values of this step, configure the same namespace in the corresponding Script Execution Result Value Map Provider.

Attributes
Plugin-Link
Optional
Assignable plugins
Skip Condition (skipCondition)
Description

If this condition is configured and fulfilled, the step is skipped and the flow execution continues with the subsequent step.

Attributes
Plugin-Link
Optional
Assignable plugins
Pre Condition (preCondition)
Description
This step is executed only if the configured pre condition is fulfilled. If the condition is not fulfilled, the step and flow execution fail immediately. The step is not initialized and no step method can be called. If no condition is configured, the behavior is that of a fulfilled pre condition.
Attributes
Plugin-Link
Optional
Assignable plugins
Requires Activation (requiresActivation)
Description
If enabled, this step is only executed if it has been dynamically activated from a previous step. If it has not been activated, the step is skipped (equivalent to when the skip condition is fulfilled).
Attributes
Boolean
Optional
Default value
false
Tags On Success (tagsOnSuccess)
Description
This step grants these tags if it completes successfully.
Attributes
Plugin-List
Optional
Assignable plugins
Step ID (stepId)
Description
ID of this step. This is only needed if this step is the target of a goto action or if this step requires activation.
Attributes
Plugin-Link
Optional
Assignable plugins
On Failure Gotos (onFailureGotos)
Description

If the step fails (no retry) and a goto target for the error code is defined here, the flow does not fail and instead a "goto" to the specified target step is executed. Note that even when the "goto" is executed, any error codes that are considered a failed factor attempt will still increment the "failed attempts" counter, and may lead to the user being locked. Therefore, this may still result in a failed flow.

A typical application of this feature is switching to an alternative authentication factor step, if an external service (e.g. Futurae server, SMS gateway) is not available (error code EXTERNAL_SERVICE_UNAVAILABLE with "Strict Counting" disabled, which will not increment the "failed attempts" counter). Other error codes can be found in the IAM REST documentation, in both the general "Error Codes" section and in the documentation of specific endpoints.

Attributes
Plugin-Map
Optional
Assignable plugins
Custom Response Attributes (customResponseAttributes)
Description

A list of custom attributes that are returned in the REST response in addition to the standard attributes the step already returns. The custom attributes defined here are only returned if the step result does not lead to an error response.

Custom attributes are added to the response when a step is initialized and when actions are executed on the step. They will therefore be available in the response leading to this step, and in any responses from endpoints specific to this step. For non-interactive steps, custom attributes are accumulated and added to the response leading to the next interactive step.

Custom attributes are not returned for 'retrieve' endpoints.

Attributes
Plugin-List
Optional
Assignable plugins
YAML Template (with default values)

type: ScriptableStep
id: ScriptableStep-xxxxxx
displayName: 
comment: 
properties:
  customFailureResponseAttributes:
  customResponseAttributes:
  inputSecrets:
  inputs:
  namespace:
  onFailureGotos:
  outputs:
  preCondition:
  requiresActivation: false
  script:
  skipCondition:
  stepId:
  tagsOnSuccess: