Azure Entra ID
This guide will walk you through the steps required to configure Azure Entra ID as a SAML identity provider in Keycloak.
Prerequisites
- Access to your Azure Entra ID Tenant, with at least Cloud Application Administrator Privileges.
- Existing Entra ID Groups that are designated for Administrators and Auditors of UDS Core Applications (see note below).
- VERY IMPORTANT Users configured in Entra are REQUIRED to have an email address defined, without this Keycloak will fail to create the user.
UDS Core comes with two preconfigured user groups in Keycloak:
Admin
andAuditor
. These groups are assigned roles to the various applications deployed by UDS Core, outlined here. Using Identity Provider Mappers in Keycloak, we can map your existing Administrator and Auditor groups in Azure Entra ID to theAdmin
andAuditor
groups in Keycloak. See User Groups for more details.
Creating Application Registrations in Azure Entra ID
In this section, we will configure Application Registrations for each Keycloak realm deployed with UDS Core - the default master
realm and the uds
realm. The two App Registrations should be nearly identical, with the main difference being their Redirect URI
.
Create App Registration - Master Realm
- In Azure Entra ID, navigate to the “App registrations” page under “Manage”.
- Click “New registration”.
- Input a name for the application.
- Under “Supported Account Types”, select “Accounts in this organizational directory (
only - Single tenant)”. - Under “Redirect URI”, select “Web” from the drop down menu and then input the following as the URL:
https://keycloak.<admin_domain>/realms/master/broker/azure-saml/endpoint
. - Click “Register” when done.
Once created, you will be directed to your application’s configuration page in Entra ID. Follow the steps below to configure the App Registration:
-
On the left-hand side, navigate to “Manage” > “Token configuration”. Here you will need to add the following as “Optional claims”:
Claim Token Type acct
SAML email
SAML ipaddr
ID upn
SAML
When adding these claims, a dialogue box will appear that says “Some of these claims (email, upn) require OpenID Connect scopes to be configured through the API permissions page or by checking the box below.”. Select the checkbox that says “Turn on the Microsoft Graph email, profile permission (required for claims to appear in token). Click “Add”.
- You will also need to add a “Groups claim” as follows:
- Select “All groups” under “Select group types to include in Access, ID, and SAML tokens.” Accept the default values for the rest.
- Click “Add” when done.
- Next, Navigate to “Expose an API” under “Manage”
- On the top of the page, you will see “Application ID URI”. Click “Add”.
- The window that appears should automatically populate with
api://<Application (Client ID)>
. Note this value. You will need it for configuring the Azure SAML Identity Provider in Keycloak later. - Click “Save”.
Create App Registration - UDS Realm
Repeat the steps above to create a new App Registration for the UDS Realm. Note the following caveats below:
- When you get to step 3, ensure that you provide the Application Registration a unique name.
- When asked to provide a “Redirect URI”, provide the following:
https://sso.<domain>/realms/uds/broker/azure-saml/endpoint
- Continue with next steps.
Keycloak Azure Entra Identity Provider Setup
-
Log into Keycloak Admin UI
keycloak.< admin_domain >
- The Keycloak admin username and password varies based on how UDS Core is deployed
- If deploying with the bundle override
INSECURE_ADMIN_PASSWORD_GENERATION
- The username will be
admin
and the password will be in a Kubernetes secret calledkeycloak-admin-password
- The username will be
- If not deploying with bundle override
- An admin user will need to be registered by using
zarf connect keycloak
- This temporary admin user is recommended to be removed later
- An admin user will need to be registered by using
- If deploying with the bundle override
-
Both Master and UDS Realms should be created by deploying UDS Core
- Verify this in the Top Left dropdown
Master Realm
-
Configure the Required Actions
-
Select
Authentication
tab from left side nav bar under Configure -
Select
Required actions
tab from top nav bar -
Now disable all required actions
- These required actions are configurations that every user registered to the Master realm will need to complete, even if they register via an Identity Provider like Entra. This can add unnecessary checks that a user will need to configure when they register. Since we are shifting all authorization to Azure Entra, these will be repetitive validations.
-
-
Configure User Groups and Realm Roles
-
Select
Groups
tab from left side nav bar under Manage -
Select
Create Group
button in the middle of the page -
Name that group
admin-group
and select theCreate
button -
Select the newly created
admin-group
, this will open aGroup details
page -
Select
Role Mapping
tab from top nav bar -
Select
Assign role
button in the middle of the page -
On the pop up page, Select the
Filter by clients
dropdown in the top left and selectFilter by realm roles
-
This should be a much smaller list, now toggle the
admin
role and clickAssign
in the bottom left corner
- This creates a Master Realm specific group for admin users to be put into when they register. This group will be mapped from the Entra user into Keycloak. This group gives the admin users complete control, if the admin users should not have those controls then creating a different role with the reuiqred controls would be necessary and a group that is connected to that role.
-
-
Configure the SAML Identity Provider for Azure
-
Select
Identity Providers
tab from left side nav bar under Manage -
Select
SAML v2.0
option from middle of page underUser-defined
- Should be on a new page called
Add SAML provider
now - Change the
Alias
field toazure-saml
- Change the
Display name
field toAzure SSO
- Get the
Service provider entity ID
from the Entra portal:- Entra - App Registrations
- Select Application from list for master realm
- Copy the
Application ID URI and copy that the
Service provider entity ID` in the Keycloak Identity Provider creation
- Get the
SAML entity descriptor
from the Entra portal:- Entra - App Registrataions
- Select Application from list for master realm
- Select the
Endpoints
tab from top nav bar - Copy the
Federation metadata document
endpoint over to theSAML entity descriptor
in the Keycloak Identity Provider creation, make sure that it gets the green checkmark
- Select
Add
button, should now see an Azure SSO page that has been auto populated - Toggle
Backchannel logout
toOn
underSAML Settings
- Toggle
Trust Email
toOn
underAdvanced settings
- Change the
First login flow override
underAdvanced settings
to befirst broker login
- Select
Save
- Should be on a new page called
-
Select
Mappers
tab from top nav bar- Select
Add mapper
, should now be onAdd Identity Provider Mapper
page- Change
Name
field toUsername Mapper
- Change
Sync mode override
field toForce
- Change
Mapper type
field toAttribute Importer
- Change
Attribute Name
field tohttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress
- Change
User Attribute Name
in the dropdown field tousername
- Select
Save
and navigate back toProvider details
via the breadcrumbs at top of page
- Change
- Select the
Add mapper
- Change
Name
field toFirst Name Mapper
- Change
Sync mode override
field toForce
- Change
Mapper type
field toAttribute Importer
- Change
Attribute Name
field tohttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname
- Change
User Attribute Name
in the dropdown field tofirstName
- Select
Save
and navigate back toProvider details
via the breadcrumbs at top of page
- Change
- Select the
Add mapper
- Change
Name
field toLast Name Mapper
- Change
Sync mode override
field toForce
- Change
Mapper type
field toAttribute Importer
- Change
Attribute Name
field tohttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname
- Change
User Attribute Name
in the dropdown field tolastName
- Select
Save
and navigate back toProvider details
via the breadcrumbs at top of page
- Change
- Select the
Add mapper
- Change
Name
field toEmail Mapper
- Change
Sync mode override
field toForce
- Change
Mapper type
field toAttribute Importer
- Change
Attribute Name
field tohttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress
- Change
User Attribute Name
in the dropdown field toemail
- Select
Save
and navigate back toProvider details
via the breadcrumbs at top of page
- Change
- Select the
Add mapper
-
Change
Name
field toGroup Mapper
-
Change
Sync mode override
field toForce
-
Change
Mapper type
field toAdvanced Attribute to Group
-
Select
Add Attributes
from middle of page -
Enter key
http://schemas.microsoft.com/ws/2008/06/identity/claims/groups
and value is in the EntraManage Groups
, Pick the admin group and copy the Group ID into the value field -
Select
Select group
button -
Select
admin-group
from the pop up window and clickSelect
-
Select
Save
and navigate back toProvider details
via the breadcrumbs at top of page
-
- This creates mappers for mapping users information between Entra and Keycloak. While not absolutely necessary there is many reasons why this is a good idea. Make sure the Entra group that is for admins is very restrictive and only users that should have control of keycloak are admitted.
- Select
-
-
Configure Authentication Flows and default Browser Flow
-
Select
Authentication
from left side nav bar under Configure -
Select
Create Flow
from top nav bar, should be onCreate flow
page now- Change
Name
tobrowser-idp-redirect
- Select
Create
, should be onbrowser-idp-redirect
page now, this is not in use yet - Select
Add an execution
- In the search bar enter
redirector
and select theIdentity Provider Redirector
, and clickAdd
- Change the requirement dropdown to
REQUIRED
- Select the gear settings icon
- Change
Alias
toBrowser IDP
- Change
Default Identity Provider
toazure-saml
- Change
-
Select the
Authentication
breacrumb at the top of the page
- We have created an Identity Provider and we have disabled the use of username passwords for admin users. So we need to disable the final route for admin users to utilize those passwords.
-
-
OPTIONAL but recommended - Configure a Client for service account authentication
-
Select
Clients
from left side nav bar under manage -
Select
Create client
from top nav bar -
Change
Client ID
field toservice-client
-
Change
Name
field toService Client
-
Change
Description
field toService Account Enabled Client
-
Select
Next
button from bottom of page -
Toggle
Client authentication
toOn
-
Toggle
Standard flow
toOff
-
Toggle
Direct access grants
toOff
-
Toggle
Service account roles
toOn
-
Select
Next
button from bottom of page -
Select
Save
button from bottom of page -
Should be on the
service-client
client details page now -
Select the
Service accounts roles
tab from top nav bar -
Select
Assign role
-
Switch the
Filter by clients
dropdown toFilter by realm roles
-
Select the
admin
role and clickAssign
at bottom of pop up
- This step creates a Keycloak client that can only be used via service accounts. This means things like Terraform or otherwise. Instead of providing a users credentials to run terraform against keycloak, the client_id and client_secret could be used instead. The
client_id
can be found on the client details page and theclient_secret
can be found in theCredentials
tab of the client. This is not necessary but can provide another avenue to manage day 2 ops for Keycloak.
-
-
Testing Changes
This requires that user be setup in Entra and have the correct group defined in Entra that maps to the Keycloak admin group created earlier
-
We would recommend testing all of these changes at this point to verify functionality of Authentication flows
-
Select the
Admin
user drop down from top right corner of screen -
Select
sign out
-
Should be redirected to a Keycloak login screen where Username/Password is enabled and an
Azure SSO
option is present
-
We will disable the Username/Password Authentication Flow after we’ve tested that everything is working otherwise if anything is misconfigured, you won’t be able to get back in and will have to start this process over again.
- Select the
Azure SSO
option - Should experience some redirects and land on Entra Login page
- Enter Entra Users information
- Should be redirected to the Admin UI again with full permissions
-
-
FINALLY
-
When configuration of Keycloak is complete and everything is working, do these final steps:
-
Disable Username Password Auth
-
Select
Authentication
from left side nav bar under Configure -
Find the newly created
browser-idp-redirect
Authentication Flow -
Select the three dots at the far right of the row
-
Select the
Bind flow
option -
Select the
Browser flow
from the dropdown and clickSave
- Since we are shifting authentication to Entra, we setup an Authentication flow that automatically redirects users to Entra when they need to login or register. This mitigates both confusion and misconfigurations.
-
-
Remove the admin user that was initial created
-
Select
Users
tab from left side nav bar under Manage -
This next step will remove you from Keycloak if you’re still using the temp admin user
-
Select the three dots from the far right of admin row
-
Select
Delete
- This user is a requirement for keycloak to be accessed and configured the very first time. So by default this user is a super user and should be removed so that a user cannot assume the admin users creds.
-
-
UDS Realm
- Configure the SAML Identity Provider for Azure
-
Select
Identity Providers
tab from left side nav bar under Manage -
Select
SAML v2.0
option from middle of page underUser-defined
- Should be on a new page called
Add SAML provider
now - Change the
Alias
field toazure-saml
- Change the
Display name
field toAzure SSO
- Get the
Service provider entity ID
from the Entra portal:- Entra - App Registrations
- Select Application from list for master realm
- Copy the
Application ID URI
and copy that theService provider entity ID
in the Keycloak Identity Provider creation
- Get the
SAML entity descriptor
from the Entra portal:- Entra - App Registrataions
- Select Application from list for master realm
- Select the
Endpoints
tab from top nav bar - Copy the
Federation metadata document
endpoint over to theSAML entity descriptor
in the Keycloak Identity Provider creation, make sure that it gets the green checkmark
- Select
Add
button, should now see an Azure SSO page that has been auto populated - Toggle
Backchannel logout
toOn
underSAML Settings
- Toggle
Trust Email
toOn
underAdvanced settings
- Change the
First login flow override
underAdvanced settings
to befirst broker login
- Select
Save
- Should be on a new page called
-
Select
Mappers
tab from top nav bar- Select
Add mapper
, should now be onAdd Identity Provider Mapper
page- Change
Name
field toUsername Mapper
- Change
Sync mode override
field toForce
- Change
Mapper type
field toAttribute Importer
- Change
Attribute Name
field tohttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress
- Change
User Attribute Name
in the dropdown field tousername
- Select
Save
and navigate back toProvider details
via the breadcrumbs at top of page
- Change
- Select the
Add mapper
- Change
Name
field toFirst Name Mapper
- Change
Sync mode override
field toForce
- Change
Mapper type
field toAttribute Importer
- Change
Attribute Name
field tohttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname
- Change
User Attribute Name
in the dropdown field tofirstName
- Select
Save
and navigate back toProvider details
via the breadcrumbs at top of page
- Change
- Select the
Add mapper
- Change
Name
field toLast Name Mapper
- Change
Sync mode override
field toForce
- Change
Mapper type
field toAttribute Importer
- Change
Attribute Name
field tohttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname
- Change
User Attribute Name
in the dropdown field tolastName
- Select
Save
and navigate back toProvider details
via the breadcrumbs at top of page
- Change
- Select the
Add mapper
- Change
Name
field toEmail Mapper
- Change
Sync mode override
field toForce
- Change
Mapper type
field toAttribute Importer
- Change
Attribute Name
field tohttp://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress
- Change
User Attribute Name
in the dropdown field toemail
- Select
Save
and navigate back toProvider details
via the breadcrumbs at top of page
- Change
- Select the
Add mapper
- Change
Name
field toAdmin Group Mapper
- Change
Sync mode override
field toForce
- Change
Mapper type
field toAdvanced Attribute to Group
- Select
Add Attributes
from middle of page - Enter key
http://schemas.microsoft.com/ws/2008/06/identity/claims/groups
and value is in the EntraManage Groups
, Pick the admin group and copy the Group ID into the value field - Select
Select group
button - Select
/UDS Core/Admin
from the pop up window and clickSelect
- Select
Save
and navigate back toProvider details
via the breadcrumbs at top of page
- Change
- Select the
Add mapper
- Change
Name
field toAuditor Group Mapper
- Change
Sync mode override
field toForce
- Change
Mapper type
field toAdvanced Attribute to Group
- Select
Add Attributes
from middle of page - Enter key
http://schemas.microsoft.com/ws/2008/06/identity/claims/groups
and value is in the EntraManage Groups
, Pick the auditor group and copy the Group ID into the value field - Select
Select group
button - Select
/UDS Core/Auditor
from the pop up window and clickSelect
- Select
Save
and navigate back toProvider details
via the breadcrumbs at top of page
- Change
- Select
-
Testing
- Navigate to
sso.< domain >
- Select the
Azure SSO
- Go through Entra Login
- Should be able to access Keycloak Account UI