# Microsoft SSO

{% hint style="warning" %}
The following steps describe the state of Microsoft services at the time of creating this instruction (16/01/2024).\
The Microsoft identity platform **interface may change**, so for the most up-to-date information, refer to the official [source](https://learn.microsoft.com/en-us/entra/identity-platform/scenario-web-app-call-api-overview) and their official [video guide](https://www.youtube.com/watch?v=LRoc-na27l0)
{% endhint %}

To log in to the AppSec portal through your Microsoft identity platform, follow these steps:

1. Navigate to your **Microsoft Entra** using the [link](https://entra.microsoft.com/#view/Microsoft_AAD_RegisteredApps/ApplicationsListBlade/quickStartType~/null/sourceType/Microsoft_AAD_IAM)
2. Navigate to **Application** -> **App registrations** section and **register a new** **application**

<figure><img src="https://3069717380-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M81VrXQrfSaYjNIFOtt%2Fuploads%2FTUeXx468yAo0UBYVVyh0%2Fmicr%20sso1.png?alt=media&#x26;token=4a303f13-2bda-46ba-b42a-3d8c947c6d82" alt=""><figcaption></figcaption></figure>

3. You will see the following screen, where you need to copy the \<Application (client) ID>:

<figure><img src="https://3069717380-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M81VrXQrfSaYjNIFOtt%2Fuploads%2FZ6UY6n5udBjOtvKPooHT%2Fmicr%20sso2.jpg?alt=media&#x26;token=17f45337-480e-4448-a474-ed4569bb4619" alt=""><figcaption><p><strong>Client ID</strong></p></figcaption></figure>

4. Now create a client secret on the "Certificates & secrets" tab:

<figure><img src="https://3069717380-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M81VrXQrfSaYjNIFOtt%2Fuploads%2FuyAMK5UJ63AE7iyn2Vfr%2Fmicr%20sso3.jpg?alt=media&#x26;token=cb1b5b17-70d4-4f93-bfe3-cc53156113ab" alt=""><figcaption><p><strong>Client Secret</strong></p></figcaption></figure>

5. The final data you have to get here is the **server metadata url.**

<figure><img src="https://3069717380-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M81VrXQrfSaYjNIFOtt%2Fuploads%2FQ5PwglUVxw7RYO2dUWeY%2Fmicr%20sso%20metadata1.jpg?alt=media&#x26;token=40e7ff7e-0bd1-408f-8951-de84c1b0033f" alt=""><figcaption><p><strong>Server metadata url</strong></p></figcaption></figure>

Use the data created for your application to [configure ](https://docs.whitespots.io/appsec-portal/general-portal-settings/sso-settings)SSO integration in the AppSec portal:

* **Domain**: login.microsoftonline.com
* **Client ID**: \<Application (client) ID>
* **Client Secret**: \<Value>
* **Server metadata url**: \<OpenID Connect metadata document>

<figure><img src="https://3069717380-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M81VrXQrfSaYjNIFOtt%2Fuploads%2FNtXBgegO9hzDsVTBhxcg%2FSSO%20Microsoft%20values.jpeg?alt=media&#x26;token=86406b93-5dde-430c-847c-bf180adaf59a" alt=""><figcaption><p>Microsoft SSO values example</p></figcaption></figure>

### MS Role Mapping

To create a role mapping in our portal, follow these steps:

1. **Create custom roles for Application**

Navigate to **Applications** -> **App registrations** -> <***Created application***> -> **App roles** section and create all required roles here

<figure><img src="https://3069717380-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M81VrXQrfSaYjNIFOtt%2Fuploads%2FP8Zy92faeBYgC9TePplC%2Fmicr%20sso4.jpg?alt=media&#x26;token=bf4f5c34-d612-4619-9cd1-583f07af535f" alt=""><figcaption></figcaption></figure>

2. Now you will be able to assign users/groups to Application roles

<figure><img src="https://3069717380-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M81VrXQrfSaYjNIFOtt%2Fuploads%2FJTpX7gFYMSnd8qDfg30N%2Fmicr%20sso5.jpg?alt=media&#x26;token=fe47975b-fa9b-429f-8d38-27ddd5d5419b" alt=""><figcaption></figcaption></figure>

For example select a group with all colleagues from IT department and assign them to our newly created role

<figure><img src="https://3069717380-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M81VrXQrfSaYjNIFOtt%2Fuploads%2FGl3jJ49nv9KwPXPxftRn%2Fmicr%20sso6.jpg?alt=media&#x26;token=3045825a-683b-431c-abcf-cc49ac0b816c" alt=""><figcaption></figcaption></figure>

3. [Configure](https://docs.whitespots.io/appsec-portal/general-portal-settings/sso-settings/..#role-mapping) the mapping of roles for your SSO connection. \
   **JSON key in JWT token with list of external groups** field should equal to **roles** for this integration.&#x20;

{% hint style="danger" %}
The integration only works with the **roles** value\
We know that Microsoft provides the guide with a clearly displayed "groups" key 🤷‍♂️ \
Get more information about this specific feature from the [video](https://youtu.be/LRoc-na27l0?si=VBqZ1hvDWjUSpKmr)
{% endhint %}

<figure><img src="https://3069717380-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M81VrXQrfSaYjNIFOtt%2Fuploads%2FqD3AP9Ugij6RiUchbQr7%2Fms%20mapp.png?alt=media&#x26;token=a8d34825-4885-4266-a2b6-855de9c177da" alt=""><figcaption></figcaption></figure>

3. If a mapping has not been previously configured, the first time you log in using Single Sign-On (SSO), the SSO settings will display a list of roles received from Microsoft under the name **External Group Name**. You can configure these roles by creating mappings. To do this, add the corresponding portal roles for each group from this list. <br>

If new roles appear on the Microsoft's side, they will also appear as unassociated during the first login and you should associate them later.

<figure><img src="https://3069717380-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M81VrXQrfSaYjNIFOtt%2Fuploads%2FfbyKaLRUKiKuE09qXCEg%2Fmicr%20sso8.png?alt=media&#x26;token=85e3a4ec-a1fa-44ed-917f-ed605f8a6793" alt=""><figcaption></figcaption></figure>
