# Azure AD Configuration

## Steps to follow

* [Create a new Enterprise Application](#create-a-new-enterprise-application)
* [Set up Single Sign-On](#set-up-single-sign-on)
  * Option 1: Upload metadata XML file
  * Option 2: Enter metadata manually
  * [Configure Attributes & Claims](#configure-attributes-and-claims)
* [Enter Azure's metadata into Sleuth](#enter-azures-metadata-into-sleuth)
  * Option 1: Link to metadata file
  * Option 2: Input metadata manually
* [Assign Users/Groups to the Enterprise Application](#assign-users-groups-to-the-enterprise-application)

## Create a new Enterprise Application

Sign into Azure as an administrator and click on the "**Azure Active Directory**" tile.

![](https://2832637360-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1bR_-Od0islbiOl4G0%2Fuploads%2F3ukKggvWPWETFfu1N17k%2Fimage.png?alt=media\&token=46656a8b-599c-4b80-8d46-759a8d4bcc0e)

In the left-hand menu click on "**Enterprise Applications**" and then click "**New application**". On the next page click "**Create your own application**". Name your application (*e.g., Sleuth*), select the "**Integrate any other application you don't find in the gallery (Non-gallery)**" option, and click "**Create**":

<figure><img src="https://2832637360-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1bR_-Od0islbiOl4G0%2Fuploads%2F8ayaYHcTJNedjFD99gYS%2Fimage.png?alt=media&#x26;token=b9497424-8c3d-4939-ae2d-63d2974008b7" alt=""><figcaption></figcaption></figure>

## Set up Single Sign-On

Once the application is created, you'll be taken to its homepage. Click the "**2. Set up single sign on**" tile (*alternatively, you can click the "**Single sign-on**" link in the left-hand navigation*):

<figure><img src="https://2832637360-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1bR_-Od0islbiOl4G0%2Fuploads%2Fr4SskjLFdeg2kBeSux2O%2Fimage.png?alt=media&#x26;token=7953daba-a010-4f7a-be6d-6e2d799cbce8" alt=""><figcaption></figcaption></figure>

When prompted, select "**SAML**" as the **single sign-on method**, then proceed with one of the 2 options explained below:

{% tabs %}
{% tab title="Option 1: Upload metadata XML file" %}
Click the "**Upload metadata file**" button to trigger the file import modal, **select the file** to upload, and click "**Add**":

<figure><img src="https://2832637360-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1bR_-Od0islbiOl4G0%2Fuploads%2F1zCKQfW2e51h3sBUAKnu%2Fimage.png?alt=media&#x26;token=369a3ff7-52e3-43e3-bac0-bd975e3d820c" alt=""><figcaption></figcaption></figure>

Once the file is uploaded, you'll see a preview of the imported metadata. If needed/desired, you can still make changes, although it generally shouldn't be necessary.

One **optional field** that doesn't get populated automatically is "**Relay State**"; you can specify it manually by inputting your **Sleuth org slug** (*find it in your URL -> `https://app.sleuth.io/`**`<org-slug>`***) and clicking "**Save**" at the top:

<figure><img src="https://2832637360-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1bR_-Od0islbiOl4G0%2Fuploads%2FmnDa0BokY76vxQQzLtMS%2Fimage.png?alt=media&#x26;token=69e3c02a-6899-481e-95ac-21a1fcfba4e6" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Option 2: Enter metadata manually" %}
On the "**Basic SAML Configuration**" tile click "**Edit**":

<figure><img src="https://2832637360-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1bR_-Od0islbiOl4G0%2Fuploads%2FptQCAsV7bWgbr0bUlQld%2Fimage.png?alt=media&#x26;token=2cc6eab2-8d69-4e26-a976-3aebd99a7e59" alt=""><figcaption></figcaption></figure>

**Fill in the necessary metadata** (*found in Sleuth*), using the following reference, and click "**Save**":

<table><thead><tr><th>AZURE AD</th><th>SLEUTH</th><th>EXAMPLE</th><th data-hidden></th></tr></thead><tbody><tr><td><strong>Identifier (Entity ID)</strong></td><td>SAML Entity ID</td><td><code>https://app.sleuth.io/saml/metadata/</code></td><td></td></tr><tr><td><strong>Reply URL (Assertion Consumer Service URL)</strong></td><td>Assertion Consumer Service</td><td><code>https://app.sleuth.io/complete/saml/</code></td><td></td></tr><tr><td><strong>Relay State (Optional)</strong></td><td>Default Relay State</td><td><code>sleuth</code><br><em>(should be your <strong>org slug</strong>)</em></td><td></td></tr><tr><td><strong>Logout Url (Optional)</strong></td><td>Single Logout Service</td><td><code>https://app.sleuth.io/saml/sls/</code></td><td></td></tr></tbody></table>

<figure><img src="https://2832637360-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1bR_-Od0islbiOl4G0%2Fuploads%2FMGjKFX1u14tJHSqcEq08%2Fimage.png?alt=media&#x26;token=ec99c134-7c94-435f-a1c6-f2603576ed52" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

### Configure Attributes & Claims

Leave the **Attributes & Claims** section configured as it is, the settings should look like this:

<figure><img src="https://2832637360-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1bR_-Od0islbiOl4G0%2Fuploads%2FW9sqTyuOJtf4lNRGlNY0%2Fimage.png?alt=media&#x26;token=d5ff9953-f246-4107-9571-3db9c25dff61" alt=""><figcaption></figcaption></figure>

{% hint style="danger" %}
Keeping the **Unique User Identifier** claim set to `user.userprincipalname` is a **prerequisite** for your SAML configuration to work with Sleuth.
{% endhint %}

## Enter Azure's metadata into Sleuth

Similarly as before, you can again choose between **pointing Sleuth to a URL** where the IdP's metadata is now available, or **entering the metadata into Sleuth manually**.

{% tabs %}
{% tab title="Option 1: Link to metadata file" %}
In Azure on the "**SAML Certificates**" tile under your Enterprise Application, **copy the value** of the "**App Federation Metadata Url**" field:

<figure><img src="https://2832637360-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1bR_-Od0islbiOl4G0%2Fuploads%2FnA0NxRyfuUd8qxAk8ovq%2Fimage.png?alt=media&#x26;token=0f964af0-4d8f-4112-ae72-25a6e204a4b8" alt=""><figcaption></figcaption></figure>

In Sleuth, click the "**point Sleuth to metadata file URL**" link to trigger the input modal and **paste the copied URL** into the field, then click "**Save**":

<figure><img src="https://2832637360-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1bR_-Od0islbiOl4G0%2Fuploads%2F53KiBmT8vEAZKEGnpild%2Fimage.png?alt=media&#x26;token=7d7bc539-b71d-4197-b03e-f5026ea3b0db" alt=""><figcaption></figcaption></figure>

The remaining fields in Sleuth will get **populated automatically**, just click "**Test Metadata and Save**":

<figure><img src="https://2832637360-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1bR_-Od0islbiOl4G0%2Fuploads%2FMBGx3YQgEG5VTEjZzx7v%2Fimage.png?alt=media&#x26;token=11d3decb-dacc-44e8-aa49-c5b3ecc0427d" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Sleuth defaults all of the Advanced configuration to the most commonly used values, but depending on your IdP configuration you might need to adjust "**Advanced settings**".
{% endhint %}

## Assign Users/Groups to the Enterprise Application

On the Application's homepage click the "**1. Assign users and groups**" tile (*alternatively, you can click the "**Users and groups**" link in the left-hand navigation*):

<figure><img src="https://2832637360-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1bR_-Od0islbiOl4G0%2Fuploads%2FeI4O2KqgmZCVJAppdzfP%2Fimage.png?alt=media&#x26;token=449464df-80e4-40a6-9865-3077cf365124" alt=""><figcaption></figcaption></figure>

Click the "**+Add user/group**" button and **assign Users/Groups** as needed:

<figure><img src="https://2832637360-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1bR_-Od0islbiOl4G0%2Fuploads%2FR1SXVnSd3WKZDqBMSsIu%2Fimage.png?alt=media&#x26;token=5bc68c1a-e5aa-4b2e-b7a3-631d4026f976" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Option 2: Input metadata manually" %}
**Fill in the necessary metadata** (*found in Azure AD*), using the following reference, and click "**Test Metadata and Save**":

<table><thead><tr><th>SLEUTH</th><th>AZURE AD</th><th>EXAMPLE</th><th data-hidden></th></tr></thead><tbody><tr><td><strong>Entity ID</strong></td><td>Azure AD Identifier</td><td><code>https://sts.windows.net/&#x3C;...></code></td><td></td></tr><tr><td><strong>SSO URL</strong></td><td>Login URL</td><td><code>https://login.microsoftonline.com/&#x3C;...></code></td><td></td></tr><tr><td><strong>SLO URL</strong></td><td>Logout URL</td><td><code>https://login.microsoftonline.com/&#x3C;...></code></td><td></td></tr><tr><td><strong>Certificate</strong></td><td>On the "<strong>SAML Certificates</strong>" tile click "<strong>Edit</strong>", then click the <strong>3 ellipses</strong> at the right end of the Active certificate and select "<strong>PEM certificate download</strong>".</td><td><code>-----BEGIN CERTIFICATE-----</code><br><code>&#x3C;...></code><br><code>-----END CERTIFICATE-----</code></td><td></td></tr></tbody></table>

<figure><img src="https://2832637360-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1bR_-Od0islbiOl4G0%2Fuploads%2FqKtP8LA1rXKLmQgTgRF7%2Fimage.png?alt=media&#x26;token=c478d15f-be4c-4d1b-b1b6-c8ae5ff13498" alt=""><figcaption><p>Open the downloaded file with a text-/code editor and copy the contents to be pasted into the "Certificate" field in Sleuth.</p></figcaption></figure>

<figure><img src="https://2832637360-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1bR_-Od0islbiOl4G0%2Fuploads%2F4ZUL1ova8qNSjotQt1kt%2Fimage.png?alt=media&#x26;token=697b4402-7d22-437e-878c-27cfc715bcf9" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}
