# Microsoft Entra ID Authentication

{% hint style="warning" %}
Azure Active Directory (Azure AD) has been renamed to **Microsoft Entra ID** (**ME-ID**). While the WorkflowGen documentation has been updated to reflect this name change, the WorkflowGen application settings still refer to Azure AD (for example, `Azure AD SCIM v2` directory connector).&#x20;

Likewise, certain ME-ID configuration items in the Azure portal have been renamed and/or moved. The WorkflowGen documentation has been updated accordingly, but still might not be completely accurate in this regard. See the [Microsoft Entra ID](https://learn.microsoft.com/en-us/entra/identity/) documentation for more information.
{% endhint %}

## Overview

This section provides instructions on how to configure WorkflowGen delegated authentication with Microsoft Entra ID (ME-ID) authentication via the **Microsoft Identity Platform v2.0** or **API endpoint v1** providers, and will show you how to set up a working WorkflowGen instance that uses ME-ID to authenticate your users.

{% hint style="info" %}
In the instructions, substitute `<workflowgen url>` with the domain and path to your WorkflowGen instance; for example, `localhost/wfgen` or `www.mycompany.com/wfgen`.
{% endhint %}

## Prerequisites

* Make sure to have a licensed copy of WorkflowGen installed and running on an IIS web server in **HTTPS** secure connection mode.
* You must be a **WorkflowGen Administrator**.
* Make sure to have **ME-ID Administrator access** to be able to configure ME-ID.
* Make sure to have provisioned an existing ME-ID user that you can authenticate with WorkflowGen and that the user has **WorkflowGen Administrator** permissions. This is important because once you've activated the delegated authentication with ME-ID, you'll still need to be able to manage the WorkflowGen web application.
* AES encryption mode and its key are required for the authentication to work.

## Microsoft Entra ID configuration

The configuration of ME-ID is done in two parts. First, you have to register the WorkflowGen web application and link it to your instance of WorkflowGen; then, you have to register the WorkflowGen GraphQL API in order to be able to register other custom applications to access it.

### Step 1: Create a new application registration for WorkflowGen

1. In the Azure portal, click **App registrations** in the **Azure services** section.<br>
2. Click **New registration**, and fill in the properties form:
   * **Name:** `WorkflowGen Web app` &#x20;
   * **Supported account type:** `Account in this organizational directory only (Default Directory only - Single tenant)`&#x20;

     ✏️ **Note:** Depending on the context, you should choose the right option for your use case for the **Supported account type** value.
   * **Redirect URI:**&#x20;

     * **Platform:** `Web`
     * **Value:** `https://<workflowgen url>/auth/callback` &#x20;

     📌 **Example:** `https://mycompany.com/wfgen/auth/callback`<br>
3. Click **Register** at the bottom of the page.

You should now see the `WorkflowGen Web app` application registration's overview page.

### Step 2: Create a client secret for the application

Now, you have to generate a **client secret** to be used by the WorkflowGen OIDC authentication module.

1. Click **Add a certificate or secret**.<br>
2. In the **Client secrets** section, click **New client secret**.
   * **Description**: `My secret`, or something to know that this is the client secret.
   * **Expires**: Choose **730 days (24 months)** or your desired expiration period.<br>
3. Click **Add**.<br>
4. The auto-generated client secret is now displayed under the **Value** column. Copy the client secret value and save it somewhere safe, since you won't be able to retrieve it afterwards.

{% hint style="warning" %}
It's no longer possible to set client secrets to **never** expire. You'll need to manually regenerate a new client secret every two years (if the **24 months** option was selected) before it expires. Then, update the client secret used by WorkflowGen instance in its web configuration file (**`ApplicationSecurityAuthClientSecret`** key).
{% endhint %}

### Step 3: Add a redirect URI

In order for the communication between the WorkflowGen instance and ME-ID to work, you need to add one more authorized redirect URI to the `WorkflowGen Web app` application registration.

1. Under **Redirect URIs** on the application's overview page, click **Add a Redirect URI**.<br>
2. Enter the following information:
   * **Redirect URI**: `https://<workflowgen url>/auth/logout/return` \
     📌 **Example:** `https://mycompany.com/wfgen/auth/logout/return`\
     ✏️ **Note:** You should also see `https://<workflowgen url>/auth/callback` in this list.<br>
3. Click **Save** at the bottom of the section.

### Step 4: Create a new application registration for WorkflowGen GraphQL API

{% hint style="info" %}
If you don't need WorkflowGen GraphQL API access, you can skip this application registration and configuration in Azure (**steps 4 through 6**). In this case, continue the configuration procedure from [Review the registrations](#review-the-registrations) through [WorkflowGen configuration](#workflowgen-configuration) completely. Finally, follow the configuration in the [Configuring the authentication without the GraphQL API](#configuring-the-authentication-without-the-graphql-api) section.
{% endhint %}

In order to expose the WorkflowGen GraphQL API, you need to add a new application registration in ME-ID that will represent it. To do this:

1. In the Azure portal, click **App registrations** in the **Azure services** section.<br>
2. Click **New registration**, and fill in the properties form:
   * **Name:** `WorkflowGen GraphQL API` &#x20;
   * **Supported account type:** `Account in this organizational directory only (Default Directory only - Single tenant)`&#x20;
   * **Redirect URI**: Leave this blank.<br>
3. Click **Register** at the bottom of the page.

You've now successfully registered the `WorkflowGen GraphQL API` application in ME-ID.

### Step 5: Expose the API in the WorkflowGen GraphQL API application registration

1. Click **Expose an API**.

2. To the right of **Application ID URI**, click **Set** and enter the URI `https://<workflowgen url>/graphql`\
   📌 **Example:** `https://mycompany.com/wfgen/graphql`

3. Click **Save**.<br>

4. Click **Add a scope** and enter the following information:

   * **Scope name:** `default`
   * **Who can consent?:** `Admins and users`
   * **Admin consent display name:** `Default access to the WorkflowGen GraphQL API`
   * **Admin consent description:** `Allows the application to get access to WorkflowGen GraphQL API.`
   * **User consent display name:** `Default access to the WorkflowGen GraphQL API`
   * **User consent description:** `Allows the application to get access to WorkflowGen GraphQL API.`

5. Click **Add scope**.

You should now have a new scope defined (e.g. `https://<workflowgen url>/graphql/default`).

{% hint style="warning" %}
Since October 2021, the use of a default schema or a verified domain for the AppId URL on a single tenant application (see the Microsoft documentation [here](https://learn.microsoft.com/en-us/azure/active-directory/develop/reference-breaking-changes#appid-uri-in-single-tenant-applications-will-require-use-of-default-scheme-or-verified-domains) for more information) is required.\
\
The Microsoft documentation on how to add and verify a custom domain is available [here](https://learn.microsoft.com/en-us/azure/active-directory/enterprise-users/domains-manage).
{% endhint %}

### Step 6: Grant WorkflowGen access to WorkflowGen GraphQL API

1. On the `WorkflowGen Web app` application registration page, click **API permissions**.<br>
2. Click **Add a permission**, then select the tab **My APIs**.<br>
3. Click the `WorkflowGen GraphQL API` application in the list.<br>
4. Click **Delegated permissions** and check `default` under the **Permission** column.<br>
5. Click **Add permissions**.<br>
6. On the **API permissions** page, click **Grant admin consent for \<your tenant name>**, then click **Yes**.

### Review the registrations

You should now have all of the information you need to configure your WorkflowGen instance to delegate authentication to Microsoft Entra ID Here's a review:

* A **client ID**. This is the application (client) ID of the `WorkflowGen Web app` application registration in ME-ID. You can find it on its **Overview** page.
* A **client secret**. This is the secret previously generated in **step 2** for the `WorkflowGen Web app`.
* An **audience**. This is the `Application ID URI` property (e.g. `https://<workflowgen url>/graphql`) in the **Expose an API** section of the `WorkflowGen GraphQL API` application registration.
* The **metadata endpoint URL**. This URL is bound to your ME-ID directory. To find it:
  1. Go to the **Overview** page and opy the `Tenant ID` value.
  2. The metadata endpoint URL is built by replacing `<Tenant ID>` with your **Tenant ID** as follows: \
     \
     **For Microsoft Identity Platform v2.0 (recommended):**

     ```
     https://login.microsoftonline.com/<Tenant ID>/v2.0/.well-known/openid-configuration
     ```

     \
     **For Azure v1:**

     ```
     https://login.microsoftonline.com/<Tenant ID>/.well-known/openid-configuration
     ```

By now, you should have all the information needed to link your WorkflowGen instance to ME-ID.

## WorkflowGen configuration

Now, you have to configure WorkflowGen to delegate its authentication to ME-ID.

### Step 1: Add Microsoft Entra ID values to the WorkflowGen `web.config`

1. Open the WorkflowGen `web.config` file and add and/or update the following properties under `<appSettings>`\
   \
   **For Microsoft Identity Platform v2.0 (recommended):**

   ```markup
   <!-- Microsoft Identity Platform v2 -->
   <add key="ApplicationSecurityAuthProvider" value="ms-identity-v2"/>
   <add key="ApplicationSecurityAuthClientId" value="<CLIENT ID>" />
   <add key="ApplicationSecurityAuthClientSecret" value="<CLIENT SECRET>" />
   <add key="ApplicationSecurityAuthMetadataUrl" value="<METADATA URL>" />
   <add key="ApplicationSecurityAuthAppIdClaim" value="appid" />
   <add key="ApplicationSecurityAuthUsernameClaim" value="preferred_username" />
   <add key="ApplicationSecurityAuthClockTolerance" value="60" />
   <add key="ApplicationSecurityAuthSessionRefreshEnableIFrame" value="Y"/>
   <add key="ApplicationSecurityAuthAccessTokenUsernameClaim" value="upn" />
   <add key="ApplicationSecurityAuthAdditionalScopes" value="https://<workflowgen url>/graphql/default" />
   ```

   \
   **For Azure v1:**

   ```markup
   <!-- Azure v1 auth -->
   <add key="ApplicationSecurityAuthProvider" value="azure-v1"/>
   <add key="ApplicationSecurityAuthClientId" value="<CLIENT ID>" />
   <add key="ApplicationSecurityAuthClientSecret" value="<CLIENT SECRET>" />
   <add key="ApplicationSecurityAuthMetadataUrl" value="<METADATA URL>" />
   <add key="ApplicationSecurityAuthAppIdClaim" value="appid" />
   <add key="ApplicationSecurityAuthUsernameClaim" value="upn" />
   <add key="ApplicationSecurityAuthClockTolerance" value="60" />
   <add key="ApplicationSecurityAuthSessionRefreshEnableIFrame" value="Y"/>
   <add key="ApplicationSecurityAuthCheckSessionUrl" value="<CHECK SESSION URL>" />
   ```

   \
   ✏️ **Note:** Check session iFrame (e.g. `ApplicationSecurityAuthCheckSessionUrl`) is not supported in **Microsoft Identity Platform v2.0**.<br>

2. Replace `<CLIENT ID>` with the `WorkflowGen Web app` application (client) ID from ME-ID.<br>

3. Replace `<CLIENT SECRET>` with the `WorkflowGen Web app` application registration's generated secret from ME-ID.<br>

4. Replace `<METADATA URL>` with the metadata endpoint URL that you built earlier from your ME-ID's `Tenant ID` value.<br>

5. For **Microsoft Identity Platform v2.0**, replace `<workflowgen url>` with your WorkflowGen URL in the value of the **`ApplicationSecurityAuthAdditionalScopes`** key (e.g. `https://mycompany.com/wfgen/graphql/default`) if you have configured the `WorkflowGen GraphQL API` application registration (**steps 4 through 6**). Otherwise, remove the **`ApplicationSecurityAuthAdditionalScopes`** key completely.

6. For **Azure v1**, replace `<CHECK SESSION URL>` (which is usually `https://login.microsoftonline.com/<Tenant ID>/oauth2/checksession`) with the value of the metadata endpoint's `check_session_iframe` property. To do this, you'll have to make an HTTP GET request to your metadata endpoint URL (e.g. `https://login.microsoftonline.com/<Tenant ID>/.well-known/openid-configuration`), then copy and paste the value. See the examples below on how to request the metadata endpoint.<br>

   **Linux/macOS request example:**

   ```
   curl "<METADATA URL>" | python -m json.tool
   ```

   \
   ✏️ **Note:** Remove `| python -m json.tool` if you don't have Python; this is for pretty printing.<br>

   **Windows PowerShell request example:**

   ```
   Invoke-RestMethod -Uri "<METADATA URL>" -Method GET | ConvertTo-JSON
   ```

**Table of `web.config` options**

| **Option**                                          | **Description**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| --------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ApplicationSecurityAuthProvider`                   | The name of the identity provider supported by WorkflowGen. At this time, there is support only for Microsoft Entra ID, Microsoft Identity Platform v2.0, Auth0, AD FS, and Okta. Value: `azure-v1`, `ms-identity-v2`,`auth0`, `adfs`, or`okta`                                                                                                                                                                                                                                                                                    |
| `ApplicationSecurityAuthClientId`                   | Each identity provider generates a code that uniquely identifies your application. In this case, this is the code that uniquely identifies the `WorkflowGen Web app` application in ME-ID.                                                                                                                                                                                                                                                                                                                                         |
| `ApplicationSecurityAuthClientSecret`               | Like the client ID, this is also generated by the identity provider, but it is more like what a password is for a user. It's important to keep this secret because malicious software that has access to this can act on the behalf of the application. This value must be explicitly generated in ME-ID.                                                                                                                                                                                                                          |
| `ApplicationSecurityAuthMetadataUrl`                | The endpoint provided by the identity provider that supports the [OpenID Connect Discovery](https://openid.net/specs/openid-connect-discovery-1_0.html) standard. It enables WorkflowGen to get some public information about your ME-ID domain. Without this, you'll have to manually enter much more configuration in the `web.config`. Take note that the metadata endpoint URL is different for **Microsoft Identity Platform v2.0** and **Azure v1**.                                                                         |
| `ApplicationSecurityAuthAppIdClaim`                 | <p>The name of the claim contained in the access token obtained from the identity provider that uniquely identifies a non-interactive client. This is only used if you have a machine-to-machine application that needs to have access to the GraphQL API. To configure this, see the <a href="azure-active-directory-configuration-for-single-page-applications">Azure Active Directory configuration for single-page applications </a>section. <br><br>✏️ <strong>Note:</strong> It's recommended to keep the default value.</p> |
| `ApplicationSecurityAuthUsernameClaim`              | <p>The name of the claim contained in the access token that identifies the user in WorkflowGen. This is used by WorkflowGen to generate a session token as well as by the GraphQL API when receiving an access token.<br><br>✏️ <strong>Note:</strong> It's recommended to keep the default value.</p>                                                                                                                                                                                                                             |
| `ApplicationSecurityAuthAccessTokenUsernameClaim`   | <p>This is used by the GraphQL API when receiving an access token.</p><p></p><p>✏️ <strong>Note:</strong> It's recommended to keep the default value.</p>                                                                                                                                                                                                                                                                                                                                                                          |
| `ApplicationSecurityAuthClockTolerance`             | <p>This value is used when verifying a token in WorkflowGen. It's essentially to deal with minor differences between servers' clocks.<br><br>✏️ <strong>Note:</strong> It's recommended to keep the default value.</p>                                                                                                                                                                                                                                                                                                             |
| `ApplicationSecurityAuthSessionRefreshEnableIFrame` | <p>When enabled (<code>Y</code>), this option activates the session auto-refresh feature using an invisible <code>\<iframe></code>. This allows users to enter their password less often by refreshing their session in the background while they're working. </p><p></p><p>✏️ <strong>Note:</strong> This option is only available when using WorkflowGen with OIDC authentication.</p>                                                                                                                                           |

WorkflowGen should now be linked to your ME-ID. The last thing left to do is to configure a few more options in order to finish the internal wiring of WorkflowGen so that it can delegate its authentication.

### Step 2: Add security values for the WorkflowGen session token generation

WorkflowGen uses an internal session token to manage the user session and identify the current user for all the HTTP requests made to the web application after the user has logged in to ME-ID. In order to generate a session token, you need to add a few more settings to the `web.config`.

1. Open the WorkflowGen `web.config` file and add and/or update the following property under `<appSettings>`:

   ```markup
   <add key="ApplicationSecurityAuthSessionTokenSigningSecret" value="<SECRET>" />
   ```
2. Replace `<SECRET>` with a custom value that can't be guessed, such as a **UUID** or a **complex password**.

The secret will be only accessible inside your instance of WorkflowGen, so when generating a session token, WorkflowGen will sign it with this secret in order to check the validity of all session tokens passed to it.

### Step 3: Activate the authentication delegation module

You now need to activate the delegation by replacing the authentication system in IIS and pointing WorkflowGen's modules to the correct authentication module.

#### **Configure IIS**

1. In IIS Manager, click on the WorkflowGen website in the tree view.<br>

2. Click the **Authentication** button.

3. Enable **Anonymous Authentication**, and **disable** all other authentications.<br>

4. Perform these steps for all sub-applications as well.

#### **Add properties to the `web.config` files of sub-applications**

Certain **sub-applications** need to have their authentication checked by the special `Advantys.Security.JWTAuthenticationModule` WorkflowGen authentication module, but certain other sub-applications (such as `/wfgen/auth`, `/wfgen/hooks` and `/wfgen/scim`) should not because they are either public or aren't part of the global authentication system.

1. Add the following property to the WorkflowGen `web.config` file:

   ```markup
   <configuration>
    <system.webServer>
        <modules>
            <add name="ApplicationSecurityAuthenticationModule" type="Advantys.Security.Http.JWTAuthenticationModule" />
        </modules>
    </system.webServer>
   </configuration>
   ```
2. If you have developed custom web forms with their own `\bin` folders, you have to copy the following .NET assemblies and dependency libraries from `\wfgen\bin` to each custom web form's `\bin` folder (`\wfgen\wfapps\webforms\<custom webform>\bin`):
   * `Advantys.My.dll`
   * `Advantys.Security.dll`
   * `Newtonsoft.Json.dll`
   * `jose-jwt.dll`

{% hint style="warning" %}
If you skipped the [WorkflowGen GraphQL API application registration](#step-4-create-a-new-application-registration-for-workflowgen-graphql-api) steps earlier, it is required to apply the configuration in the [Configuring the authentication without the GraphQL API](#configuring-the-authentication-without-the-graphql-api) section.
{% endhint %}

{% hint style="success" %}
You should now have a working WorkflowGen instance with the authentication delegated to Microsoft Entra ID through the OpenID Connect protocol. Make sure to have provisioned your users to WorkflowGen in order for them to successfully access WorkflowGen.
{% endhint %}

## Calling third-party APIs with the shared access token

{% hint style="info" %}

* This method is only supported with the **Microsoft Identity Platform v2.0** provider (e.g. `ms-identity-v2`).
* Your third-party APIs must support an access token (JWT) for authentication and be able to validate the user by verifying the access token's content.
  {% endhint %}

{% hint style="warning" %}
This configuration does have some drawbacks. For example, the [WorkflowGen Plus v2](https://docs.workflowgen.com/azure/8.0/azure-active-directory-configuration-for-mobile-apps#overview) mobile application **will not be compatible** with this setup.
{% endhint %}

By default, the only recipient of the access token is the `WorkflowGen GraphQL API` application. This means that the access token can only be used to send queries to the GraphQL API only. In order to use the same access token to call your own APIs from WorkflowGen (e.g. web forms), you will need to perform the following steps in your Azure portal, and then modify the WorkflowGen `web.config` file.

### In your Azure portal:

#### Step 1: Add a new application registration that represents all your APIs

1. In the Azure portal, click **App registrations** in the **Azure services** section.<br>

2. Click **New registration**, and fill in the properties:

   * **Name:** `My APIs` &#x20;
   * **Supported account types:** `Account in this organizational directory only (Default Directory only - Single tenant)` \
     ✏️ **Note:** Depending on the context, you should choose the right option for your use case for the **Supported account type** value.
   * **Redirect URI:** Leave this blank

3. Click **Register** at the bottom of the page.

#### Step 2: Expose your APIs in the registration

1. Click **Expose an API**.<br>

2. To the right of **Application ID URI**, click **Set** and enter the URI `api://my-apis`.

3. Click **Save**.<br>

4. Click **Add a scope** and enter the following information:

   * **Scope name:** `wfgen-graphql-full-access`
   * **Who can consent?:** `Admins and users`
   * **Admin consent display name:** `Full access to the WorkflowGen GraphQL API`
   * **Admin consent description:** `Allows the application to get access to WorkflowGen GraphQL API.`
   * **User consent display name:** `Full access to the WorkflowGen GraphQL API`
   * **User consent description**: `Allows the application to get access to WorkflowGen GraphQL API.`

5. Click **Add scope**.

6. Add any other scopes that seem necessary for your other APIs.

#### Step 3: Add an application role

1. Click **Manifest**.

2. Find the `appRoles` JSON property and add the following JSON object to the JSON array:

   ```javascript
   {
     "allowedMemberTypes": [
       "Application"
     ],
     "description": "Allows the application to get access to WorkflowGen GraphQL API.",
     "displayName": "wfgen-graphql-full-access-role",
     "id": "<NEW ID>",
     "isEnabled": true,
     "lang": null,
     "origin": "Application",
     "value": "wfgen-graphql-full-access-role"
   }
   ```

   ✏️ **Note:** Replace `<NEW ID>` with the value generated by the `[guid]::NewGuid().ToString()` PowerShell command or use any GUID generators.

3. Click **Save**.

#### Step 4: Grant WorkflowGen access to `My APIs` application

1. On the `WorkflowGen Web app` application registration page, click **API permissions**.

2. In the **Configured permissions** section, click **Add a permission**.<br>

3. Click **My APIs**, then select the `My APIs` application in the list.<br>

4. Click **Delegated permissions** and check `wfgen-graphql-full-access` under the **Permission** column.<br>

5. Click **Add permissions**.<br>

6. On the **API permissions** page, click **Grant admin consent for \<your tenant name>**, then click **Yes**.

#### Step 5 (optional): Grant your automated applications in Azure (client credentials flow) access to the `My APIs` application

For each of your automated applications in Azure (e.g. server-side script, background service, or application) that requires access to the `My APIs` application, do the following:

1. Go to the application's registration page, then click **API permissions**.

2. In the **Configured permissions** section, click **Add a permission**. <br>

3. Click **My APIs**, then select the `My APIs` application in the list.<br>

4. Click **Application permissions** and check `wfgen-graphql-full-access-role` under the **Permission** column.<br>

5. Click **Add permissions**.<br>

6. On the **API permissions** page, click **Grant admin consent for \<your tenant name>**, then click **Yes**.

### In the WorkflowGen `web.config` file:

Open the WorkflowGen `web.config` file, add and/or update the following application settings, then save the file:

```markup
<add key="ApplicationSecurityAuthAudience" value="api://my-apis"/>
<add key="ApplicationSecurityAuthAdditionalScopes" value="api://my-apis/wfgen-graphql-full-access" />
<add key="ApplicationSecurityAuthGraphQLScope" value="wfgen-graphql-full-access" />
<add key="ApplicationSecurityAuthGraphQLAppRole" value="wfgen-graphql-full-access-role" />
```

{% hint style="info" %}
You also need to define any additional scopes in the **`ApplicationSecurityAuthAdditionalScopes`** key that refer to the other APIs you defined in **step 2** of the Azure portal steps above. The scopes must be separated by a comma.
{% endhint %}

### .NET Web Forms Access Token Helper

The `WorkflowPage` class in the `WorkflowGen.My` library provides a public `CurrentUserAccessToken` method to easily retrieve the current user's shared access token that can be used to query the GraphQL API and your third-party APIs. See the snippet code below.

```csharp
protected void Page_Load(object sender, EventArgs e)
{
    base.Page_Load(sender, e);

    string accessToken = this.CurrentUserAccessToken();

    // Use accessToken to query GraphQL API or your third-party APIs...
}
```

## Additional information

## SOAP services support

WorkflowGen only supports requests to the SOAP API using classic authentication methods. If you still need to use this API, you have to perform some additional steps to configure it properly:

1. Create a new separate WorkflowGen directory (i.e. users and groups) for the SOAP API users.<br>
2. Provision it with users and groups as needed.<br>
3. In **IIS Manager**, enable the **Basic** authentication method for the `\wfgen\ws` application.<br>
4. In the `web.config` file (located in `\Inetpub\wwwroot\wfgen`), add the following under  `<location path="ws" inheritInChildApplications="false">` :&#x20;

   ```markup
   <system.webServer>
       <modules>
           <remove name="ApplicationSecurityAuthenticationModule" />
       </modules>
   </system.webServer>
   ```

### About session management

Microsoft Entra ID supports [OpenID Connect Session Management](https://openid.net/specs/openid-connect-session-1_0.html), an extension draft standard, in addition to the core OpenID Connect standard. This standard defines the rules to handle SSO session of the provider from the client. An example use is that if a user logs out of their ME-ID session from any device, a regular web client will receive a message that enables it to remove the same user's local session. WorkflowGen supports this feature when activating delegated authentication with ME-ID.

### Configurable options

{% hint style="info" %}
For a complete list of configurable options, see the [Web and Application Configuration Parameters](https://docs.advantys.com/workflowgen-technical-reference-guide/v/8.0.0/appendix-web-and-application-configuration-parameters) appendix in the [WorkflowGen Technical Guide](https://docs.advantys.com/workflowgen-technical-reference-guide/v/8.0.0/).
{% endhint %}

This table lists all configurable options in WorkflowGen that you can use to customize your authentication experience; these are located in the WorkflowGen `web.config` file.

| **Option**                                    | **Description**                                                                                                                                                                                                                                                                                                                                         |
| --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ApplicationSecurityAuthSessionTokenCookie`   | <p>The name of the session cookie that is generated by the authentication module. <br><br><strong>Default:</strong> <code>wfgen\_token</code> <br><br>✏️ <strong>Note:</strong> This is useful when you have multiple instances of WorkflowGen running and you want to have access to both and be authenticated on both instances at the same time.</p> |
| `ApplicationSecurityAuthSessionTimeOut`       | <p>The duration of the session in seconds. It defaults to the ID token expiration time received. <br><br><strong>Default:</strong> The exp value of the ID token</p>                                                                                                                                                                                    |
| `ApplicationSecurityAuthMobileSessionTimeOut` | <p>The duration of the session in seconds when requested from mobile devices on the token endpoint. <br><br><strong>Default:</strong> 7200 seconds</p>                                                                                                                                                                                                  |
| `ApplicationSecurityAuthAudience`             | <p>The intended recipient of the access token (e.g. the target API).</p><p></p><p><strong>Default:</strong> <code>https\://\<workflowgen url>/graphql</code></p>                                                                                                                                                                                        |
| `ApplicationSecurityAuthAdditionalScopes`     | <p>Additional scopes to add to the authentication request. They will appear in the access token content.</p><p></p><p>✏️ <strong>Note:</strong> The <code>openid</code>, <code>profile</code>, and <code>email</code> scopes are always in the request.</p>                                                                                             |
| `ApplicationSecurityAuthGraphQLScope`         | Custom GraphQL scope value that will be verified when validating the authorized scopes in the access token returned from the OIDC provider.                                                                                                                                                                                                             |
| `ApplicationSecurityAuthGraphQLAppRole`       | <p>Custom GraphQL application role value that will be verified when validating the roles in the access token returned from the OIDC provider in a client credentials flow.</p><p></p><p>✏️ <strong>Note:</strong> Only available for the <code>ms-identity-v2</code> provider.</p>                                                                      |

### Current limitations

If the WorkflowGen User Portal or Administration Module is displayed without the main header menu, this feature will not work. For example, this scenario could occur when the portal home page or a request follow-up form is displayed inside an iFrame in an external solution.

### Configuring the authentication without the GraphQL API

If for some reason you can't register the `WorkflowGen GraphQL API` application and you don't need GraphQL API authentication configured with the provider, you can avoid creating the registration and configure WorkflowGen with the **Microsoft Graph API** instead, which is included by default in all application registrations. To configure it, you only have to change some configuration options in the `web.config` file:

```markup
<configuration>
    <appSettings>
        <add key="ApplicationSecurityAuthAudience" value="https://graph.microsoft.com"/>
        <add key="ApplicationSecurityAuthDecodeAccessToken" value="N"/>
    </appSettings>
</configuration>
```

1. Change the `ApplicationSecurityAuthAudience` key to the **Microsoft Graph API URL**, e.g.`https://graph.microsoft.com`.<br>
2. Set the `ApplicationSecurityAuthDecodeAccessToken` option to `N`.

{% hint style="warning" %}

* Keep in mind that by setting `ApplicationSecurityAuthDecodeAccessToken=N`, the expiration date of the session token generated by WorkflowGen will be based on that of the ID token.<br>
* You won't be able to use the access token received from ME-ID to query the GraphQL API. This access token will give you access to the Microsoft Graph API and nothing else. To query the GraphQL API, you'll need to configure its authentication with another method, like Basic authentication.
  {% endhint %}
