# Claims-based identity provisioning: users, Account access and user groups

## Claims-based Account access and User Group provisioning in Exivity

In the case of large organizations with a large number of users that log in through SSO, giving [Account](https://olddocs.exivity.io/reports/accounts) access to each one of them or assigning them to a [group](https://olddocs.exivity.io/administration/user-management/groups), quickly becomes an intensive manual labour. To avoid this, Exivity implemented a mechanism that automatically assigns appropriate permissions to SAML2 users. For example, users will have [Metadata](https://olddocs.exivity.io/data-pipelines/metadata) applied (such as *Security Groups* memberships), which could be leveraged to automatically give each user access to the appropriate *Account(s)* in Exivity.  Apart from Account level Access,  the Exivity Group membership can also be provisioned automatically, without the need for any manual intervention from an Administrator.

## Claims-based identity & SAML2

A claim is a statement that one subject, such as a user or organization, makes about itself. For example, the statement can be about a name, group, privilege, association or capability.  Claims are held in an authentication token which is then used to authenticate against multiple applications. Apart from enhanced security, a claims-based identity has the potential to simplify authentication logic for large amounts of users that require account provisioning and configuration across multiple applications.

SAML works by exchanging user information, such as identifiers, and other relevant attributes between the Identity Provider (IdP) and Service Provider(SP). As a result, it optimizes and secures the authentication process as the user only needs to log in once with a single set of authentication credentials. When the user tries to access a website (SP), the IdP passes the SAML authentication to the SP, who then grants the user entry and access to its resources. The diagram below exemplifies the SAML2 flow between Exivity and the IdP:

![SAML2 flow between Exivity and the IdP](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRZvuYYNyI3vz1mar1l4%2Fuploads%2FuWSpTVuIZdcpN98IYxEZ%2Fsaml2.png?alt=media\&token=813fd31c-8a6d-4e2d-8314-4635392818df)

## Tutorial: configure claims-based identity and Account access provisioning

{% hint style="warning" %}
This feature is currently in Beta, so make sure to [enable Beta features](https://olddocs.exivity.io/administration/settings#enable-beta-features) in order to configure claims-based access provisioning.
{% endhint %}

{% hint style="info" %}
For demonstration purposes, this tutorial uses [OneLogin](https://www.onelogin.com/) as an Identity Provider.
{% endhint %}

This tutorial is divided into three main sections:

1\) [The configuration of a OneLogin account to integrate SSO with Exivity](#part-1-configure-onelogin).

2\) [The configuration of your Exivity instance, so that it can be used as a Service Provider](#part-2-configure-your-exivity-instance).

3\) [The necessary configuration to automatically provision users with Account access and assign them to User Groups based on a claims-based identity.](#part-3-configure-the-saml2-attributes-for-claims-based-identity-provisioning)

{% hint style="success" %}
If you already have an SSO configuration enabled and configured, you may be interested only in the 3rd part of this tutorial, therefore skip sections 1 and 2.
{% endhint %}

### Part 1: Configure OneLogin

1\. In order to use OneLogin as an Identity Provider, you need to set up a new application. To do so, navigate to the OneLogin administration, hover over **Applications** in the navigation bar, and click on **Applications***:*

![Applications menu in OneLogin](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRZvuYYNyI3vz1mar1l4%2Fuploads%2Fg8P9sZSr6VOmDPfLMwDv%2FOneLoginStep1.png?alt=media\&token=2af9c86b-0185-4355-9561-5a25ac170e61)

2\. Click on the **Add App** button in the top right corner:

![Click Add App button](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRZvuYYNyI3vz1mar1l4%2Fuploads%2FEXiai3QeVqiKzVa94WxE%2FOneLoginStep2.png?alt=media\&token=62e09d49-caf5-436d-b499-9e45a4577a66)

&#x33;*.* In the list of applications, search for "saml" and click on the item *SAML Custom Connector (Advanced)*:

![List of SAML connectors](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRZvuYYNyI3vz1mar1l4%2Fuploads%2FiwNFKIPVRBOPzZQ4zUny%2FOneLoginStep3.png?alt=media\&token=cb9e31fe-8ff2-4bf2-94ec-c858b8c7040c)

4\. Provide a meaningful name for your app, then click **Save**.

5\. Click the **Configuration** tab. You will notice there are some fields to configure:

![Configuration of SAML2 in OneLogin](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRZvuYYNyI3vz1mar1l4%2Fuploads%2FEecCXmboi40WgADQBqCH%2FOneLoginStep4.png?alt=media\&token=fcf1bec1-4af6-45c6-84d1-961cd09d72a5)

The required information to fill in these fields can be found at the **Administration** > **Settings** > **Single Sign-on** > **Endpoints** section in the Exivity GUI:<br>

![Exivity Endpoints](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRZvuYYNyI3vz1mar1l4%2Fuploads%2FbE5zGUUnBosxyNwINRba%2Fendpoint-sso.png?alt=media\&token=9a545d7e-2108-45a2-8523-a329484b5c79)

Follow this mapping between OneLogin and the Endpoints:

![Mapping between OneLogin and Exivity Endpoints](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRZvuYYNyI3vz1mar1l4%2Fuploads%2FQ9co5FCDCb7hQeQWNM3Z%2Fmapping-exivity-onelogin-endpoints.png?alt=media\&token=a14e268d-5bc0-4506-aa2b-8121b772c75f)

6\. After filling in the fields, click the **Save** button in the top right corner.

### Part 2: Configure your Exivity instance

1. Now, you have to copy and paste some values from the  OneLogin application into the Exivity instance Single Sign-on settings. In OneLogin, click on the **SSO** tab:

![SSO Configuration in OneLogin](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRZvuYYNyI3vz1mar1l4%2Fuploads%2F5Jh0YWbHIYkKU0H51ZfM%2FOneLoginStep5.png?alt=media\&token=3e96a2ae-b08b-4e06-a354-d0a469a652e8)

2\. In a separate browser tab, open the Exivity GUI. Navigate to the **Administration** > **Settings** > **Single sign-on** menu and select the **SAML** tab. Copy over the following settings from OneLogin with this correspondence:

![Mapping between Exivity's SAML configuration and OneLogin](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRZvuYYNyI3vz1mar1l4%2Fuploads%2FBKn1a2nBBfqMgu8HUVex%2Fmapping-exivity-onelogin.png?alt=media\&token=39526cce-188e-4ffb-9483-a88447f4f4b9)

![SAML configuration in the Exivity GUI](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRZvuYYNyI3vz1mar1l4%2Fuploads%2FyyC3PSTf27vbUJOsPnec%2FOneLoginStep6.png?alt=media\&token=b7b202f8-61cb-4ad9-ad35-b09d5ddf8f91)

3\. Now, let's set up the OneLogin certificate in Exivity. In the same **SSO** tab in OneLogin, under the label *X.509 Certificate*, click the **View Details** link.&#x20;

![X.509 certificate in the SSO tab](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRZvuYYNyI3vz1mar1l4%2Fuploads%2F1ETq9y4Rhi7Y5p0i3YTh%2FOneLoginStep7.png?alt=media\&token=fa968bcb-63a7-4c79-b5cf-7d344044324f)

4\. Copy the X.509 Certificate and paste it in the *X-509 certificate* field in the Exivity *SAML* settings:

![Adding the certificate in Exivity](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRZvuYYNyI3vz1mar1l4%2Fuploads%2FdwXni2nmhOusNGADvlL7%2FOneLoginStep8.png?alt=media\&token=d1b69922-07e3-4ef4-8dbd-5181edef40fe)

5\. Click **Update** to apply your new settings.

6\. You also need to add the OneLogin domain for your organization to the [CORS](https://olddocs.exivity.io/security/security#cross-origin-resource-sharing-cors) whitelist as well. Navigate to the **System** tab in the **Administration** > **Settings** menu and add your domain in the *CORS origins* field.

Your domain may look similar to: `https://`*`name`*`.onelogin.com`

![Adding your OneLogin domain to the CORS whitelist](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRZvuYYNyI3vz1mar1l4%2Fuploads%2F1Tx47E8SBHaOhZyvA4JS%2Fadd-CORS-forSSO.png?alt=media\&token=73aa3266-0908-4467-80ba-e977f0552fa7)

{% hint style="success" %}
Make sure to separate the CORS origins domains with a comma.
{% endhint %}

7\. Click **Update** to apply your new settings.

### Part 3: Configure the SAML2 attributes for claims-based identity provisioning and Account access

1. Navigate to the **Administration** > **Settings** > **Single sign-on** menu and select the **SAML** tab.
2. Scroll down to the *User Provisioning*, *User group* and *Account Provisioning* sections. You will notice that for each section you can fill in some *attributes*.

{% hint style="warning" %}
If you don't see the aforementioned sections, it might be that you haven't [enabled Beta Features](https://olddocs.exivity.io/administration/settings#enable-beta-features).
{% endhint %}

In order to understand the attributes in a SAML2 response  and the configuration that we have to do, it's important to understand the following workflow, which describes the communication between a Service Provider and an Identity Provider:

{% hint style="success" %}

1. The user opens their browser and navigates to the Service Provider's web application (In this case, Exivity), which uses an Identity Provider (In this case, OneLogin) for authentication.
2. The web application responds with a SAML request.
3. The browser passes SAML request to the IdP.
4. The IdP parses the SAML request.
5. The IdP authenticates the user by prompting for a username and password or some other authentication factor. *NOTE*: The IdP will skip this step if the user is already authenticated.
6. The IdP generates the SAML response and returns it to the user's browser.
7. The browser sends the generated SAML response to the Service Provider's web application which verifies it.
8. If the verification succeeds, the web application grants the user access.
   {% endhint %}

Assume there is a user called *Foo* who is a member of the AD (Active Directory) group: ***group2***. After *step 7* in the above  example, the SAML2 response in an XML format may look like this:

```
<saml:AttributeStatement>
		<saml:Attribute NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic" Name="Email">
				<saml:AttributeValue
		 				xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">anca@exivity.com
				</saml:AttributeValue>
		</saml:Attribute>
		<saml:Attribute NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic" Name="Department">
				<saml:AttributeValue
		 				xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">group2
				</saml:AttributeValue>
		</saml:Attribute>
</saml:AttributeStatement>
```

{% hint style="info" %}
In the SAML2 response, we can observe that there are `Attribute Names` and `Attributes Values`. \
We are interested in the attribute name that holds the ***group2*** value. In this case, the attribute name is *Department*.
{% endhint %}

\
3\. In order to provision [Account](https://olddocs.exivity.io/reports/accounts) access based on claims (for example, the user *Foo* is part of a group), you must [create a Metadata](https://olddocs.exivity.io/data-pipelines/metadata#step-1-defining-metadata-fields) definition and [associate it with the Account(s)](https://olddocs.exivity.io/data-pipelines/metadata#step-2-associate-metadata-to-report-levels) that you want to be accessible for the user(s) which are part of that group.

Consult the [Metadata](https://olddocs.exivity.io/data-pipelines/metadata) article for a detailed guide about how to create a metadata definition and link it to an account.

\
4\. In this tutorial, we configured a custom Exivity Metadata Field *"Azure AD Security Group"* and set this value for the Accounts *"Manufacturing", "Marketing"* and *"Retail"*  to ***group2***.

![](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRZvuYYNyI3vz1mar1l4%2Fuploads%2FOmUdRYpJVcljb4xuD7O4%2Fmetadata-mapping-works-01-01.png?alt=media\&token=05450ee1-3522-4d49-8e87-22bfcb32001f) ![](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRZvuYYNyI3vz1mar1l4%2Fuploads%2FohQKG7aTfBgoNxC5Ypgu%2Fmetadata-mapping-works-02-01.png?alt=media\&token=99cbd920-2aac-4ef9-8850-648125fb4975) ![](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRZvuYYNyI3vz1mar1l4%2Fuploads%2FzZZwNXKYI2qI3q1VxXFy%2Fmetadata-mapping-works-03-01.png?alt=media\&token=d04cfafd-9cf6-4662-899d-3b4bed7d6166)

5\. In your OneLogin configuration screen, navigate to the **Parameters** tab and click the **+** button to add *Attributes*. In this case, we added an Attribute named "Department":

![Adding SAML2 attributes in OneLogin](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRZvuYYNyI3vz1mar1l4%2Fuploads%2FG3ModkZQM2KlitWd4bKv%2Fparameters-tab-config-oneLogin.png?alt=media\&token=2f4295ac-927e-431b-914a-6e443965fa87)

To test our claims-based Account provisioning scenario, we must assign a value to the Department attribute. To do that, open the **User** tab, click on your user and add your prefered value to Department. In this case, we want a user who is part of the ***group2***, in accordance with the Metadata value we configured earlier:

![Department is set to group2](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRZvuYYNyI3vz1mar1l4%2Fuploads%2FaJzd1NaqOME4R6JBwZDl%2Fgroup2.png?alt=media\&token=fb487f08-92b0-467f-9f64-10e43becce41)

6\. In the *Account provisioning* section mentioned earlier, this definition must be mapped by filling in the fields:

![Mapping the SAML attribute to a Metadata field for Account access provisioning](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRZvuYYNyI3vz1mar1l4%2Fuploads%2F4VMMIoZMuPunnhpVq5oG%2FCBAAP-group2.png?alt=media\&token=fd17e4ea-a6ff-4b33-8867-f9b8ca94fe55)

In the picture above, the SAML attribute "Department" is checked against the metadata field "Azure AD Security Group". If the values of these two keys match, then the user will receive [Account](https://olddocs.exivity.io/reports/accounts) access to that/those Account(s) that are connected to this Metadata definition.&#x20;

The following diagram illustrates how the mapping between user attributes and metadata fields works when doing claims-based Account access provisioning:

![Claims-based Account access provisioning](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRZvuYYNyI3vz1mar1l4%2Fuploads%2FUAggXi0vg30jYIfYheJa%2FCBAAP.png?alt=media\&token=3220ca94-294d-49a1-a382-f2ce511e397f)

&#x20;If the user's claims (i.e. the attributes in the SAML2 response) don't match any of the Metadata values assigned to one or more Accounts, then the user will not receive access and visibility to those Accounts, unless an Administrator configures it manually.

### Account key vs Metadata

If you select **Account Key** instead of Metadata, then the attribute value will be matched against every Account with that name. For example, if we would have selected Account key with the same *Department* attribute (whose value we know is equal to ***group2***), then the user/s would get access to all the Accounts that are named ***group2***.

7\. Now that you know how the mapping of SAML2 attributes works, fill in the details for the *User Provisioning* and *User Groups* settings with the corresponding SAML2 attributes:

{% hint style="info" %}
*Note*: These attributes here are specific to OneLogin. For other Identity Providers, they might differ.
{% endhint %}

![User Provisioning attributes](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRZvuYYNyI3vz1mar1l4%2Fuploads%2FRTBLmZHkauwgd2dYi4U0%2Fuser-provisioning-atributes.png?alt=media\&token=10d271bc-a5b4-417b-a7e9-416c899a7556)

The *User Provisioning* attributes have the purpose of assigning a relevant *name*, *email* and *display name* when an SSO user logs in for the first time.

![User Group attributes](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRZvuYYNyI3vz1mar1l4%2Fuploads%2FJaEzyHu6CNPymwJcksOp%2FGroup-provisioning.png?alt=media\&token=dbe18878-d8ab-4149-ad03-897bfb12c835)

The *User group* attributes have the purpose of assigning the user to the right group, if it has been sent through a SAML2 attribute. For example, in the picture above, if *MemberOf* = *managers*, then the user would be assigned to the Managers group. Otherwise, it will be assigned to the Default chosen group.

8\. Click **Update** to apply your changes.

9\. Finally, we can test our automatic Account access provisioning. Enable Single Sign-On in Exivity by navigating to **Administration** > **Settings** and then clicking on the **System** tab. Make sure the *Single Sign-On* option is set to an option including *SAML2 Authentication:*

![Enable Single Sign-On](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRZvuYYNyI3vz1mar1l4%2Fuploads%2FX1hRFI7twnPhcOIe4Cax%2Fenable-saml-2.png?alt=media\&token=f69da502-ddc0-4aa6-8174-1f4b2902464e)

10\. Click **Update** to apply your change.

11\. Log out of the current session and you will be redirected to the login page which may look like this:

![SSO login](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRZvuYYNyI3vz1mar1l4%2Fuploads%2FbP6QLzTugKB7wWtDxBen%2Fsso-login.png?alt=media\&token=5f82045c-5c1f-469a-86ce-10f3e8c52101)

12\. And by clicking on the **Login** button, you'll be taken to the OneLogin login screen.&#x20;

13\. After logging in, we can observe that the user only has access to the Accounts *"Manufacturing", "Marketing"* and *"Retail",* as expecte&#x64;*:*

![](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRZvuYYNyI3vz1mar1l4%2Fuploads%2Ff3c5T5oKZIaBJF4untVr%2Fmetadata-mapping-works-01.png?alt=media\&token=f5015b55-13cf-4567-b8cf-d3997adfb595) ![](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRZvuYYNyI3vz1mar1l4%2Fuploads%2FpwkEzbI2k2Qri3YuPYBr%2Fmetadata-mapping-works-02.png?alt=media\&token=a33b3f5f-6779-4807-8898-ef13643cfc57) ![](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRZvuYYNyI3vz1mar1l4%2Fuploads%2FoL59GARwLtrPsZTuoE9s%2Fmetadata-mapping-works-03.png?alt=media\&token=d432f8a5-440f-43c3-8515-abd1bba2d087)

Depending on which Metadata fields you configured (for example a *Security Group*), you will observe that your user(s) whose claims/attributes match with the metadata fields, automatically received access to one or more Accounts, eliminating the need for manual configuration.
