# Azure Active Directory

This guide provides a step-by-step walkthrough to configure Azure Active Directory (AD) as an external identity provider for Akamas users.

{% hint style="info" %}
Ensure you have an Azure account with the **Application.ReadWrite.All** permission to create app registrations in your Azure AD tenant.
{% endhint %}

## Configure the App registration

To integrate Akamas with your Azure AD, you’ll need a dedicated App registration in your Azure organization. You can either use an existing registration or create a new one.

* **Using an Existing Registration:** Skip to [#get-the-client-configuration](#get-the-client-configuration "mention").
* **Creating a New Registration:** Follow the instructions below.

{% hint style="info" %}
​​Multiple Akamas instances can share a single app registration, meaning any AD user added to the registration can access all associated Akamas instances. To manage access with finer granularity, create a unique app registration for each Akamas instance.
{% endhint %}

### Creating a new App registration

* In your Azure portal, navigate to [**App registrations**](https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade) and select **New registration**.
* Provide:
  * A **name** for the application.
  * The **account type** that best suits your use case.
* Complete the process by clicking **Register**.

<figure><img src="https://4103111959-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzrIhBBVa4sw46ol13SWX%2Fuploads%2Fgit-blob-29e504703dd39ba239f749eb66df426289b7c432%2Fazure_new_app.png?alt=media" alt=""><figcaption></figcaption></figure>

### Get the client configuration

On the **Overview** page of your app registration, make note of the following values:

* **Application (client) ID**

<figure><img src="https://4103111959-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzrIhBBVa4sw46ol13SWX%2Fuploads%2Fgit-blob-5dfab9b131de5518522654f155f1d07bb968291e%2Fazure_auth_appid.png?alt=media" alt=""><figcaption></figcaption></figure>

* **OpenID Connect metadata document** (found in the "Endpoints" side panel)

<figure><img src="https://4103111959-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzrIhBBVa4sw46ol13SWX%2Fuploads%2Fgit-blob-f5316b6183c2eb8b4963c598e005f85ea7ccf924%2Fazure_auth_config.png?alt=media" alt=""><figcaption></figcaption></figure>

Then, in the **Certificates & secrets** section, create a new **Client secret** and note its value. With these values ready, proceed to configure the provider in the Keycloak console.

<figure><img src="https://4103111959-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzrIhBBVa4sw46ol13SWX%2Fuploads%2Fgit-blob-f9ddf3fcd9570a57df4c565f840bcfc845c2a6d0%2Fazure_auth_secret.png?alt=media" alt=""><figcaption></figcaption></figure>

## Create the Identity provider in Keycloak

In the Keycloak admin console, access the **Identity Providers** section within the **Akamas** realm (see the [](https://docs.akamas.io/akamas-docs/3.6/managing-akamas/users-management/configure-an-external-identity-provider "mention") page for more details).

* Select **OpenID Connect v1.0** to start creating the new provider.
* Provide:
  * **Alias** (e.g., "microsoft") and optional **Display name** (e.g., "Microsoft") for the login page.
* In the **OpenID Connect settings** section, populate the following fields:
  * **Discovery endpoint:** Enter the URL of the *OpenID Connect metadata document*. A green box indicates successful validation.
  * **Client ID:** Enter the *Application (client) ID*.
  * **Client Secret:** Enter the generated client secret.

<figure><img src="https://4103111959-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzrIhBBVa4sw46ol13SWX%2Fuploads%2Fgit-blob-60eaf7c414f3eeb3c7fde630b2d47041749fb945%2Fkc_ms_provider.png?alt=media" alt=""><figcaption></figcaption></figure>

Click **Add** to complete the configuration. Copy the **Redirect URI** from the details page of the new provider.

## Complete the app registration in Azure

Return to the Azure portal and open the app registration. In the **Authentication** section, add the **Web** platform (if not already present).

<figure><img src="https://4103111959-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzrIhBBVa4sw46ol13SWX%2Fuploads%2Fgit-blob-45f5a360a55b84084e9868d876b8da022ef43ea8%2Fazure-web.jpg?alt=media" alt=""><figcaption></figcaption></figure>

Add the Redirect URI from the Keycloak console to the list of redirect URIs.

<figure><img src="https://4103111959-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzrIhBBVa4sw46ol13SWX%2Fuploads%2Fgit-blob-a993e5be236798a017e6e95861882b87d84eab4b%2Fazure_redirect.png?alt=media" alt=""><figcaption></figcaption></figure>

Akamas is now configured to delegate user login to Azure AD.

{% hint style="warning" %}
If the hostname of the Akamas installation changes, update the **Redirect URI** in the app registration to avoid login errors such as:

> The redirect URI 'https\://...' specified in the request does not match the redirect URIS configured for the application '...'.
> {% endhint %}

## Configure the default Akamas roles

To automatically assign default roles to users, set up mappers in Keycloak so users can access the default workspace with read and write permissions upon first login.

In Keycloak, go to the provider's details page and navigate to **Mappers**:

<figure><img src="https://4103111959-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzrIhBBVa4sw46ol13SWX%2Fuploads%2Fgit-blob-c7b5ff9b978786f8e9091e63e2a95f69b6830a2b%2Fkeycloak-mappers.jpg?alt=media" alt=""><figcaption></figcaption></figure>

Add the following configurations:

**User role**

* **Name**: *User role*
* **Mapper type**: *Hardcoded role*
* **Role**: *USER*

<figure><img src="https://4103111959-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzrIhBBVa4sw46ol13SWX%2Fuploads%2Fgit-blob-86daab00d138ae282d7aec193b7402d0c6b3b33d%2Fkc_user_mapper.png?alt=media" alt=""><figcaption><p>User Role map</p></figcaption></figure>

**Default Workspace Read**

* **Name**: *Default Workspace Read*
* **Mapper type**: *Hardcoded role*
* **Role**: *WS\_ac8481d3-d031-4b6a-8ae9-c7b366f027e8\_R*

**Default Workspace Write**

* **Name**: *Default Workspace Write*
* **Mapper type**: *Hardcoded role*
* **Role**: *WS\_ac8481d3-d031-4b6a-8ae9-c7b366f027e8\_W*

## Test the integration

Visit the Akamas installation's login page to verify that the new authentication method is displayed and working as expected.

<figure><img src="https://4103111959-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzrIhBBVa4sw46ol13SWX%2Fuploads%2Fgit-blob-cbe5e150bf07836f9f211465071a77ae06fe99a5%2Fms_auth_login.png?alt=media" alt=""><figcaption></figcaption></figure>
