Connect Azure AD as an identity provider
What you’ll accomplish
Section titled “What you’ll accomplish”You’ll configure Azure Entra ID as a SAML identity provider in Keycloak for both the master and UDS realms so that users authenticate via Azure instead of local Keycloak accounts. Once complete, users will be redirected to Azure when they log in to any UDS Core application.
Prerequisites
Section titled “Prerequisites”- UDS Core deployed
- Azure Entra ID tenant with at least Cloud Application Administrator privileges
- Existing Entra ID groups designated for Admin and Auditor roles in UDS Core
- All users in Entra must have an email address defined — Keycloak requires this to create the user account
Before you begin
Section titled “Before you begin”UDS Core deploys Keycloak with two preconfigured user groups: /UDS Core/Admin (platform administrators) and /UDS Core/Auditor (read-only access). This guide maps existing Azure groups to those groups using Identity Provider Mappers.
You will configure two App Registrations in Azure (one per Keycloak realm) and then set up SAML identity providers in both the master and UDS realms.
-
Create the master realm App Registration in Azure
In Azure Entra ID, navigate to App registrations → New registration and create an application with these settings:
- Supported account types: Accounts in this organizational directory only (Single tenant)
- Redirect URI:
https://keycloak.<admin_domain>/realms/master/broker/azure-saml/endpoint
After creating the registration, configure token claims:
-
Go to Manage → Token configuration
-
Add the following optional claims:
Claim Token type acctSAML emailSAML ipaddrID upnSAML When prompted, enable the Microsoft Graph email and profile permissions.
-
Add a Groups claim: select All groups, accept the default values, and save.
-
Go to Manage → Expose an API, click Add next to “Application ID URI”, and note the resulting URI (format:
api://<Application Client ID>). You will need this value when configuring the SAML identity provider in Keycloak.
-
Create the UDS realm App Registration in Azure
Repeat step 1 to create a second App Registration with these differences:
- Provide a unique name
- Redirect URI:
https://sso.<domain>/realms/uds/broker/azure-saml/endpoint
-
Configure the master realm in Keycloak
Log in to the Keycloak admin UI at
keycloak.<admin_domain>.Disable required actions so Azure-federated users are not prompted to configure local credentials:
- Go to Authentication → Required actions
- Disable all required actions
Create an admin group with realm admin role:
- Go to Groups → Create Group, name it
admin-group - Open the group → Role mapping → Assign role
- Switch to “Filter by realm roles” and assign the
adminrole
Add the Azure SAML identity provider:
- Go to Identity Providers → select SAML v2.0
- Set
Aliastoazure-samlandDisplay nametoAzure SSO - For Service provider entity ID: copy the Application ID URI from the master realm App Registration
- For SAML entity descriptor: paste the Federation metadata document URL from the App Registration’s Endpoints tab; wait for the green checkmark
- Toggle Backchannel logout to On
- Toggle Trust Email to On (under Advanced settings)
- Set First login flow override to
first broker login - Save
Add attribute mappers (go to the provider’s Mappers tab → Add mapper for each):
The attribute names below use the prefix
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/— the Attribute name column shows only the suffix. The groups claim uses a different Microsoft namespace and is shown in full.Mapper name Mapper type Attribute name User attribute Username Mapper Attribute Importer emailaddressusernameFirst Name Mapper Attribute Importer givennamefirstNameLast Name Mapper Attribute Importer surnamelastNameEmail Mapper Attribute Importer emailaddressemailGroup Mapper Advanced Attribute to Group groups(Entra admin group ID)admin-groupSet Sync mode override to
Forcefor all mappers.Create a browser redirect auth flow:
- Go to Authentication → Create flow, name it
browser-idp-redirect - Add an execution → search for
Identity Provider Redirector→ Add - Set requirement to REQUIRED
- Click the gear icon → set
AliastoBrowser IDPandDefault Identity Providertoazure-saml
-
Configure the UDS realm in Keycloak
Switch to the uds realm using the top-left dropdown.
Add the Azure SAML identity provider (same process as step 3, using the UDS realm App Registration values).
Add attribute mappers, including group mappers for both UDS Core groups:
Mapper name Entra group Keycloak group Admin Group Mapper Your Entra admin group’s Object ID /UDS Core/AdminAuditor Group Mapper Your Entra auditor group’s Object ID /UDS Core/Auditor -
Test the configuration
- In the master realm, sign out from the top-right user menu
- On the login page, select Azure SSO
- Complete the Entra login flow
- Confirm you are redirected back to Keycloak admin UI with full admin permissions
-
Finalize: bind the redirect flow and remove the initial admin user
Once Azure login is confirmed working:
- Go to Authentication → find
browser-idp-redirect→ click the three-dot menu → Bind flow → select Browser flow → Save - Go to Users → find the initial admin user → click the three-dot menu → Delete
- Go to Authentication → find
Verification
Section titled “Verification”Confirm Azure identity provider setup is working end-to-end:
- Navigate to
sso.<domain> - Select Azure SSO
- Complete the Entra login flow
- Confirm you can access the Keycloak Account UI
In the Keycloak admin UI, check the UDS realm:
- Identity Providers shows
azure-samlis configured - Users shows federated users appearing after first login
Troubleshooting
Section titled “Troubleshooting”Problem: Login fails after Azure redirect
Section titled “Problem: Login fails after Azure redirect”Symptoms: Error page after completing Entra authentication, or user is not created in Keycloak.
Solution: Confirm all users in Entra have an email address defined. Keycloak requires this field to create a user account — logins for users without an email will fail silently at the federation step.
Problem: Users log in successfully but have wrong group membership
Section titled “Problem: Users log in successfully but have wrong group membership”Symptoms: Users can authenticate but cannot access applications or have unexpected permissions.
Solution: In the Keycloak admin UI, check the group mapper for the affected realm:
- Go to Identity Providers →
azure-saml→ Mappers - Verify the Attribute value in each group mapper matches the exact Entra group Object ID
- In Azure, confirm the user is in the expected Entra group
Problem: “Invalid redirect URI” error in Azure
Section titled “Problem: “Invalid redirect URI” error in Azure”Symptoms: Error after selecting Azure SSO, before reaching the Entra login page.
Solution: Verify the Redirect URI in the Azure App Registration exactly matches the Keycloak broker endpoint for that realm:
- Master realm:
https://keycloak.<admin_domain>/realms/master/broker/azure-saml/endpoint - UDS realm:
https://sso.<domain>/realms/uds/broker/azure-saml/endpoint
Related Documentation
Section titled “Related Documentation”- Identity & Authentication concepts — background on how Keycloak and identity federation work in UDS Core
- Keycloak: Identity Provider Mappers — reference for SAML attribute mapper types
- Azure: Quickstart — Register an application
Next steps
Section titled “Next steps”These guides and concepts may be useful to explore next: