Workflow API

The workflow engine simplifies the way you define different kinds of flows, such as registration or activation. It provides a simple, configurable, and flexible way to create a flow for different clients that each want their own custom flow.

The workflow API exposes two endpoints:

  1. POST /workflowapi/process?type={type}&returnUrl={returnUrl}
  2. POST /workflowapi/process/{processToken}

Let’s dive into each API.

POST /workflowapi/process?type={type}&returnUrl={returnUrl}

The POST /workflowapi/process?type={type}&returnUrl={returnUrl} API starts a process instance.

It uses the following parameters:

  • type: This parameter represents the process type to start. It represents the name of the Business Process Model and Notation (BPMN) that is triggered to start. Depending on the process type, some processes require an initial set of data as the request body to start properly.
  • returnUrl: This optional parameter represents the URL where the user is redirected when the process ends.

NOTE: An important BPMN term to understand is process definition, which represents the XML that describes the steps in the flow. Basically, a flow means the execution of a process definition in the workflow engine (which is Activiti).

Request

The frontend of the workflow API renders itself according to each step in the flow. The first time a page that uses a flow is rendered, such as registration, the user interface (UI) is responsible for making a call to the workflow API:

POST /process?type=registration

Basically, this POST tells the workflow API to start a new workflow for the user who is accessing this page.

Response

The response is in the following form:

JSON
Copy

The structure of this response is important, because throughout the whole flow, this response remains consistent:

  • configurationName: This field tells the UI the name of the configuration from the ui-config service ( uic) to render. If you use a custom UI, this field signals to the consumer of the API to render the next UserTask for the user. In the example above, it renders the registration_selection_step UserTask.
  • processToken: This token is linked to the ID of the process definition instance. This means that the user who initialized the process is associated with a unique token, which ensures that it is the same user that initialized the process and not a different user.
  • data: This defines where the data for the user is stored throughout the steps in a flow. Basically, the system keeps track of the user’s inputs.
  • errors: If a step in the flow fails, the UI checks this field to determine whether there are any errors from the backend in regards to the input data.

POST /workflowapi/process/{processToken}

Going back to the responsibility of the UI, the UI renders itself from the specified configurationName.

A typical workflow includes the following steps:

  1. The UI renders the actual page for that step based on the configuration that it received in the response.
  2. The user enters some data on the page.
  3. The UI validates the data that the user entered.
  4. If the data is correct, the user clicks the Next button (or similar action).
  5. The UI calls the workflow API with data similar to what is covered in the POST /workflowapi/process/{processToken} API.
  6. This API moves the flow to the next step in the process instance, which is identified by the processToken.

Request

JSON
Copy

In this example, 8be540c7-20e0-4f42-baa9-38523d2ce042 is the processToken from the first API. This causes the flow to move to the next steps until the next UserTask, DecisionGateway, or EndTask.

Response

The following example shows a response from the backend:

JSON
Copy

With the previous call, if everything goes well, the user is created in the INACTIVE state, which triggers the activation flow:

  • The UI repeats from step 1 until it receives configurationName: thanks, which is basically a stop point or poison pill.

Workflow actions

Workflow actions give the user the ability to reiterate over process steps or to completely cancel a process that they started.

There are four actions that can control the process flow:

  1. CONTINUE goes to the next step in the flow, and can be omitted.
  2. STEP_BACK goes to the previous user task in the flow.
  3. STEP_TO_SERVICE_TASK goes to a service task in the flow, it usually recalls a service task that failed for some reason, such as sending an email or SMS.
  4. CANCEL cancels the flow.

The workflow actions are sent to /workflowapi/process/{processToken} as part of the request body. However, WORKFLOW_ACTION is a reserved keyword and must not be used for any other purposes.

JSON
Copy

To make the workflow actions work, the BMPN process model must implement the logic for these actions (gateways):

XML
Copy

The gateway specifies the exit point, or step, for the desired actions. This means that at a step, the user has the option to choose between any number of these actions (always a minimum of one: CONTINUE).

The following example takes the user to the cancel_user_task if the request body contains "WORKFLOW_ACTION": "CANCEL":

XML
Copy

The workflow actions are not restrictive to the previously specified behavior, but to avoid confusion, use them as designed. For example, use CANCEL to take the user to a previous user task instead of cancelling the flow.

Process instance

When the workflow engine receives a process definition (XML), the user ingesting process definitions into the engine is responsible for starting a new flow or process. The result of starting a new flow or process represents the process instance, which returns some information about the process instance. To identify the process instance that was initialized by the user, use processInstance.id. When it's exposed, the name is simplified to processToken.

User Task

A user task models work that needs to be done by a human actor. The UserTask is pretty powerful in what it can do. The UserTask can be defined as simply as follows:

<userTask id="form_registration_utask_1" name="registration_step1"/>

The UI call to render a page uses the name of the userTask as an identifier. Simply said: userTask.name = configurationName.

Configuring a workflow

To configure a custom workflow process, use a validation group after each user task. This validation group consists of the following tasks:

  • InputProvidedTask checks whether a value has been specified for a declared field or list of fields.
  • ValidationTask takes the current step name and performs validation against user attributes. The validation rules can be defined in UIC and retrieved by calling /api/v1/workflow-configuration/{process}.

In some situations, the ValidationTask cannot be used, and therefore it is necessary to use a custom task for data validation.

NOTE: If the validation fails in one of the validation steps, then the process returns to the previous step with a code and an error message. To learn more about API validation, see API validation.

For the sake of simplicity, only the relevant things that you can configure in the BPMN file are shown here. For a full example of a BPMN, check src/main/resources/bpmn/registration.bpmn20.xml.

To configure a flow’s expiration time, use the token API from self-service, where you can configure the expiry token separately for each segment and brand (value represented in duration).

XML
Copy
  • A flow always includes <startEvent> and <endEvent>.
  • When defining a userTask, which is usually followed by a validationTask (such as serviceTask), if you don't specify a validationTask, then validation is not performed from the backend.
  • Steps are connected to each other using <sequenceFlow>.
  • The following service task is available:
    • validationTask takes the current step name and calls /api/v1/workflow-configuration/{process} to perform validations that are located in uic. The validations are performed against user attributes.

When declaring a validationTask in a BPMN file, the attribute name is required for retrieving the correct validations.

Process variable requirements:

Input

JSON
Copy

Output: None

Available tasks

Some out-of-the-box tasks are available:

emailSenderTask

Sends an email.

Process variable requirements:

Input

JSON
Copy

NOTE You can use either user.preferredLanguage or locale.

Output: none

generateTokenTask

Generates a token for a user. You need to call this task if a user already exists, such as if the user was created using createScimUserTask in a previous step in the flow, or if the user is available at the beginning of the flow.

Process variable requirements:

Input

JSON
Copy

Output: none

createScimUserTask

Takes all the data input by the user from data and performs a SCIM create. You can configure the payload for this task (see Configuring payloads).

Input

JSON
Copy

Output

JSON
Copy

updateScimUserTask

Takes all the data input by the user from data and performs a SCIM update. You can configure the payload for this task (see Configuring payloads).

Process variable requirements:

Input

JSON
Copy

Output:

JSON
Copy

HttpRequestorTask

Executes an HTTP or HTTPS request and sets the response on the execution.

Service task properties:

  • httpRequestConfigName is the configuration name that contains a JSON representation of a request.

Example

XML
Copy

Configuration

iwelcome.requests.requests is a JSON representation of a map in the format: <string, HttpRequestConfig>

The string value from the map represents the httpRequestConfigName that needs to be provided in the BPMN. The HttpRequestConfig format is explained after the example.

Example

JSON
Copy

HttpRequestConfig format:

  • request is the HttpRequestData object.
  • responseContainer is a string that represents the name of the variable from the execution where the response is set. When set to the execution, the variable defined in the responseContainer is of type HttpResponseData. HttpResponseData format:
  • response is the actual response from the invoked endpoint.
  • statusCode is the returned HTTP status code.
  • headers is the returned headers, which are needed when dealing with other types of data, such as images.

HttpRequestData format:

  • endpoint is the URL where you send the request. It can contain placeholders for URL variables. Define the placeholders within curly brackets {}.
  • method is the HTTP method name, such as GET, POST, PATCH, DELETE, and so on.
  • authInfo is the SpEL expression that specifies which type authentication to apply for the configured endpoint such as Basic Auth, Oauth, and so on.
  • headers is a map representing the headers needed while invoking an endpoint. The headers map follows the following pattern: header-name : header-value.
  • contextHeaders is a map representing the headers needed while invoking an endpoint. This is different from the headers, because it allows header values to be specified dynamically based on a SpEL expression from the execution context, such as "contextHeaders": {"Authorization": "#execution['internalUser']['response']['access_token']"}
  • urlPlaceholdersis a map of <string, SpEL expression>, where the string represents the URL placeholder names and the SpEL expression defines where to retrieve the value from the execution.
  • template is a mustache template that defines the payload structure for requests that support the request body (can be omitted for other requests).
  • payload is the RequestPayload object.

RequestPayload format:

valuePlaceholders is a map of <string, SpEL expression> where the string represents the request body placeholder names from the template, and the SpEL expression defines where to retrieve the value from the execution.

Reserved keywords

  • execution: Every SpEL expression from urlPlaceholders and valuePlaceholders starts with #execution and this aspect is mandatory, because needed values are retrieved from the process execution.
  • data: All template SpEL expressions start with #data and this aspect is mandatory to properly map the attributes.
  • applicationProperties: When the process starts, all application properties are set to the process execution. To retrieve these properties, the user needs to access this map. This is a decision that simplifies the way a request is defined for an HttpRequestorTask service task.

activateUserTask

Activates a user, which means it sets the user’s state to ACTIVE.

Process variable requirements:

Input

JSON
Copy

Output: none

changePasswordTask

Changes a user's password

Process variable requirements:

Input

JSON
Copy

Output: none

deleteTokenTask

Inactivates a flow token, such as activation token or password reset token.

Process variable requirements:

Input

JSON
Copy

Output: none

generateConsentTask

Generates consent for user's attributes

Process variable requirements:

Input

JSON
Copy

Output: none

generateDocumentConsentTask

Generates consent for documents (eg: terms of service, privacy policy)

Process variable requirements:

Input

JSON
Copy

Output: none

generateProcessTokenTask

Generates a process token

Input: none

Output

JSON
Copy

WARNING: The validity period for this token is taken from the ssmicroservice.

generateProcessTokenTtlTask

Generates a process token for which it is mandatory to specify the time to live (TTL) for the token.

Input: none

Output

JSON
Copy

Example

XML
Copy

WARNING: When you define this service task, you must specify the tokenValidity period , otherwise it uses the default period specified in the SS microservice.

deleteProcessTokenTask

Inactivates the current process token with the WORKFLOW_PROCESS_TOKEN type. If the token was generated with a different type than WORKFLOW_PROCESS_TOKEN, specify the type of the current process token to inactivate.

Process variable requirements:

Input

JSON
Copy

Output: none

Example:

XML
Copy

GenerateHashTask

Generates a hash for a provided string value. This task takes the hashing configuration from the Consul (config/application/iwelcome.attribute-hashing.hashing-templates) and sends it to the hashing library, which means that it won't work without this configuration. This service task looks in consul for hashing.

Input

  • inputValue is the value to hash.
  • outputName is the name of the variable on the execution that contains the hashed value.
  • hashingTemplate is the name of the template used to hash the value.

NOTE: When you define this service task, you must specify the inputValue, outputName, and hashingTemplate fields, or it will be unable to generate the hash.

Output

JSON
Copy

Example

XML
Copy

SmsSenderTask

Sends an SMS to a specific user.

Input

JSON
Copy

Output

JSON
Copy

Example

XML
Copy

NOTE:sendOtpMaxAttempts specifies the maximum number of attempts that a user can perform when sending an SMS. The limit is set to three. If this maximum is exceeded, an error is generated. If the sendOtpMaxAttempts is not present on the execution, default configuration is picked up from iwelcome.two-fa.sendOtpMaxAttempts.<<segment>>.<<brand>> .

Script example

XML
Copy

SmsCodeValidationTask

Validates the SMS code.

Input

JSON
Copy

Output

JSON
Copy

Example

XML
Copy

NOTE: validateOtpMaxAttempts specifies the maximum number of attempts that a user can perform when validating an SMS code. The limit is set to three. If this maximum is exceeded, an error is generated. If the sendOtpMaxAttempts is not present on the execution, the default configuration is picked up from iwelcome.two-fa.validateOtpMaxAttempts.<<segment>>.<<brand>> .

Script example:

XML
Copy

inputProvidedTask

Checks whether a value is specified for declared fields. When declaring this service task in a BPMN, you must specify the fieldNames attribute. This attribute value must consist of a single attribute name or a list of attribute names separated by commas (, ).

Example

XML
Copy

Process variable requirements:

Input

JSON
Copy

Output: none

authorizationUserTask

Checks if a provided access token contains the required scopes that were configured in the BPMN. When declaring this service task in a BPMN, you must specify the requiredScopes attribute. This attribute value must consist of a single attribute name, or a list of attribute names separated by commas (, ).

Example

XML
Copy

Input: An access token sent on the authorization header using the bearer schema.

Output

  • None when the user is authorized and the access token contains the required scopes
  • user_not_authorizedwhen the user is not authorized
JSON
Copy

validateTokenTask

Checks whether a token is valid.

Process variable requirements:

Input

JSON
Copy

Output: none

getSocialProfileTask

Retrieves a social user profile from a social provider.

Process variable requirements:

Input

JSON
Copy

Output

JSON
Copy

userConsentMappingTask

Maps the user consent to social consent. Creates a list of consented attributes to retrieve from social providers, based on local consented attributes. Attribute mapping is based on the map defined in Consul under the following key: iwelcome.social.<PROVIDER_NAME_mapping>, such as iwelcome.social.facebookMapping. To support additional social providers, some minor code change are required, such as adding a key for each provider.

Attribute mapping example (map has localAttrName : socialAttrName form):

JSON
Copy

Process variable requirements:

Input

JSON
Copy

Output

JSON
Copy

socialUserDataMappingTask

Maps data retrieved from a social account to a user considering consented processing purposes. The mapping is needed because some attributes are always retrieved from a social provider. For example, Facebook returns the user's name in the public profile and the public profile is always retrieved from Facebook.

Attribute mapping is based on the map defined in Consul under the following key: iwelcome.social.<PROVIDER_NAME_ProcessingPurposeAttributeMapping>, such as iwelcome.social.facebookProcessingPurposeAttributeMapping. To support additional social providers, some minor code changes are required, such as adding a key for each provider.

Attribute mapping example (map has the localAttrName: attribute name from processing purposes`` form):

Process variable requirements:

Input

JSON
Copy

Output

JSON
Copy

socialProviderRequesterTask

Builds the URL used for retrieving the user data from a social provider based on the consented fields.

Process variable requirements:

Input

JSON
Copy

Output

JSON
Copy

getUserTask

Retrieves user information based on the user's email address.

Process variable requirements:

Input

JSON
Copy

Output

JSON
Copy

deleteUnusedTokensTask

Deletes tokens for a user based on the token type.

Process variable requirements:

Input

JSON
Copy

Output: none

eventPublisherTask

Publishes an event for a user. When declaring this service task in a BPMN, you must specify the eventType attribute . This attribute value must consist of a single event type name.

Example

XML
Copy

Process variable requirements:

Input

JSON
Copy

Output: none

generateAuthTokenTask

Generate an auth token that can be used for the authentication code flow.

Example

XML
Copy

Process variable requirements:

Input

JSON
Copy

Output

JSON
Copy

genericLookupTask

Searches for a user in an external database or store, based on lookup data.

Process variable requirements:

Input

JSON
Copy

Output

JSON
Copy

sdUserAuthenticationTask

Verifies whether a user is a service desk user. This check is done using the request headers.

Process variables requirements:

Input: none

Output: none

userStatusActiveVerifierServiceTask

Verifies whether a user is active based on the user's email address.

Process variables requirements:

Input

JSON
Copy

Output (only if the user is not active):

JSON
Copy

deleteUserTask

Deletes a user.

Process variables requirements:

Input

JSON
Copy

Output: none

saveProcessDataTask

Collects and stores BPMN process data to be shared between multiple BPMN processes.

Service task properties:

  • processDataTransferType is a type of process data. Together with userId, it forms a unique pair for storing and retrieving purposes.
  • transferredAttributes is a list of attribute names (separated by commas) to retrieve from execution and store in the process data.

Example

XML
Copy

Process variable requirements:

Input

JSON
Copy

Output: none

getProcessDataTask

Retrieves BPMN process data, and each attribute in the process data is set to the process execution service task properties:

  • processDataTransferType identifies the type of process data to retrieve.

Example

XML
Copy

Process variable requirements:

Input

JSON
Copy

Output

JSON
Copy
  • deleteProcessDataTask deletes the BPMN process data service task properties.
  • processDataTransferType specifies the type of process data to delete.

Example

XML
Copy

Process variable requirements:

Input

JSON
Copy

Output: none

publishDataTask

Puts attributes from execution to the process public data. The attributes will be in the HTTP response.

Service task properties:

  • publishDataConfigName is the configuration name with attributes to publish, which means to place in the public process data.

Example

XML
Copy

Configuration

iwelcome.publish.publishData json map of PublishData object list

Example

In this example, publish_preferred_language and publish_return_url are publishDataConfigName to provide as values in the BPMN.

JSON
Copy

The format of PublishData object is:

  • attributeName is the SpEL expression for the attribute to publish.
  • executionVariableName is the name of the attribute in the execution where you can look for the attributeName.
  • publishedAttributedName is the name of the attribute after it is published (placed in the public process data).

Process variable requirements:

Input

JSON
Copy

Output

JSON
Copy

IsPasswordSetForUserTask

Makes a request to the credential-api and checks if a user has already provided a password.

Example

XML
Copy

Process variable requirements:

Input

JSON
Copy

Output

JSON
Copy

MoveProcessVariablesTask

Facilitates moving variables on a process execution from one place to another. This service task is like a connector task, because it prepares and makes available data for following service tasks. You can use it to match the input of a task to the output of a previous task.

Service task properties:

  • configuration specifies the name that contains a JSON representation of a move data action.

Example

XML
Copy

Configuration

  • iwelcome.move-process-variables.configuration is a JSON representation of a map in the format: <string, MoveDataConfig>

The string value from the map represents the configuration that needs to be provided in the BPMN. The MoveDataConfig format is explained after the example.

Example

JSON
Copy

MoveDataConfig format:

  • from specifies the name of the source variable.
  • fromSpel is a SpEL expression used to pinpoint the from attribute in the process execution.
  • to specifies the name of the destination variable.
  • toSpel is a SpEL expression used to pinpoint the to attribute in the process execution.
  • operation specifies the type of move operation. It can take the following values: APPEND or OVERWRITE.

Reserved keywords

  • execution: Every SPeL expression from fromSpel and toSpel starts with #execution. This aspect is mandatory because all needed values are retrieved from the process execution.
  • Operation notes:*
  • OVERWRITE: Overwrites the to attribute with the value of the from attribute, regardless of the data types.
  • APPEND: Behaves differently according to the data types that are involved. You can use the following compatible data types with the APPEND operation:
  • from Map to Map: Adds all attributes from the source map to the destination map.
  • from String to Map: Adds the fromSpel value to the destination map. The new attribute key is represented byfrom.
  • from List to List: will add all attributes from the source list to the destination list
  • After the defining the flow, the last step should always be a userTask with the name thanks. The UI requires this step.

Configuring push notifications

Push notification message templates

You can configure the messages in the iwelcome.imi.push-notification-message-templates.

JSON
Copy

Specify the segment and brand inside the configuration file. Specify the logo on the segment and brand level. The messageContent property contains the message templates for sending the push notification, and is configurable on the segment level.

This configuration is useful if you need to send different messages in the push notification, for the session and for different languages. The logo is not set at the locale level, because it is the same regardless of locale.

ImiPushUserNotificationTask

This is the IMI user push notification.

Example

JSON
Copy

Configuration

pollingInterval: Represents the interval (in seconds) that is used by external parties, such as the UI, APIs, and so on, to query the notification status. Uses the ISO 8601 duration format.

Process variable requirements:

Input

JSON
Copy

Output

JSON
Copy

GetImiNotificationStatusTask

Retrieves the IMI notification status for the nonce code that is present in the process.

Example

XML
Copy

Process variable requirements:

Input

The get notification status API is called using the nonce value.

JSON
Copy

Output

JSON
Copy

ImiDeleteAccountsTask

Deletes all the accounts for a specific user.

Example

XML
Copy

Process variables requirements:

Input

JSON
Copy

Output

JSON
Copy

GenerateImiEnrolQrTask

Generates a QR code for a user. The generated code can be used for OMI enrolment.

Example

JSON
Copy

SsoCookieVerifierServiceTaskTest

Validates whether the SSO session is valid.

Example

XML
Copy

Process variable requirements:

Input

JSON
Copy

Output

JSON
Copy

Configuration

  • pollingInterval: Represents the interval (in seconds) that external parties, such as the UI, APIs, and so on, use to query the QR scanning status. Uses the ISO 8601 duration format. Process variable requirements:

Input

JSON
Copy

Output

JSON
Copy

GetImiEnrolmentStatusTask

Retrieves the IMI enrolment status for the nonce code that is present in the process.

Example

XML
Copy

Process variable requirements:

Input

The get enrolment status API is called using the noncevalue.

JSON
Copy

Output

JSON
Copy

Status cases

  • enrolled (isStepSuccessful=true): The enrolment was successful and can move to the next step.
  • pending (isStepSuccessful=true): The user has not yet scanned the generated QR code. The process should stay in the same step (GetImiEnrolmentStatusTask).
  • failed (isStepSuccessful=false): The credential API call failed and the process should be redirected to the generate QR code step.

Configuration of precomputed claims

The PrecomputedClaims flow is a mechanism triggered by the login-api service when a user needs to have OIDC or SAML claims precomputed in some way. The BPMN that is triggered can be configured from the login-api properties.

Generally, the steps in a precomputed claims flow look like this:

  • Receive the default claims from the login-api.
  • Calculate new claims.
  • Pass the new claims to an httpRequestor task, which sends the requests to UDH for storing the claims.

The initial claims can be retrieved from the execution variables using the initialClaims key .

WARNING: When receiving input from the user, and before storing the precomputed claims, always make sure that all data that came from user input is actually valid.

In the following example of a flow, a user can enter malicious data: When the precomputed claims are triggered, the user needs to select one group to use on the external application that is triggering the OIDC or SAML request. Instead of selecting a group that this user has, the user calls the API and specifies that they selected the group admins. If no checks are done in the workflow to determine if this user actually belongs to that group, and the precomputed claims are stored, the user gains administrative rights for the external application.

NOTE: In general, anything that comes from a userTask must be validated.

Listeners and events

Process End Event Listener

Deletes the workflow process token from self-service. This event must be attached to the end event on every workflow BPMN definition.

XML
Copy

Get Process Purposes Listener

Listener that can be attached to a user task. When attached, it retrieves the consent process purposes for that task, filtered by the filter field.

XML
Copy

NOTE: When modifying processing purposes in consul, remember that changing the tags field directly affects the registration flows (workflow-api bpmn). If you do not provide the correct tags, the processing purpose does not appear throughout the registration flows, and consent is not saved for the user. The tags field is connected with the steps defined in the BPMNs.

Example

If we have a userTask in a BPMN:

XML
Copy

The value step2 needs to be in the processing purpose in the tags field.

Example of processing purpose (notice the tags section in the JSON):

JSON
Copy

Process variable requirements:

No input variable is needed.

The listener queries for the required processing purposes and places them in the following variables:

  • Processing purposes with attribute legalBasis : consent.
JSON
Copy
  • Processing purposes with attribute legalBasis : contract
JSON
Copy

Collect Process Purposes Listener

Should be used with Get Process Purposes Listener. You can attach the Collect Process Purposes Listener to a user task. When attached, it adds the consented processing purposes in the task to the possible previously consented processing purposes in the process flow.

JSON
Copy

Process variable requirements: The listener looks into the following process variable to collect the consented processing purposes:

JSON
Copy

The listener collects the consented private purposes in the following process variable (note that processPrivateData is not sent via HTTP and remains visible only to the workflowapi service):

JSON
Copy

Get Documents Listener

Listener that you can attach to a user task. When attached, it retrieves the consent documents for that task, filtered by the filter field.

XML
Copy

Process variables requirements:

No input variable is needed.

The listener queries for the needed documents and places them in the following variables:

JSON
Copy

Collect Documents Listener

Should be used with the Get Documents Listener. You can attach the Collect Documents Listener to a user task. When attached, it adds the consented documents in the task to the possible previously consented documents in the process flow.

XML
Copy

Process variable requirements:

The listener looks into the following process variable to collect the consented documents:

JSON
Copy

API validation

  • Both the UI and the API validate the data that the user submits.
  • To perform the API validation, use the validators _ _defined in the uic.
  • Define the API validations in consul under the following key: CONFIG/UIC/WORKFLOW/API/VALIDATIONS/.
  • For each process there is a key under the specified folder and a key has the segment.brand.process_id_ format.
  • Validators _ are defined for (process_id,_ step_name, field_name) tuples.

API validator types

  • Maximum length (max_length): Defines a maximum length for a field. Constraint: The value must be a positive integer.
  • Minimum length (min_length) : Defines a minimum length for a field. Constraint: The value must be a positive integer.
  • Regular expression (regex) : Defines a regular expression that the field must match. Constraint: The value must be a valid java regex.
  • Required (required): Defines a required Boolean value for the field. Constraints: true if value is required, falseotherwise.
  • Unique email (unique_email) : Defines whether the value (email) must be unique among the primary email addresses for a brand. Constraints: true if value is required, false otherwise.
  • Unique attribute(unique_attribute): Defines whether the attribute value must be unique among the other existing attribute values.
  • Attribute: Specifies the name of the unique attribute. Constraints: true if the value is required, false otherwise.

Example for the activation flow:

  • consul key

config/uic/workflow/api/validations/ongo.bikes.activation

JSON
Copy
  • The consent microservice is called using a JWT that contains a fictitious user with the ROLE of SD user. This JWT solution is temporary. The client is then responsible for logging in a super-user that can create consent for the user that registers.
  • GenerateConsentTask is used for attribute consent generation, which takes the attribute consents from the process variables and stores them.
  • GenerateDocumentConsentTask is used for document consent generation, which takes the documents from the process variables, looks for the configuration in UIC, and then stores the consent for the documentId and the user.

The main reason for the separation of consent generation is flexibility. You can add service tasks anywhere in the BPMN process and it is generic, can be added on multiple steps of the process, and all that you need to do is have the consents on the processVariables. The consentData can be incomplete. For example, it can have only attribute consent data if you are storing only attribute consent, and you can add the document consent later, or not at all.

JSON
Copy
  • Add the desired consent generator task in the BPMN at the required step.

BPMN sub processes

Two reusable sub processes have been created. One is for sending an email, and one is for activating the user.

The sub process must be included in the main process, as follows:

Send email

XML
Copy

Activate user

XML
Copy

Configuring payloads

SCIM postObject/patchObject configurations:

The configuration is done using the iwelcome.scim.postObject.<<SEGMENT>>.<<BRAND>> key in Consul. Replace the SEGMENT and BRAND according to your needs.

By default, there is a sensible default for any type of segment and brand:

YAML
Copy

If no configuration is made in Consul, the src/main/resources/scim/scim-create.json.mustache are picked off.

The JSON is actually a mustache template, which is changed at runtime with the corresponding segment brand that comes from reverse proxy.

To override the default configuration, go to src/main/resources/scim/scim-create.json.mustache, take a copy, replace all occurrences of {{segment}} and {{brand}} with your segment and brand combination, and then paste that in a new key in Consul: config/workflowapi/iwelcome.scim.postObject.YOUR_SEGMENT.YOUR_BRAND

The same applies for the iwelcome.scim.patchObject.<<SEGMENT>>.<<BRAND>> configuration, but the corresponding configuration is located in src/main/resources/scim/scim-patch.json.mustache

NOTE: When configuring the scim-[create/patch].json file, remember to wrap each attribute value with simple quotes, otherwise the value is not read as a string. For more information about this Sprint Expression Language requirement, see https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#expressions.

Example: "'ongo'"

Configuring createScimUserTask

The configuration is done using the iwelcome.scim.postObject.<<SEGMENT>>.<<BRAND>> key in Consul.

The value of this key is a map of maps that represents the link between payload attributes and the user-to-be-created SCIM attributes. The key for each map in the config represents the createScimUserTask BPMN ID of that particular service task.

To change a payload attribute name, change the mapped attribute key as follows:

  • The name of the new payload attribute needs to be defined as #userMap['newPayloadAttributeName'].

The following example maps the email(defined by the #userMap['email']) attribute from the payload to the emailsSCIM attribute. For example, for iwelcome.scim.postObject.ongo.bikes and the BPMN service task that is associated with it:

JSON
Copy

NOTE: Set the preferredLanguage while creating the user. This attribute facilitates sending email to the user in their language of choice (the language that was set during registration).

Step input or output validation

To control the data that is present in the workflow process, for security reasons, configure each step to accept or return only the attributes that it needs.

This can be configured through Consul (iwelcome.workflow-data-sanitization.configuration ), where you can specify the input and the output attributes that are accepted for each step. The extra attributes present in the payload are ignored.

In addition to filtering the input and output attributes, you can make certain value manipulations with the help of SpEL expressions when needed.

One example is masking the phone number on the output (response to the client, which can be the UI). This is optional.

If an attribute is mutated using a SpEL expression, its name is prefixed with mutated_ when returning it in the response. For example, phoneNumber is returned as mutated_phoneNumber.

JSON
Copy

With the example configuration above, the following actions are performed:

  1. The firstName attribute is upper-cased before saving it to the process execution (and going forward, everywhere this attribute is used, it is upper-cased).
  2. The phoneNumber attribute does not suffer any mutations on the input side.
  3. The firstName attribute is part of the response (it is upper-cased because of the previous input configuration).
  4. The phoneNumber attribute is part of the response and every character or digit in it, except the first two and the last one, are replaced by the character. The replacement is not saved on the process execution, which means that the actual phoneNumber from the user input is used in the process execution.

Configure the workflow to check the input and the output for the step named example_step:

  • Input: a list of data sanitization objects

    • attributeName: (string) the name of the attribute that is accepted as input in the payload
    • spelExpression: a SpEL expression
  • Output: a list of data sanitization objects

    • attributeName: (string) the name of the attributes returned by the step
    • spelExpression: a SpEL expression that changes the attribute, the name of the attribute is prefixed with mutated_

Both input and output are optional attributes in the configuration JSON.

Filtering is not performed if the input or output attributes are not present. If these attributes are defined as empty JSON ([]), the step input or output validation filters out everything.

SpEL expression example

To mask the phone number when returning it to the UI, so that only the first two digits and the last digit are shown, and the rest of the digits are replaced with * , use the following SpEL expression:

#phoneNumber.replaceAll("(?⇐.{2}).(?=.{2})", "*")

Profile completion step configuration

The profile completion step allows you to ask for additional data from the user when that data is not present.

For example, we call an IDP (such as a user lookup) that returns data for the user, but it is missing the user’s email, which is an attribute that we need. The profile completion page should have a configuration that allows us to state which attributes we need, and if some of them are missing, request them from the user.

In this example, we need the email, so that the user is redirected to the profile completion page, where they must specify the email.

Use case

When a login with a remote IDP is performed, and the login fails because there is no account linked in the iWelcome store, then a workflow is triggered with the ID token data that has been received from the remote IDP. The data is used to look up the user in the iWelcome store, and if there is no user found, we have to request additional information.

Additional information is requested through the profile completion page. The page is constructed by comparing the input payload with a list of configured attributes. If something is missing from the input payload, then profile completion asks for the missing data. After the user completes the forms, then that data is used to look up the user again.

BPMN configuration

The service task findMissingRequiredDataTask checks for the requiredDataConfigName, based on a configuration in Consul, and checks whether the user has the attributes specified in the configuration. The output of this service task is as follows:

  • Required data is missing:

    • requiredAttributesMissing process variable is set to true, stating that some data is missing
    • missingData is a list of missing attributes that is put on the public process data
  • All the required data is present for the user:

    • requiredAttributesMissing process variable is set to false

After this gateway, the user is directed to the profile completion step, if needed, or to the next step in the flow, if no additional data is required.

The missingData variable is removed from the processPublicData, to not be seen on further workflow steps.

XML
Copy

Consul configuration

To configure the required attributes for the profile completion page, you must change the following Consul key: iwelcome.required-step-data.configuration. The configuration is a list of attributes (strings) that are needed in the respective step.

JSON
Copy

The key required_step1 is the requiredDataConfigName specified in the service task findMissingRequiredDataTask in the BPMN. For this reason, this configuration does not have to be segment and brand aware, and you can use it multiple times in the same BPMN, you just have to change the requiredDataConfigName.

XML
Copy

Initiate identity link: The service task initIdentityLinkTask initiates the account linking process before redirecting the user to the (social) identity provider for login. The required key needs to be set on execution: identityProviderName.

XML
Copy

*_Get identity link profile process input: *_the output of the initIdentityLinkTask task, the authorization_code, and redirect_uri . *_Process output: *_the output is a map containing the account information from the remote IDP, and is set on the execution context under them profileData property.

XML
Copy

Activate identity link: The service task activateIdentityLinkTask activates the identity link. Invoking this service task changes the status of the identity-link from pending to active. Before you use this service task, use the initIdentityLinkTask. The required keys that you need to set on execution: initiateIdentityLink, idpUser.

XML
Copy

Link Account: The service task LinkAccountTask is used to complete the identity link. Before using this service task, use the initIdentityLinkTask. The required keys that you need to set on execution: initiateIdentityLink, authorization_code, redirect_uri``

XML
Copy

Redirect hook: The service task RedirectHookTask redirects the user to any social provider. Before using this service task, use the initIdentityLinkTask.

XML
Copy

Advanced configuration of createScimUserTask

It is possible using SpEL expressions to configure something more complicated than just normal attributes or default values. For example, to configure a field to be lowercase, you could do the following:

JSON
Copy

Another example would be if you want to strip some substring from an attribute, based on a condition:

JSON
Copy

This example verifies whether the relatienummer starts with a 0 (zero), strips the 0s using a regex, and replaces it with an empty string (this is the Java equivalent of Linux sed).

Configuring updatedScimUserTask

The configuration is done using iwelcome.scim.patchObject.[[SEGMENT]](https://github.com/onewelcome/se-community-documentation/blob/master/documentation/workflow%20api/workflow%20api%20public.adoc#SEGMENT).[[BRAND]](https://github.com/onewelcome/se-community-documentation/blob/master/documentation/workflow%20api/workflow%20api%20public.adoc#BRAND) key in Consul. The value of this key is a map of maps that represents the link between payload attributes and the SCIM attributes for the user to update . The key for each map in the configuration represents the updateScimUserTask BPMN ID of that particular service task.

To change a payload attribute name, you must change the mapped attribute key. Define the name of the new payload attribute needs as #userMap['newPayloadAttributeName']

The following example maps the email (defined by #userMap['email']) attribute from payload to the emails SCIM attribute. The following example shows iwelcome.scim.patchObject.[[SEGMENT]](https://github.com/onewelcome/se-community-documentation/blob/master/documentation/workflow%20api/workflow%20api%20public.adoc#SEGMENT).[[BRAND]](https://github.com/onewelcome/se-community-documentation/blob/master/documentation/workflow%20api/workflow%20api%20public.adoc#BRAND) and the BPMN service task that is associated with it:

XML
Copy
JSON
Copy

Process Flows

Each user task corresponds to a UI page. The name of the user task is the name of the UI page.

If you configure a new user task it should look like this:

XML
Copy

Here the page_name is the name of the UI page config that will be used for this step.

These UI pages configurations can be configured in consul, config/uic/ui/segment.brand.workflowEngine.name. Replace segment, brand and name with what is needed.

The following table explains the correlation between BPMN user tasks and the UI pages configuration.

Flow typestepconfiguration(config/uic/ui/segment.brand.workflowEngine.name)
registrationregistration_selection_stepregistration_selection_step
form_registration_utask_confirm_emailemail_sent_step
last_stepthanks
activationform_registration_utask_confirm_emailemail_confirm_step
token_validation_failedtoken_validation_failed
form_registration_utask_2registration_step3
form_registration_utask_1registration_step1
last_stepthanks
registration_email_consentregistration_email_consent_stepregistration_email_consent_step
email_sentemail_sent_step
activation_idin_lookup_otpwait_for_activation_email_clickemail_confirm_step
token_validation_failedtoken_validation_failed
set_user_passwordset_password_step
select_idin_bankselect_idin_bank_step
match_successfulmatch_successful_step
match_failedmatch_failed_step
set_phone_numberset_phone_number_step
input_otpinput_otp_step
activation_failedactivation_failed_step
activation_completeaccount_ready

Activation process flow

The user activation process flow starts when a user is created. If the user is INACTIVE, the activation flow sends an activation email to the user’s primary email.

The workflow listens to a rabbitMQ queue called activation-queue for the user-created process event. This process event is published by UMS when creating a user.

The listener picks up this event and consumes it, starting the activation flow and populating it with initial data collected from the event.

When starting a new activation process, the old activation processes are deleted. For details about how this is done, see the Ending already existing processes section.

If the workflow cannot process the message on this queue after a configurable number of retries, then the message is passed to the activation dead letter queue. The following lines configure the retry mechanism for reading a message from rabbitMQ (maximum number of retries, delay, interval).

Remember that for the dead letter queue to work as expected, you need to configure the default-requeue-rejected property to false, otherwise the messages are lost:

YAML
Copy

Complex invitation process

The invitation flow is used when a user (invitor in this case) wants someone else (invitee) to register, and maybe give that person access to some resources.

To start the invitation process, the invitor completes some data about the invited user:

  • email
  • language
  • personal note: Some validation is performed. If it fails, the user is redirected to the start page, where they have to change the data.

After this step, the invited user receives an email informing them that they are invited to register.

The invited user clicks the email link and is redirected to the profile completion page. Validation is performed, and if it fails, the user is redirected to the profile completion page.

The user is created and the web hook API is called. If everything is performed successfully, the invitation flow ends and the invitor receives a confirmation email informing them that the invited user accepted the request.

To start the invitation flow, the invitor must be logged in. The following headers are needed:

  • Authorization (Bearer token)
  • segment
  • brand

The following section describes the complex invitation flow:

  1. Start the invitation flow: https://www.ongo.com/bikes/workflowapi/process/?type=invitation_complex.
    1. body:
    2. response:
JSON
Copy
  1. Accept email, language, and personal note task: https://www.ongo.com/bikes/workflowapi/process/357c183c-bcee-4ac6-8da9-f4568f7a95c5.
    1. body:
JSON
Copy

b. response:

JSON
Copy
  1. Email step (invited user clicks email)
    1. body:
JSON
Copy

b. response:

JSON
Copy
  1. Complete profile step:
    1. body:
JSON
Copy

b. response:

JSON
Copy
  1. Send an email to the invitor informing them that the user accepted their invitation.

Time-based one-time password

There is a sample of how to configure Time-based One-Time Password (TOTP) enrollment. The location of individual configurations is: src/main/resources/totp

The user enrolls a new TOTP device, and after the process is completed, the user is automatically logged in.

Social registration flow

Ending already existing processes

When a new process is created, and another one exists for the same user, the old process must be deleted. Deleting old processes is necessary because of timers for certain tasks (like deleting the user if they do not complete the process), to avoid cluttering the memory with useless, suspended processes.

The workflow API listens to a queue named end-workflow-process.queue for messages that contain a processId and deletes the process with the respective processId.

When a process is started for a user, it deletes old tokens for the same process type and user. The SSUI microservice deletes the tokens and publishes a message containing the processId to the end-workflow-process.queue. The listener (EndProcessListener.java) in the Workflow API picks up this message and deletes the process.

Example: activation process

  1. In the activation process BPMN, the following task deletes the old tokens:
JSON
Copy
  1. The SSUI microservice deletes the process token and publishes the process event to end the old activation process.
  2. The Workflow API deletes the old activation process.
Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard
  Last updated by Lisa Burry
On This Page
Workflow APIPOST /workflowapi/process?type={type}&returnUrl={returnUrl}POST /workflowapi/process/{processToken}Workflow actionsProcess instanceUser TaskConfiguring a workflowAvailable tasksemailSenderTaskgenerateTokenTaskcreateScimUserTaskupdateScimUserTaskHttpRequestorTaskactivateUserTaskchangePasswordTaskdeleteTokenTaskgenerateConsentTaskgenerateDocumentConsentTaskgenerateProcessTokenTaskgenerateProcessTokenTtlTaskdeleteProcessTokenTaskGenerateHashTaskSmsSenderTaskSmsCodeValidationTaskinputProvidedTaskauthorizationUserTaskvalidateTokenTaskgetSocialProfileTaskuserConsentMappingTasksocialUserDataMappingTasksocialProviderRequesterTaskgetUserTaskdeleteUnusedTokensTaskeventPublisherTaskgenerateAuthTokenTaskgenericLookupTasksdUserAuthenticationTaskuserStatusActiveVerifierServiceTaskdeleteUserTasksaveProcessDataTaskgetProcessDataTaskpublishDataTaskIsPasswordSetForUserTaskMoveProcessVariablesTaskConfiguring push notificationsPush notification message templatesImiPushUserNotificationTaskGetImiNotificationStatusTaskImiDeleteAccountsTaskGenerateImiEnrolQrTaskSsoCookieVerifierServiceTaskTestGetImiEnrolmentStatusTaskListeners and eventsProcess End Event ListenerGet Process Purposes ListenerCollect Process Purposes ListenerGet Documents ListenerCollect Documents ListenerAPI validationAPI validator typesConsent GenerationBPMN sub processesConfiguring payloadsConfiguring createScimUserTaskStep input or output validationProfile completion step configurationUse caseBPMN configurationConsul configurationSocial identity linkAdvanced configuration of createScimUserTaskConfiguring updatedScimUserTaskProcess FlowsActivation process flowComplex invitation processTime-based one-time passwordSocial registration flowEnding already existing processes