> For the complete documentation index, see [llms.txt](https://ztrust.gitbook.io/ztrust-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ztrust.gitbook.io/ztrust-documentation/user-manual-ztrust-v4.2/3.-guide-to-navigation/3.2-client-scopes.md).

# 3.2 Client Scopes

#### What is Client Scope in ZTrust?

In **ZTrust**, **Client Scopes** represent a set of permissions, claims, protocol mappers, and role mappings that can be assigned to one or more clients.\
They help avoid duplication by allowing **multiple clients** to use the same configuration.

Client Scopes are particularly useful in **OpenID Connect (OIDC)** and **OAuth2** flows, as they define what information (claims) will be included in tokens such as the **ID token** or **Access token**.

### **Key Features of Client Scopes**

* Group reusable **permissions** and **claims** for multiple clients.
* Avoid duplicate configuration across clients.
* Control what information is included in tokens.
* Assign roles, protocol mappers, and other attributes to tokens.
* Manage claims and transformations easily from a single place.

<figure><img src="/files/aiNygzIgTH9Wxw0VWQwV" alt=""><figcaption><p>Fig 3.2.a: Client scopes list</p></figcaption></figure>

### **Filtering Client Scopes**

You can filter client scopes based on:

* **Name** → Unique name of the client scope.
* **Assigned Type** → Whether the client scope is **Default** or **Optional** for new clients.
* **Protocol** → Defines whether the scope uses **OpenID Connect (OIDC)** or **SAML**.

<figure><img src="/files/7TYif2XLtbTKuEO8hTIL" alt=""><figcaption><p>Fig 3.2 b: Filtering Client Scopes</p></figcaption></figure>

#### Client Scope Attributes:&#x20;

* **Name** : A unique name for the client scope within the realm.
* **Assigned Type:** Defines whether the scope is added **by default** to all new clients or can be added manually.
* **Protocol**: The protocol configuration (**OIDC** or **SAML**) associated with the client scope.
* **Display Order**: Determines the position of the scope in the admin console UI.
* **Description**: A short description of the purpose of the client scope.

<figure><img src="/files/uqwBSHv0B7RF73S5hOXn" alt=""><figcaption><p>Fig 3.2.c: Client Scope Attributes</p></figcaption></figure>

### **Managing Client Scopes**

### **1.Creating a Client Scope**

1. Click on **Create Client Scope**.
2. Fill in the following details:
   * **Name** → Must be unique and cannot contain spaces.
   * **Description** → Purpose of the client scope.
   * **Type** → Choose whether the scope is **Default** or **Optional**.
   * **Protocol** → Select the desired protocol (OIDC/SAML).
   * **Display on Consent Screen** → Enable if you want users to see this scope during consent.
   * **Consent Screen Text** → Text displayed to users during consent (defaults to scope name if empty).
   * **Include in Token Scope** → Enable if you want this scope included in access tokens.
   * **Display Order** → Set the UI display priority.
3. Click **Save** to create the client scope.

<figure><img src="/files/Ws9uTBAD8dAH1MnKbfB0" alt=""><figcaption><p>Fig 3.2.d: Creating a Client Scope</p></figcaption></figure>

#### **What are Protocol Mappers?**

Protocol mappers transform and map data between the **authentication server** and **tokens**.\
They define **which claims** are included in tokens and how user attributes or roles are represented.

#### **Managing Protocol Mappers**

* **Add a New Mapper**
  1. Open a client scope.
  2. Go to the **Mappers** tab.

     <figure><img src="/files/HaQufYGlbDGy7HyAyEqa" alt=""><figcaption><p>Fig 3.2.e: Mappers tab</p></figcaption></figure>
  3. Click **Configure a New Mapper**.

     <figure><img src="/files/kvBKvQfAoBkOMx3LYIsh" alt=""><figcaption><p>Fig 3.2.f.1: Configure a New Mapper.</p></figcaption></figure>

     <figure><img src="/files/vTQVKX6sEgXRDgo2Ne8P" alt=""><figcaption><p>Fig 3.2.f.2: Configure a New Mapper.</p></figcaption></figure>
  4. Select a mapper type (e.g., **User Property**, **Role Name Mapper**, etc.).
  5. Customize settings and click **Save**.
* **Add Predefined Mappers**
  1. Click **Add Predefined Mapper**.

     <figure><img src="/files/oZTcUYaj1mBJJLRHh3Dm" alt=""><figcaption><p>Fig 3.2.g: Add Predefined Mapper</p></figcaption></figure>
  2. Choose from the list of **29 predefined mappers**.
  3. Select the desired mappers and click **Add**.

You can view the same settings here that you previously configured.

If any changes are made and you want to save them, click Save. Otherwise, click Cancel.

**Add to ID Token**

This toggle button controls whether the claim can be added to the ID Token.

When activated (toggled ON), the claim can be included in the ID Token.

Conversely, when deactivated (toggled OFF), the claim is not added to the ID Token.

You can adjust this setting as needed by toggling it ON or OFF.

#### **Add to user info**

This toggle button determines whether the claim should be added to the user info.&#x20;

When activated (toggled ON), the claim will be included in the user info.

If deactivated (toggled OFF), the claim will not be added to the user info.

You can toggle this setting ON or OFF according to your requirements.

#### **Save**

To apply the changes you've made, click on Save.

#### **Cancel**

If you prefer not to incorporate the changes, click on Cancel to discard them.

You can review the table below to observe the various types of mappers and their respective purposes.

<table><thead><tr><th width="224">Mapper Type</th><th>Description</th></tr></thead><tbody><tr><td>Claims parameter Token</td><td>The claims specified by the claims parameter are included in the tokens.</td></tr><tr><td>User Realm Role</td><td>Associate the user realm role with a token claim.</td></tr><tr><td>User Session Note</td><td>Connect a custom user session note to a token claim.</td></tr><tr><td>Claims parameter with value ID Token</td><td>Claims specified with a value by the claims parameter are included in an <a href="/pages/9rnYYTa68pp701vUEqcg#identity-token">ID Token</a>.</td></tr><tr><td>User Address</td><td>Associate user address attributes (street, locality, region, postal_code, and country) with the OpenID Connect ‘address’ claim.</td></tr><tr><td>Role Name Mapper</td><td>Assign a role to a new name or position in the token.</td></tr><tr><td>User Client Role</td><td>Associate a user client role with a token claim.</td></tr><tr><td>User Property</td><td>Map a built-in user property (email, firstName, lastName) to a token claim.</td></tr><tr><td>Authentication Context Class Reference (ACR)</td><td>Assign the achieved <a href="/pages/9rnYYTa68pp701vUEqcg#level-of-authentication-loa">Level of Authentication (LoA)</a> to the ‘acr’ claim of the token.</td></tr><tr><td>Hardcoded Role</td><td>Hardcode a role into the access token.</td></tr><tr><td>Hardcoded claim</td><td>Hardcode a claim into the token</td></tr><tr><td>Pairwise subject identifier</td><td>Generates a pairwise subject identifier using a <a href="/pages/9rnYYTa68pp701vUEqcg#salted-sha-256-hash">salted SHA-256 hash</a>.</td></tr><tr><td>User’s full name</td><td>Associates the user's first and last name with the OpenID Connect 'name' claim.</td></tr><tr><td>Allowed Web Origins</td><td>Includes all permitted web origins in the 'allowed-origins' claim within the token.</td></tr><tr><td>Audience</td><td>Append the specified audience to the 'audience' (aud) field of the token.</td></tr><tr><td>User Attribute</td><td>Connect a custom user attribute with a token claim.</td></tr><tr><td>Group Membership</td><td>Map user group membership.</td></tr><tr><td>Audience Resolve</td><td>Include all client_ids of 'allowed' clients in the audience field of the token. An 'allowed' client refers to a client for which the user has at least one client role.</td></tr></tbody></table>

<figure><img src="/files/aNEdMZt3ZAP7Bn9C5KP7" alt=""><figcaption><p>Fig 3.2.h: Mappers tab</p></figcaption></figure>

<figure><img src="/files/wKVVNR4SkhYG4r8DYugu" alt=""><figcaption><p>Fig 3.2.i: Add predefined mappers</p></figcaption></figure>

You can use the search box to find a specific mapper.&#x20;

Click the Refresh button to see the latest settings.

There are 29 predefined mappers available for you to choose from.

<figure><img src="/files/5gis1RFEmjkIpM44yARA" alt=""><figcaption><p>Fig 3.2.j: Show number of client scopes per page</p></figcaption></figure>

You can also choose how many mappers you want to display on one screen. Select your preferred option from the dropdown menu as shown below.

If you want to select a specific mapper from the predefined mapper list, click on the checkbox for that particular mapper.

This will select the corresponding mapper.&#x20;

At the bottom, there's an option to Add. Click on Add to add the chosen predefined mappers.

<figure><img src="/files/5iTJAd2x2GfbRrLaOUVr" alt=""><figcaption><p>Fig 3.2.k: Adding mapper</p></figcaption></figure>

Once added, the particular mapper will be visible under the Mappers tab, as shown below.

<figure><img src="/files/sy1iejm4nuAKpGNrWNrt" alt=""><figcaption><p>Fig 3.2.l: Mapper added</p></figcaption></figure>

#### **Name**

This displays the names of the existing predefined mappers.

#### **Category**

This section categorizes the mentioned mappers.

#### **Type**

This specifies the type of the predefined mappers.

#### **Priority**

Mapper implementations are prioritized based on their order in the list of mappers.

Priority order is not the configuration property of the mapper. It is the property of the concrete implementation of the mapper.

This order dictates the sequence in which changes to the token or assertion are applied, with the lowest priority mappers being processed first.

This ensures that implementations dependent on others are executed in the required order.

<figure><img src="/files/W3eGIJpEO25x843yfn0s" alt=""><figcaption><p>Fig 3.2.m: Option to delete mapper </p></figcaption></figure>

After clicking on the three dots, you will see an option to delete the specific mapper.

If you wish to delete that particular mapper, click on Delete.

<figure><img src="/files/uuyl6eDvf4OJl8mXm7te" alt=""><figcaption><p>Fig 3.2.n: To add new mappers</p></figcaption></figure>

<figure><img src="/files/G6edjRAQt7G3N5uiJ8eF" alt=""><figcaption><p>Fig 3.2.o: Scopes page</p></figcaption></figure>

#### **Scope**

This configuration enables you to limit the user role mappings included in the access token requested by the client.

To assign roles, select Assign role.&#x20;

Upon clicking this, you will be presented with the prompt shown below.

<figure><img src="/files/74uLtcTM8rlZZeV0ZoPH" alt=""><figcaption><p>Fig 3.2.p: Realm roles</p></figcaption></figure>

<figure><img src="/files/7hnXO5ZWC7wa49ouys97" alt=""><figcaption><p>Fig 3.2.q: Assign roles to demo</p></figcaption></figure>

Here, you can filter roles based on clients or realm roles.

<figure><img src="/files/vltAFEz36xNGbuBJUwUG" alt=""><figcaption><p>Fig 3.2.r: List of realm roles</p></figcaption></figure>

If you want to select a specific role from the list, click on the checkbox for that particular role.

This will select the corresponding role.&#x20;

At the bottom, there's an option to Assign. Click on Assign to add the chosen roles.

Once added, the particular role will be visible in the scope list, as shown below.

<figure><img src="/files/CQnlJv5LwFy0p5S3cXWn" alt=""><figcaption><p>Fig 3.2.s: Assigned roles</p></figcaption></figure>

#### **Name**

It includes the list of all the different roles that are already assigned to this client.

#### **Inherited**

This pertains to roles explicitly assigned to users and those inherited from composite roles. It can have two values: True (indicating the role is inherited from composites) or False (indicating it is not inherited from any composite role).

#### **Description**

It refers to the description for the role which will aid you in identifying its purpose.

This field can be localized by specifying a substitution variable with **${var-name}** strings.

<figure><img src="/files/lmvJDY6CIL5StnhPulKg" alt=""><figcaption><p>Fig 3.2.t: Opition to unassign </p></figcaption></figure>

By clicking on the three dots, you can access the option to unassign. If a role is no longer needed for any client, simply click on Unassign.

Upon clicking Unassign, you will receive a confirmation prompt. To remove a specific role, click Remove; otherwise, click Cancel.

If you wish to unassign multiple roles, simply click on the checkbox next to each role you want to select. Once selected, click on Unassign to proceed.

You will receive the following prompt requesting confirmation.

<figure><img src="/files/UA9GKxJt7zDUJbUBWW1P" alt=""><figcaption><p>Fig 3.2.u: Conformation to remove role</p></figcaption></figure>

To remove a specific role, click Remove; otherwise, click Cancel.

#### **Hide inherited roles**

Selecting this checkbox hides inherited roles, preventing you from seeing roles inherited from composites.&#x20;

To view inherited roles, simply uncheck this option.

<figure><img src="/files/F9NvKoMJQYLGyFZvBK2f" alt=""><figcaption><p>Fig 3.2.v: List of available roles display per page</p></figcaption></figure>

You can also choose how many roles you want to display on one screen. Select your preferred option from the dropdown menu as shown above.

You can search for any specific role by using the search box.

Click the Refresh button to see the latest settings.

<figure><img src="/files/RVTCfK2dNisenHjsNrUk" alt=""><figcaption><p>Fig 3.2.w: Opition to delete client scope</p></figcaption></figure>

You can also delete the entire client scope by clicking on Action at the top right corner and selecting Delete.

Upon clicking Delete, you will receive the following prompt requesting confirmation.&#x20;

<figure><img src="/files/InepINPxi3WupSrZAYG4" alt=""><figcaption><p>Fig 3.2.x: Conformation to delete the client scope</p></figcaption></figure>

Click Delete to proceed with the removal, or click Cancel to retain it.
