Add a SAML v2 with Azure AD IdP

On this page

Configure Azure AD (Microsoft Entra ID) as a SAML v2 Identity Provider. FusionAuth acts as the service provider (SP), and Azure AD acts as the Identity Provider (IdP). The FusionAuth login page then shows a Login with Azure AD button that connects to Azure AD users and applications through SAML.

A FusionAuth login page with a Login with Azure AD button.
A FusionAuth login page with a Login with Azure AD button.
Note

Azure AD is Microsoft Entra ID. But the usage of Azure AD is common. In this document, wherever you see Azure AD, rest assured we mean Microsoft Entra ID as well.

Create an Application in Azure#

Note

This guide uses the SAML single sign-on feature of Azure.

When you already have an Azure AD Enterprise application, skip this section. Otherwise, create an application:

  1. In the Azure portal, navigate to Enterprise Applications .
  2. Click New application .
  3. Click Create your own application .
  4. Enter a name for the application.
  5. Select Integrate any other application you don't find in the gallery (Non-gallery).
  6. Click Create .

The Azure form to create a non-gallery Enterprise application.
The Azure form to create a non-gallery Enterprise application.

Configure Your Azure Application#

On the home screen of your application, click Single sign-on . Then select the SAML option.

The Azure single sign-on options, with SAML available.
The Azure single sign-on options, with SAML available.

Azure AD needs an Entity IDA unique identifier, usually a URL, that names a SAML Identity Provider or Service Provider. The SAML entity Id is unrelated to FusionAuth Entities. from FusionAuth before Azure AD generates an X.509A standard format for public key certificates. certificate. FusionAuth needs an X.509 certificate before you can create the Identity Provider that supplies the Entity ID. To work around the dependency, follow these steps:

  1. Import a placeholder X.509 certificate into Key MasterThe FusionAuth subsystem for managing cryptographic keys..
  2. Create a SAML Identity Provider in FusionAuth with the placeholder certificate.
  3. Update your Azure AD Enterprise application with values from the new Identity Provider. Azure AD then generates a valid X.509 certificate.
  4. Update the SAML Identity Provider in FusionAuth with the certificate from Azure AD.
  5. Complete the integration.

When you already have a valid X.509 certificate, use the certificate in the second step, and skip the placeholder steps.

Import a Placeholder X.509 Certificate#

FusionAuth never uses the placeholder certificate to verify a login, so any valid X.509 certificate works. To generate a placeholder certificate, run the following command:

$ openssl req -x509 -newkey rsa:2048 -nodes -keyout /dev/null -out placeholder.crt -subj "/CN=placeholder" -days 30

The command writes the certificate to placeholder.crt and discards the private key.

Navigate to Settings -> Key Master , click Import Certificate , and paste the contents of placeholder.crt.

The Key Master page in the Admin UI, with the Import Certificate option.
The Key Master page in the Admin UI, with the Import Certificate option.

After you configure Azure AD, Azure AD gives you the X.509 certificate that signs SAML logins.

Create a SAML v2 Identity Provider#

In the FusionAuth Admin UI, navigate to Settings -> Identity Providers -> Add , and select the SAML V2 Identity Provider.

The SAML v2 Identity Provider form in the Admin UI, configured for Azure AD.
The SAML v2 Identity Provider form in the Admin UI, configured for Azure AD.

Complete the following fields:

  • Name: a name that describes the connection, such as Pied Piper Azure AD.

  • IdP endpoint: the Login URL value from your Azure AD application, as shown in the following image.

    The Login URL in step four of the Azure AD SAML configuration.
    The Login URL in step four of the Azure AD SAML configuration.
  • Verification keys: the placeholder certificate that you imported. You replace the placeholder later.

Enable Enable debug logging. FusionAuth then writes debug information to the Event Log. To view the Event Log, navigate to System -> Event Log . Turn off debug logging when you run in production.

Note

For more information about the Event Log, see the Event Logs API and Troubleshooting.

Then click the Applications tab of your SAML v2 Identity Provider, and enable the Identity Provider for the Application.

The Applications tab of the SAML v2 Identity Provider, with the Identity Provider enabled for an Application.
The Applications tab of the SAML v2 Identity Provider, with the Identity Provider enabled for an Application.

When you save the Identity Provider, FusionAuth can show a CORS warning. Follow the instructions on the screen. For more information, see CORS Configuration.

Linking Options#

When you link users by email, configure the SAML Identity Provider to find the email claim. Navigate to Settings -> Identity Providers -> Your SAML IdP -> Edit , and click the Options tab. Then enter the claim in the Email claim field.

The Options tab of the SAML v2 Identity Provider, with a custom email claim.
The Options tab of the SAML v2 Identity Provider, with a custom email claim.

The location of the email claim can vary in an existing Azure AD application. A default Azure AD application uses the following email claim:

http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress
Note

When you aren't sure which claim to use, the Event Log shows the SAML response that Azure sends to FusionAuth.

The SAML response in the Event Log contains the claim. In a default Azure AD application, the email claim is nested:

<AttributeStatement>
    <!-- ... -->
    <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress">
        <AttributeValue>*your*email*</AttributeValue>
    </Attribute>
    <!-- ... -->
</AttributeStatement>

Finish Setup of Azure AD Application#

Next, enter the values from the FusionAuth Identity Provider into your Azure AD application.

Navigate to your Azure AD application. Under step one, click the pencil icon to edit the configuration.

The five steps of the Azure AD SAML configuration.
The five steps of the Azure AD SAML configuration.

Add the Entity ID and Reply URL. To find the values, navigate to Settings -> Identity Providers , and click the magnifying glass in the row of your Identity Provider. The Entity ID is the Issuer value in FusionAuth. Enter the Entity and ACS values from FusionAuth into Azure AD.

The SAML v2 Integration details of the Azure AD Identity Provider in the Admin UI.
The SAML v2 Integration details of the Azure AD Identity Provider in the Admin UI.

Download and Import the X.509 Certificate#

Replace the placeholder certificate with the certificate from Azure AD. On the overview of your SAML application in Azure AD, under step three, download the Certificate (Base64).

The Certificate (Base64) download in step three of the Azure AD SAML configuration.
The Certificate (Base64) download in step three of the Azure AD SAML configuration.

Import the certificate into Key Master: Settings -> Key Master -> Import Certificate .

Then add the new certificate to the Identity Provider: Settings -> Identity Providers -> your SAML IdP -> Verification keys . Remove the placeholder certificate from Verification keys, and delete the placeholder certificate from Key Master.

Tip

Azure AD can publish more than one signing certificate in the federation metadata of the application, such as during a certificate rollover. Import each signing certificate, and add each one to Verification keys. FusionAuth then verifies a SAML response signed with any of the certificates. For more information, see Rotate Identity Provider Certificates.

Configure the FusionAuth Application Redirect URL#

Configure where FusionAuth sends users after the Azure AD login. The redirect URL can be any URL.

Navigate to Applications -> Your Application -> OAuth . Update the Authorized redirect URLs field, and enable the Authorization Code grantAn OAuth 2.0 grant type in which a client exchanges an authorization code for tokens..

The OAuth tab of a FusionAuth Application, with an authorized redirect URL.
The OAuth tab of a FusionAuth Application, with an authorized redirect URL.

Assign Users#

Note

When your existing Azure AD application already has assigned users, skip this step.

Assign Azure AD users to your Azure AD application. Navigate to Users and groups , click Add user/group , and follow the instructions to add a user.

The Azure AD form to add a user to an application.
The Azure AD form to add a user to an application.

Complete the Login#

To test the integration, log in to the FusionAuth Admin UI, and navigate to Applications -> Your Application . Choose View , scroll to the OAuth2 & OpenID Connect Integration details section, and copy the Login URL.

The OAuth2 and OpenID Connect Integration details of a FusionAuth Application, with the Login URL.
The OAuth2 and OpenID Connect Integration details of a FusionAuth Application, with the Login URL.

Open the Login URL in a new tab. The login page shows the Azure AD button from the beginning of this guide. Click the button, and log in as one of the Azure AD users that you assigned. FusionAuth then sends you to your redirect URLThe URL where the authorization server sends the browser after login, with an authorization code or an error..

When the login fails, review the Event Log at System -> Event Log . For help with an invalid signature error, see Invalid Signature Errors.