> ## Documentation Index
> Fetch the complete documentation index at: https://www.truefoundry.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Setting up External Auth with SAML Azure

> Configure SAML v2 with Azure AD as an identity provider for external authentication with TrueFoundry.

## Configure SAML v2 for Azure

This documentation will guide you in configuring SAML v2 IdP for Azure. In this case, TrueFoundry will act as Service Provider (SP) to Azure (IdP).

## Create an Application in Azure

1. Log in into your Azure Portal navigate to `Enterprise applications`.
2. At the top of the screen click on `New Application`.

<Frame caption="">
  <img src="https://mintcdn.com/truefoundry/vmoU3Gx28WWGm9Ka/images/saml-azure-create-app.png?fit=max&auto=format&n=vmoU3Gx28WWGm9Ka&q=85&s=56986fcf275849c6b1720130ded01694" width="2274" height="1194" data-path="images/saml-azure-create-app.png" />
</Frame>

3. At `Browse Microsoft Entra App Gallery` page click on `Create your own application`

<Frame caption="">
  <img src="https://mintcdn.com/truefoundry/ByFvWfIx7-jKgBqD/images/saml-azure-create-your-own-application.png?fit=max&auto=format&n=ByFvWfIx7-jKgBqD&q=85&s=a8a0c3b883893a7f56e8e4b8e60bb634" width="3008" height="1540" data-path="images/saml-azure-create-your-own-application.png" />
</Frame>

4. Enter Application name and create application
   In `What are you looking to do with your application?` choose `Integrate any other application you don't find in the gallery (Non-gallery)`

<Frame caption="">
  <img src="https://mintcdn.com/truefoundry/vmoU3Gx28WWGm9Ka/images/saml-azure-application-creation.png?fit=max&auto=format&n=vmoU3Gx28WWGm9Ka&q=85&s=5372ffef8fd702269a9b9e52e858ad7f" width="1178" height="1644" data-path="images/saml-azure-application-creation.png" />
</Frame>

## Configure Your Azure Application

1. In application go to `Single Sign on` and choose SAML

<Frame caption="">
  <img src="https://mintcdn.com/truefoundry/vmoU3Gx28WWGm9Ka/images/saml-azure-sso.png?fit=max&auto=format&n=vmoU3Gx28WWGm9Ka&q=85&s=d5a4a21ca622ce9fa560e1e4fea5eec7" width="3016" height="1330" data-path="images/saml-azure-sso.png" />
</Frame>

2. Edit `Basic SAML Configuration`

* **Identifier (Entity ID)**: This is unique ID that identifies your application to Microsoft Entra ID. This is generally control plane URL.

```
     <control-plane-url>/deployments?tab=services
```

* **Reply URL (Assertion Consumer Service URL)**: This is ACS endpoint which can be obtained from truefoundry.

```
    <control-plane-url>/api/svc/v1/saml/acs
```

* **Relay State**: This is endpoint where user will be redirected after being authenticated. This is generally control plane URL.

```
     <control-plane-url>/deployments?tab=services
```

<Frame caption="">
  <img src="https://mintcdn.com/truefoundry/vmoU3Gx28WWGm9Ka/images/saml-azure-basic-saml-configuration.png?fit=max&auto=format&n=vmoU3Gx28WWGm9Ka&q=85&s=1c16f6a4ef3c49b99c0f456f957ee515" width="1710" height="1612" data-path="images/saml-azure-basic-saml-configuration.png" />
</Frame>

once SSO is Configured download the SAML Certificates(Recommended Base64) it will be required later.

3. Attributes & Claims:

* Add Required Claim
  click and on Claim name `Unique User Identifier`
  set Name identifier format as `Email address` and Source attribute as `user.userprincipalname`

<Frame caption="">
  <img src="https://mintcdn.com/truefoundry/MMr_lFGYMwcxFTFb/images/docs/saml-azure-required-claim.png?fit=max&auto=format&n=MMr_lFGYMwcxFTFb&q=85&s=befe5ab485b442f2ef8bfac643a21a24" width="2674" height="1004" data-path="images/docs/saml-azure-required-claim.png" />
</Frame>

* Add Additional Claims
  Please do not make changes to already predefined Additional Claims.
  Click on Add new claim at top left and add three new claims `firstName`, `lastName` and `email` one by one.
  Addition of firstName is illustrated in the below picture

<Frame caption="">
  <img src="https://mintcdn.com/truefoundry/MMr_lFGYMwcxFTFb/images/docs/saml-azure-firstName.png?fit=max&auto=format&n=MMr_lFGYMwcxFTFb&q=85&s=beb42c57f08dd02840b76c388f839f22" width="1880" height="876" data-path="images/docs/saml-azure-firstName.png" />
</Frame>

our final list of claims should be like as shown below

<Frame caption="">
  <img src="https://mintcdn.com/truefoundry/MMr_lFGYMwcxFTFb/images/docs/saml-azure-final-claim.png?fit=max&auto=format&n=MMr_lFGYMwcxFTFb&q=85&s=86412a2724ad0e609fc16225c0a0e20d" width="1750" height="1238" data-path="images/docs/saml-azure-final-claim.png" />
</Frame>

## Integrate with TrueFoundry

To integrate Azure application with TrueFoundry, Add the following configuration to env Variables

* **OAUTH\_PROVIDER\_TYPE** : `EXTERNAL_SAML`
* **EXTERNAL\_SAML\_IDP\_ENDPOINT**: This is `User access URL` which can be obtained from application by navigating to properties tab.

<Frame caption="">
  <img src="https://mintcdn.com/truefoundry/MMr_lFGYMwcxFTFb/images/docs/saml-azure-access-url.png?fit=max&auto=format&n=MMr_lFGYMwcxFTFb&q=85&s=2f02ad2070034565c11d057ccfd0969c" width="2134" height="1614" data-path="images/docs/saml-azure-access-url.png" />
</Frame>

* **EXTERNAL\_SAML\_CERTIFICATE**: Encode the the Certificate that we download earlier by Base64 Encoder and set it here.

<Frame caption="">
  <img src="https://mintcdn.com/truefoundry/MMr_lFGYMwcxFTFb/images/docs/saml-azure-certificate.png?fit=max&auto=format&n=MMr_lFGYMwcxFTFb&q=85&s=90e21bbc321ed4f6449b000295a9ffd8" width="1606" height="1344" data-path="images/docs/saml-azure-certificate.png" />
</Frame>

* **EXTERNAL\_SAML\_ACCESS\_TOKEN\_EXPIRY\_SECONDS**: This is duration of access token that will be asigned to user, so keep it as required.

***
