Iframe Support For Trust Web

Introduction

For customers who wish to embed TrustX in an iframe this guide will describe the necessary steps to follow.

Iframe Permissions

In accordance with security best practices TrustX does not allow iframes to embed the web application. Embedding within an iframe is forbidden to prevent bad actors from appearing to host TrustX in their own websites.

In order for TrustX to be embedded in an iframe an update must be made to TrustX's Content Security Policy.

As TrustX is a multi-tenant system, support for iFrame is configured on a tenant by tenant basis. That is, TrustX's Content Security Policies must be altered to enable iframe support. This Content Security Policy generated on a per tenant basis to add only specific hosts as requested by a tenant.

To enable iframe support, set set the trusted iframes from the System Management Settings.

For more information, see the Self Service System Management guide.

A Content Security Policy (CSP) is a security feature that helps prevent a variety of attacks, including Cross-Site Scripting (XSS) and data injection attacks. It is implemented via a special HTTP header that the server sends to the client.

The CSP defines which resources the user agent (typically a web browser) is allowed to load for a given page. This could include scripts, stylesheets, images, and more. By restricting the resources that a user agent can load, the CSP can help to prevent malicious content from being loaded and executed.

For example, a CSP can specify that all scripts on a page must be loaded from the same domain as the page itself, or from a specific list of trusted domains. If an attacker tries to inject a script that loads from a different domain, the user agent will refuse to load it.

For more information please see https://cheatsheetseries.owasp.org/cheatsheets/HTTP_Headers_Cheat_Sheet.html#content-security-policy-csp

Embedding TrustWeb in an Iframe

This section will demonstrate the correct configuration required to embed TrustWeb within an iframe.

The first requirement for integration is the Process Token URL. This can be achieved from the Process Definition page in the Backoffice.

  1. Find the Process Definition and expand the the options to add a new token.
  1. Click on the 'key' icon to generate a token to be used within the iFrame. The token can also be generated programmatically using the APIs, see: Process Definition Tokens Guide.
  1. Copy the Process Token URL. This will be used to embed TrustWeb in an iframe.
  2. In the HTML file of your application, add a new <iframe> element and set the src to the Process Token URL.
  3. The allow = "camera" permission ensures that camera permissions required to complete an ID&V flow in Trust Web is granted within the iframe. Note, if your process definition does not perform document or face capture then allow "camera" permission is not required.
HTML
Copy

Example:

HTML
Copy

When using face capture v2 or document capture v4, it is also required to allow gyroscope and accelerometer permissions.

Example:

HTML
Copy

If the Process Token URL is not correct passed inside the iframe, Trust Web will not appear.

Handling Events

When embedding TrustWeb in an iframe, TrustX will communicate to the parent frame via window messages where each message will have an event and data. These events will occur at the end of the Process Instance.

Possible event types include the following:

EventDescription
webCompletedIndicates the completion of the TrustX flow.
webTimeoutIndicates that an activity has expired during the TrustX flow.
errorIndicates an error has occurred.

The example below demonstrates the alerts that are shown when TrustX sends a message to the enclosing iframe.

Example:

HTML
Copy

The code sample above uses a Javascript switch statement to handle each possible event. For the webCompleted case, the presence of a message indicates that the completed process is in the 'Review' status. Otherwise, webCompleted will not return a message.

Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard