# Setup Single Sign On (SSO) with SAML

EC3 supports integration with various [Identity Providers](#user-content-fn-1)[^1] (IdP) who implement the [SAML protocol](https://en.wikipedia.org/wiki/SAML_2.0). If your organization has a compatible, centralized user management system like Microsoft Entra ID, Active Directory or Google Workspaces this integration will enable your users to log into all BuildingTransparency services with your corporate authentication server.  You can configure your server to decide which groups of users are eligible to login into EC3.

## Setting up the integration

This section explains the complete flow for setting up a Single Sign-on (SSO) integration for Building Transparency products with SAML based IdP[^2]. The configuration process requires actions by the EC3 engineering team and yourselves. &#x20;

Before you start:

* You have an EC3 subscription that supports SSO integration.  (contact <sponsorship@buildingtransparency.org>)
* Ensure you have access and **permissions to change SAML** configuration with your identity provider
* You have received the following from BuildingTransparency:
  * Issuer/Identifier/Entity ID, for example “Entity ID: <https://auth.buildingtransparency.org/source/saml/acme-saml”>
  * ACS/Reply URL/Assertion Consumer Service, for example: “Reply URL (ACS): <https://auth.buildingtransparency.org/source/saml/acme-saml/acs/”>

#### IdP Specific Instructions

* [Microsoft Entra ID](#microsoft-entra-id) (formerly Azure AD, Azure Active Directory)

### Microsoft Entra ID

#### Step 1 - Create a BuildingTransparency Application in Azure

1. In [Microsoft Entra ID](https://portal.azure.com/#view/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/~/Overview)
   1. go to [**Microsoft Entra ID** > **Enterprise Applications**](https://portal.azure.com/#view/Microsoft_AAD_IAM/StartboardApplicationsMenuBlade/~/AppAppsPreview/menuId~/null),&#x20;
   2. click **+ New application** to display the Browse Microsoft Entra ID Gallery, and&#x20;
   3. click **+ Create your own application**.\
      The Create your own application side panel is displayed.<br>

      <figure><img src="https://3092112806-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPDhVD99RBnS0Qy4HvVPO%2Fuploads%2FFR9p8sWtuHT6u07xWc1O%2Fimage.png?alt=media&#x26;token=72af3764-6881-47c8-bcd0-20069451dabc" alt=""><figcaption><p>Create new SAML application dialog (MS Entra ID)</p></figcaption></figure>
   4. Select **Integrate any other application you don’t find in the gallery (Non-gallery)**&#x20;
   5. click **Create**.

#### Step 2 - Initial Configuration

1. Open your newly created application.&#x20;
2. From the left navigation panel select **Single sign on** \
   &#x20;

   <figure><img src="https://3092112806-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPDhVD99RBnS0Qy4HvVPO%2Fuploads%2FWzYRLOscdkRCcJ0Df4S9%2Fimage.png?alt=media&#x26;token=146b64df-b4da-4886-ae24-1069d5a0a60d" alt=""><figcaption><p>Single Sign-on of the SAML app (MS Entra ID)</p></figcaption></figure>

   Select **SAML** from the list of the proposed authentication options<br>

   <figure><img src="https://3092112806-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPDhVD99RBnS0Qy4HvVPO%2Fuploads%2FOxhtxeErIlScbka3mH91%2Fimage.png?alt=media&#x26;token=1794daa7-6319-4dee-8ebd-0624819aeac6" alt=""><figcaption><p>Select SSO method (MS Entra ID)</p></figcaption></figure>
3. Locate the **Basic SAML Configuration** section and click 3 dots icon in the right top corner;\
   Choose **Edit** from the drop down menu. <br>

<figure><img src="https://3092112806-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPDhVD99RBnS0Qy4HvVPO%2Fuploads%2FaztrIeSiJmOG4s1yFawm%2Fimage.png?alt=media&#x26;token=e4049c64-0b1e-403b-80dc-9d75eff6c540" alt=""><figcaption><p>Open basic SAML configuration editor  (MS Entra ID)</p></figcaption></figure>

4. The **Basic SAML Configuration** side panel is displayed.<br>

<figure><img src="https://3092112806-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPDhVD99RBnS0Qy4HvVPO%2Fuploads%2FW3tT8CmpwJHaOtjEvFFo%2Fimage.png?alt=media&#x26;token=19fa22df-e731-4657-94ac-52ce347a51af" alt=""><figcaption><p>Basic SAML editor (MS Entra ID)</p></figcaption></figure>

1. Set **Identifier (Entity ID)** and **Reply URL (Assertion Consumer Service URL)**. You should ask Building Transparency support for this values. \
   Click **Save** and close side panel.

#### Step 3 - Configure Attribute Mapping

{% hint style="info" %}
Depending on the settings of your organization the attribute mapping might be slightly different. This guide assumes you use email as a user identifier and you didn't do any changes to the standard user fields.
{% endhint %}

1. In section 2 "Attributes & Claims" click three dots icon and then Edit item from dropdown menu<br>

   <figure><img src="https://3092112806-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPDhVD99RBnS0Qy4HvVPO%2Fuploads%2Fs42KJXePBFOTxcHByfvT%2Fimage.png?alt=media&#x26;token=5439971b-0a5d-42b1-b137-d233f7129afa" alt=""><figcaption><p>Open attributes mapping dialog (MS Entra ID) </p></figcaption></figure>
2. Attribute Mapping dialog will appear<br>

   <figure><img src="https://3092112806-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPDhVD99RBnS0Qy4HvVPO%2Fuploads%2F5PB1EFPBuBsssxNfX0cC%2Fimage.png?alt=media&#x26;token=edde5377-fbf1-4129-932f-8882279b4ce0" alt=""><figcaption><p>Attribute Mapping dialog (MS Entra ID)</p></figcaption></figure>
3. Click on the Unique User Identifier field and make sure the configuration matches the screenshot below:<br>

   <figure><img src="https://3092112806-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPDhVD99RBnS0Qy4HvVPO%2Fuploads%2FWkyzvRvrFspFywrD8a2r%2Fimage.png?alt=media&#x26;token=4f4a80e1-3c6a-489a-b083-a43938ee9a03" alt=""><figcaption><p>Unique User Identifier field mapping (MS Entra ID)</p></figcaption></figure>
4. For each of the additional claims set mapping as per picture below.\
   **IMPORTANT**: You must remove the namespace from each of the fields:<br>

   <figure><img src="https://3092112806-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPDhVD99RBnS0Qy4HvVPO%2Fuploads%2FtD5yY26C8BKFdRGEt7Tg%2Fimage.png?alt=media&#x26;token=3f4f7611-50b4-4791-8817-5712e7265e64" alt=""><figcaption></figcaption></figure>

   Repeat this procedure for each field so you have the following mapping:

| SAML Claim  | Source attribute |
| ----------- | ---------------- |
| email       | user.mail        |
| first\_name | user.givenname   |
| last\_name  | user.surname     |
| name        | user.displayname |

The final result should look like this:

<figure><img src="https://3092112806-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPDhVD99RBnS0Qy4HvVPO%2Fuploads%2FZ37JwA5NBCXgJPdqiZld%2Fimage.png?alt=media&#x26;token=51fcffe3-90f8-49fd-bf35-6553aa228cb0" alt=""><figcaption><p>Final attributes mapping (MS Entra ID)</p></figcaption></figure>

5. Close the dialog to return back to your SAML app configuration.

#### Step 4 - Collect credential

Once you have configured your application, you will need to collect your application identifiers and certificate. You will be sending this information to Building Transparency. &#x20;

1. In Section 3 "SAML Certificates". Locate field **Certificate (Base64)** and click Download<br>

   <figure><img src="https://3092112806-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPDhVD99RBnS0Qy4HvVPO%2Fuploads%2F60j94IboneK6BRD8Ufcb%2Fimage.png?alt=media&#x26;token=5ee5e4d4-2848-48a8-8dbf-5914662cfc38" alt=""><figcaption><p>Download SAML certificate (MS Entra ID)</p></figcaption></figure>

2. In section 4 "Set up" locate Login and Logout URLs and copy values<br>

   <figure><img src="https://3092112806-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPDhVD99RBnS0Qy4HvVPO%2Fuploads%2FmP3W3hTu2eykvpO4VTE5%2Fimage.png?alt=media&#x26;token=950f1996-afeb-4d5d-bca2-ce566b82da93" alt=""><figcaption><p>SAML App URLS (MS Entra ID)</p></figcaption></figure>

3. Send the following information to your contact at Building Transparency:
   1. SAML Login URL
   2. SAML Logout URL
   3. Certificate in Base64 format

#### Step 5 - Grant access to your users

You can either allow anyone in your organization to use this app or configure strict rules to enable access for the selected users.&#x20;

To allow access for everyone within your organization:

1. Open Properties from the left navigation menu on your SAML app page
2. Select **Assignment required** = No\
   &#x20;

   <figure><img src="https://3092112806-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPDhVD99RBnS0Qy4HvVPO%2Fuploads%2FZs0gJstNqk90qOxcVJ70%2Fimage.png?alt=media&#x26;token=8e8b5141-812c-4a29-9464-d48fb6fee267" alt=""><figcaption><p>Make application available for everyone within organization (MS Entra ID)</p></figcaption></figure>

To restrict access for specific group or users:

1. Navigate to Users and Groups from the left navigation menu of your SAML app page.
2. Select Add user/group and configure access as needed\
   &#x20;

   <figure><img src="https://3092112806-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPDhVD99RBnS0Qy4HvVPO%2Fuploads%2FZ25KjIf0Lpto2ofEdPdh%2Fimage.png?alt=media&#x26;token=46f3fceb-061c-41b7-ae68-fdb7072fa79e" alt=""><figcaption><p>Restrict access to the application (MS Entra ID)</p></figcaption></figure>

#### Step 6 - Wait for notification by Building Transparency

Building Transparency engineers will update configuration with the data you supplied and let you know when you can start testing the integration.

[^1]: An identity provider (abbreviated IdP or IDP) is a system entity that creates, maintains, and manages identity information. Examples are Google Workspaces, Active Directory, etc.

[^2]: Identity Provider
