How Keycloak brokers Microsoft Entra ID sign-in for your workforce
Keep Microsoft Entra ID as the workforce login and place Keycloak in front of your internal applications as a broker. Users authenticate at Entra ID, Entra ID returns an identity to Keycloak, and Keycloak then issues its own tokens to each client application. The applications trust Keycloak, not Entra ID directly, so you gain one place to define client registrations, token contents and access rules, while sign-in itself still happens in your existing tenant. Keycloak becomes the token issuer for the applications, and Entra ID remains the authentication authority.
There are two ways to add Entra ID to a realm. The Microsoft social provider is documented in the Keycloak server administration guide and is the more specific option for Microsoft accounts. A generic OpenID Connect identity provider lets you enter the endpoints and client settings yourself and is the usual choice when you need control over the tenant-specific configuration. The choice determines which settings the admin console exposes, so confirm the options available in your Keycloak version before you write the design, and check the current guide rather than relying on a screenshot from an older release. Record the decision, because switching later changes the provider alias, mappers and any stored links to existing users.
Brokering does not move the directory's role in your environment. Entra ID remains the source of truth for passwords, MFA enrollment, conditional access policies and account disablement, so a user blocked in Entra ID cannot complete a new Keycloak login through that provider. Keycloak may still hold local data about the user, such as sessions, attributes and role assignments, and an active Keycloak session can outlive the upstream decision unless you set session and token lifetimes deliberately. Ask your security team to confirm which Entra ID policies apply to sign-in from Keycloak, and test a blocked account end to end before go-live.
What you need before you configure the Entra ID provider
Five decisions and checks come before any Entra ID settings are touched. Each one changes what you register in Entra, what Keycloak must reach, and which identity source is authoritative for the users who sign in.
Keycloak version and deployment mode
Pin the Keycloak release line you will run before you build the provider, since the release notes, mapper behavior and admin console layout can change between minor releases. The current release is 26.8.1, published October 13, 2026. Confirm whether you will run it on containers, the Operator or virtual machines, and record the exact version in your change plan so the provider configuration is tested against the same build you deploy.
Keycloak docsHostname, TLS and reverse proxy
Give Keycloak a stable public hostname with TLS on every connection, fronted by a reverse proxy with path restrictions. Entra ID redirects the browser back to Keycloak's broker endpoint, so that URL must match exactly what you register. Decide now whether the admin console and Administration REST API sit on a separate hostname or context path from public frontend URLs, because changing the hostname later means re-registering the redirect URI.
Production guideEntra tenant rights and consent
Confirm that you hold rights to register applications in the target Microsoft Entra tenant and that someone with the authority to grant admin consent is available for the permissions the provider requests. Without that consent, sign-in can fail for every user in a way that looks like a Keycloak fault. Ask the tenant administrators whether any conditional access or app consent policy blocks new enterprise applications.
Identity source of record for each user
Establish which system owns each workforce account before configuration begins. In a hybrid setup, on-premises Active Directory identities sync to Entra ID through Microsoft Entra Connect, so attributes such as the UPN, email and group membership may originate on-premises. Confirm the source of record for each attribute Keycloak will map, because a claim edited in the wrong system will change access in Keycloak on the next login.
Entra and AD comparisonNetwork paths to Entra endpoints
Keycloak must reach the Microsoft identity endpoints over HTTPS for discovery, token exchange and key retrieval, and the browser must reach both Keycloak and Entra during sign-in. Map outbound egress rules, proxies and DNS resolution from every Keycloak node, not only one. Test from a node in each network zone, because a blocked backchannel call often surfaces only after the first login attempt.
Redirect URIs and tenant scope
Decide which Keycloak realm and broker endpoint URIs you will register, and whether one Entra application serves several realms or each realm gets its own. Also decide whether sign-in is limited to a single tenant or accepts several, since that choice controls which accounts can reach Keycloak at all. Write both decisions down before registration, because redirect URI mismatches are a frequent first-run failure.
How a sign-in travels from the application through Keycloak to Entra ID
The sign-in starts in the application, which redirects the user's browser to Keycloak as its OpenID Connect provider. Keycloak, acting as the broker, redirects the browser onward to Microsoft Entra ID, where the user authenticates against the tenant. Entra ID returns an authorization code through the browser, and Keycloak exchanges that code on the back channel for the upstream tokens and user claims. Keycloak then issues its own tokens to the application, so the trust boundary sits where Keycloak accepts Entra ID's identity. Check that the tenant restriction, the client secret handling and the claims Keycloak maps are all configured at that boundary.
Sign-in flow from the application through Keycloak to Entra ID, with the trust boundary marked.
Microsoft provider or generic OIDC provider: which one to choose
The Microsoft provider is a social-style identity provider type that Keycloak documents in the server administration guide. It ships with the endpoints and default settings for Microsoft identity platform, so the administrator mainly supplies the application (client) ID, the client secret and the tenant-related settings the provider exposes. This suits teams that want Keycloak to carry the Microsoft-specific details and that prefer to change fewer fields by hand.
- Fewer fields to maintain: Endpoints and the standard Microsoft defaults come from the provider type, so there are fewer values to copy from the Entra admin center.
- Documented path: Steps appear in the administration guide for each Keycloak release, which helps reviewers trace the configuration.
- Less control over edge cases: Unusual tenant setups, custom claims or non-standard scopes may need settings the built-in form does not expose.
- Upgrade behavior follows the provider: Changes to the provider type arrive with Keycloak releases, so test sign-in after each upgrade.
- Vendor-specific behavior: Confirm how the provider handles the Microsoft identifiers and email claims your tenant issues.
Confirm the field list and defaults against the Keycloak documentation for your installed version before you write the configuration down.
A generic OpenID Connect provider means your team enters the issuer, authorization, token, userinfo and JWKS endpoints, the scopes, and the mapping of claims to Keycloak user attributes. Keycloak uses these values to validate ID tokens and build the user record, so each one needs a deliberate value. This option fits teams that need claim handling the built-in provider does not cover, or that must keep one consistent provider pattern across several identity sources.
- Manual endpoint and issuer values: Copy the issuer and endpoints from the tenant's OpenID configuration and check them after any tenant change.
- Scope and claim decisions: Decide which scopes to request and which claims map to username, email and first-login attributes.
- Upgrade exposure: Keycloak changes to the generic provider logic can affect your settings, and no provider-specific defaults will correct a wrong value for you.
- Testing burden: Each configuration change needs a sign-in test with real tenant accounts, including accounts without the expected claims.
- Ownership: Someone must own the endpoint values, claim mappings and the runbook that explains them.
Before you choose this option, check the current OIDC provider settings in the Keycloak server administration guide for your version and record each value with its source.
The right provider type depends less on the protocol than on four practical questions. Start with tenant scope: whether one tenant or several will sign in, and whether guest users from other tenants must be allowed. Then list the claims your applications need, such as stable identifiers, email, and roles. Group handling matters because group membership and app roles may arrive as IDs, names or overage references that need separate treatment. Finally, decide who will maintain the configuration after go-live.
- Tenant scope: A single workforce tenant with a fixed domain list is simpler to configure than multi-tenant or guest sign-in.
- Required claims: Write down each claim your applications read and confirm the token includes it under your tenant's settings.
- Group and role handling: Decide whether Keycloak imports groups, maps app roles, or reads them on each login.
- Maintenance ownership: A platform team with Keycloak experience can maintain a generic provider, while a smaller team may prefer fewer hand-set values.
- Change control: Record who approves changes to endpoints, scopes and mappers, and who runs the sign-in test afterward.
Ask your identity team to confirm tenant type, guest policy and the claims in a test token before you pick a provider type.
Configuring Entra ID as an identity provider in Keycloak step by step
This sequence takes a target Keycloak realm from a registered Entra ID application to a verified workforce sign-in and a client application receiving the claims it expects. Each step closes with a check so the team knows whether to continue.
Register the application in Entra ID
An Entra ID administrator creates an app registration in the tenant that holds your workforce accounts and adds the Keycloak broker redirect URI for the target realm, using the exact callback path your Keycloak version generates for its identity provider. Record the application (client) ID and the directory (tenant) ID, and confirm the redirect URI matches the one shown in Keycloak's identity provider settings character for character. The step is done when the registration lists that redirect URI and no unrelated URIs.
Create the client secret or certificate
In the app registration, the administrator creates a client secret or uploads a certificate, then stores the value in your organization's secrets store with an owner and a rotation date. Do not paste the secret into tickets, chat or shared documents. The step is done when the secret or certificate is stored, the Entra ID expiry date is recorded in your calendar, and someone other than the creator can locate the stored item.
Configure the identity provider in the target realm
A Keycloak administrator opens the target realm, chooses the Microsoft provider or a generic OpenID Connect provider, and enters the client ID and secret, with the tenant-specific issuer and endpoints if using the generic option. Confirm the provider's trust settings, such as whether to trust email from the provider, only after you have reviewed how verified email is set for your tenant. The step is done when the provider is saved and the realm login page shows the provider button in a private browser session.
Restrict sign-in to your tenant
Set the provider so only accounts from your own Entra ID tenant can complete sign-in, by using the tenant-specific endpoints rather than the multi-tenant common endpoint, and confirm the token issuer your Keycloak instance accepts matches that tenant. Test this with an account from a different directory if you have one available. The step is done when a sign-in attempt from outside the tenant is rejected and the tenant's own pilot account is accepted.
Set scopes and map claims
Choose the scopes Keycloak requests from Entra ID, such as the standard OpenID scopes, and decide which claims you need for roles and groups. Entra ID group claims can be large or replaced by overage handling, and group object IDs are not the same as group names, so confirm which form your mappers expect before you build them. The step is done when a test sign-in shows the expected identity claims in the Keycloak identity provider mapper preview or logs.
Run a pilot sign-in with a non-admin user
Choose a pilot user who holds no Entra ID or Keycloak administrator role, then sign in through the brokered button in the target realm. Check that Keycloak creates or links the user as intended, that the account lands with the expected attributes and that the first login flow behaves as your design says, including any account linking prompt. The step is done when the pilot user reaches the Keycloak account page with the correct username, email and mapped roles, and the Keycloak event log records a successful identity provider login.
Add a client application and inspect its tokens
Register a test client in the same realm, with a redirect URI for a non-production application, and sign in as the pilot user. Decode or inspect the access and ID tokens the client receives to confirm the issuer, audience, subject, email and mapped role or group claims. Compare them against the claims your application requires before any production client is added. The step is done when the token contents match the written claim specification for that client and any missing or extra claims are explained.
Document the configuration and confirm the rollback path
Record the redirect URI, provider settings, scopes, mappers, tenant restriction and test results in your configuration record, and note which items live in the secrets store. Confirm who can disable the provider and how users would sign in if Entra ID is unavailable, such as through a local realm account reserved for administrators. The step is done when the record is reviewed by the platform owner and a second administrator can repeat the pilot sign-in from the documentation alone.
Which Entra ID attributes and claims map to Keycloak users and roles
This table pairs each Entra ID source attribute or claim with the Keycloak field or identity provider mapper it feeds and the decision your team must settle before go-live. Read it top to bottom as a checklist, since the subject identifier and group format decisions are hard to change once users have logged in. Treat sync-on-login behavior as part of each mapping choice, not a later tuning step.
| Entra ID source | Keycloak field or mapper | Decision the team must make |
|---|---|---|
| Stable subject identifier (sub or oid) | Federated identity link for the Microsoft provider, matched on the upstream user ID | Use the immutable subject value, not the UPN or email, so renamed or re-addressed users keep their Keycloak account |
| User principal name (UPN) or preferred username | Keycloak username, usually via the username import mapper | Decide whether usernames follow UPN format and how to resolve collisions with existing local accounts |
| Email claim | Keycloak email attribute, set on first login and optionally on each login | Decide whether Keycloak overwrites email on every sign-in or only at account creation |
| Verified email status | Account linking and trust rules for an existing Keycloak user with the same email | Decide whether unverified emails may trigger automatic linking, and require verification before linking to a local account |
| Group membership claim (group object IDs) | Claim-based identity provider mapper into Keycloak groups or roles | Choose object IDs for stable mapping across group renames, or display names for readability, and maintain a lookup table either way |
| Group overage or omitted group claim | Fallback path such as Microsoft Graph lookup or a reduced group scope, if your design requires it | Large group lists can cause Entra ID to omit the groups claim. Confirm the current limits and fallback guidance in Microsoft's documentation before designing role mapping |
| App roles assigned in the Entra enterprise application | Roles claim mapped to Keycloak client or realm roles | Decide whether app roles or groups are the authorization source, since using both invites drift between systems |
| Optional claims and user attributes (department, employee ID, job title) | Keycloak user attributes via attribute mappers, and token claim mappers for downstream clients | Limit what is copied into Keycloak to attributes that applications need, and document the owner and source of each |
| Sync mode per mapper (import on first login or every login) | Identity provider mapper sync mode setting | Choose import-only for values Keycloak administrators may change locally, and force-on-login for values that must follow Entra ID, then test removal of a group membership |
How first-login account linking avoids duplicate users
The first Entra ID sign-in is the moment most likely to create duplicate users. A person may already exist in the Keycloak realm as a local account, or as a user imported through LDAP or Active Directory federation, and the Entra ID login arrives as a new identity link. Keycloak's identity provider settings decide whether that login attaches to the existing user or creates a second one. The matching key is the value Keycloak compares, usually the email address or a stable identifier such as the subject from the token, and that choice has to be made before go-live because changing it later means reconciling accounts that have already been linked.
Keycloak offers two broad approaches. Automatic linking attaches the Entra ID identity to the existing user without a prompt, which suits a workforce where the upstream directory is the authority and the claim used for matching is verified and controlled by the organization. The review approach stops at a page that asks the user to confirm the link by signing in with the existing credentials, such as their local password or a second factor. That step costs the user a moment but protects against linking to the wrong account. Linking on an unverified email is the main risk: if a user can set or assert an email value that matches someone else's account, the login can take over that account. Confirm with your Entra ID configuration whether the email claim is trustworthy for your tenant before you rely on it.
Test the decision with deliberately confusing data before users arrive. Create duplicate-looking accounts: the same name with a different username, a local account and an imported directory account that share an email, and a user whose primary address changed. Run first logins through Entra ID for each and check which user receives the link, what the linking page shows, and whether the existing user's roles and attributes are the ones expected. Record the outcome as a test case so the matching key and flow can be re-verified after any change to the provider or the realm.
Security settings that protect the Entra ID trust
A brokered Entra ID login is only as trustworthy as the settings around it. The cards below cover the tenant boundary, the permissions and secrets behind the app registration, the token checks Keycloak runs on upstream responses, and the clients and logs that consume the brokered identity. Confirm each setting name against the Keycloak documentation for your release before you change production.
Restrict sign-in to one tenant
Configure the Entra ID provider so only your own tenant can authenticate. A multi-tenant or common endpoint lets accounts from other Entra tenants sign in to Keycloak. Check the tenant or issuer setting in the provider configuration, then test with an account from a second tenant to confirm it is rejected. Treat the tenant restriction as a required control, not a default.
Keycloak docsScope Graph permissions and consent
Request only the delegated or application permissions the login and group lookup need, and keep admin consent with a named owner. Broad directory permissions let a compromised Keycloak client read far more than sign-in data. Review granted permissions after each provider change, and confirm which permissions your configured flow actually uses in the current Microsoft documentation.
Rotate and store client credentials
The app registration uses either a client secret or a certificate. Secrets expire, so record the expiry date and set a rotation owner before it lapses. Store the value in a secrets manager or the Keycloak secret configuration rather than in realm exports or Git. Where your policy allows, prefer a certificate and confirm that Keycloak supports it for your provider type.
Validate upstream token signatures
Keycloak must verify the signature and issuer of the ID token it receives from Entra ID, and reject tokens with the wrong audience. Check that signature validation is on and that the configured signing keys come from the tenant's discovery endpoint. Keep server clocks synchronized with NTP, because token lifetime checks fail when clocks drift and skewed clocks are a common cause of intermittent login errors.
Limit which clients accept brokered users
Brokered identities should reach only the Keycloak clients that need Entra ID sign-in. Disable the provider on the login page for clients that should use local accounts, and review each client's allowed identity provider or authentication flow settings. A client that accepts any brokered identity inherits the trust of the whole Entra tenant, so map this list in your design before rollout.
Log failed brokered logins
Failed Entra ID logins show up as events in Keycloak's event store, and admin events record changes to the provider. Enable login event logging, decide retention with your security team, and forward events to your SIEM. Check which event types your release records and whether failed logins are persisted to the database by default in your version, since upgrade notes have changed this behavior.
Metrics guideCommon failures when Entra ID sign-in breaks in Keycloak
This table pairs common Entra ID brokering symptoms with their likely causes and the settings to check first. Read it by matching the error a user or administrator sees to a row, then working through the listed settings in the Entra app registration and the Keycloak identity provider configuration. Most failures trace back to a small set of mismatches in redirect URIs, tenant scope, consent, claims and account linking.
| Symptom | Likely cause | Fix |
|---|---|---|
| Redirect URI mismatch error from Entra ID after clicking the provider | The redirect URI in the Entra app registration does not exactly match the Keycloak broker endpoint for that identity provider alias | Compare the registered redirect URI character by character with the broker endpoint shown in the Keycloak provider settings, including scheme, host, realm and alias, then correct the registration |
| Valid users see a sign-in error or access denied for the tenant | Tenant restriction in the Keycloak provider or the Entra app registration limits sign-in to a tenant or issuer that does not match the user's home tenant | Confirm the tenant or issuer value in Keycloak matches the directory the users belong to, and check whether the app registration audience allows the account types your users hold |
| Consent prompt fails or sign-in returns insufficient privileges | Requested scopes or permissions were not granted, or require administrator consent that no one has given | Review the scopes Keycloak requests against the API permissions on the app registration, then have a tenant administrator grant consent for the required permissions |
| Users sign in but group or role claims are missing | Group claims are not included in the token configuration, or the user belongs to so many groups that Entra ID returns an overage indicator instead of the list | Check the group claim settings on the app registration, decide whether to emit groups or use app roles, and confirm the Keycloak mapper reads the claim name Entra ID actually sends |
| A second Keycloak user is created on first login instead of linking to the existing account | The claim chosen as the link key differs from the value stored on the existing user, such as email address versus user principal name, or the value changed in the directory | Pick a stable identifier for the link key, align the first login review or linking flow with it, and clean up duplicate users before enabling automatic linking again |
| Token signature or issuer validation fails after a certificate or client secret change | Keycloak still holds the old client secret or cached signing keys, or the issuer or key endpoint in the provider configuration no longer matches the tenant | Update the client secret in the Keycloak provider, confirm the discovery endpoint and issuer values, and check that the signing keys are fetched from the current metadata |
| Tokens rejected as not yet valid or expired immediately after issue | Clock skew between the Keycloak nodes, the reverse proxy and Entra ID, which affects validation of time-based token claims | Verify that Keycloak hosts sync to a trusted time source, check every node in a cluster, and compare system time across the proxy layer before changing token lifetimes |
| Sign-in loops back to the Keycloak login page with no error | Broker callback fails silently because of a cookie, host name or proxy header issue, often after a change to the public frontend URL | Confirm the public hostname and forwarded headers in the reverse proxy configuration, then review Keycloak logs for the broker callback and the first broker login step |
Questions teams ask before connecting Entra ID to Keycloak
How much effort does connecting Entra ID to Keycloak take?
The effort depends mostly on how many applications sit behind Keycloak, how much claim and group logic you need, whether identities are hybrid, and how much testing you run before cutover. A single application with a simple group claim is a small job. Many applications with nested groups, role mapping and first-login linking is a multi-week project in most organizations, because each application needs its own client, mapper and test cases. Hybrid identity adds work if users are synced from Active Directory with Microsoft Entra Connect, since you must decide which attribute is the stable identifier. Ask for a written scope that lists applications, claims, test users and environments before you accept any duration.
What does the integration cost, and who gets paid for what?
The Keycloak software is licensed under Apache 2.0, so there is no license fee for the open source build. Costs fall into separate buckets: staff time for your team or a partner, infrastructure to run Keycloak and its database in your environment, Microsoft Entra licensing for the tenant and any features you rely on, and, if you choose the Red Hat build of Keycloak, a Red Hat subscription. Setup costs are largely one time, while hosting, patching, upgrades and monitoring recur. Ask any quote to itemize these components so you can compare the Entra and subscription choices on their own terms.
Can our own team connect Entra ID to Keycloak without a partner?
Yes, a capable team can do it alone if it has an administrator for Microsoft Entra ID, an administrator for Keycloak, and someone who owns the application side of each client. The work is well documented, and the hardest parts are design decisions rather than console steps. A partner usually helps where the team lacks recent experience with claim mapping, tenant restrictions, testing across several applications or a planned cutover from an existing sign-in path. Decide early which parts you will own and which you will hand over, and write that split into the scope.
What do we need to provide before the work starts?
You need administrator access to the Microsoft Entra tenant, with rights to register applications and read group and directory settings, plus administrative access to the Keycloak realm and its hosting environment. Business owners should sign off on claim names, group-to-role mapping and which users may sign in, because those choices drive most of the rework later. A pilot group of real users and at least one non-production test tenant or realm make verification practical. Confirm these prerequisites in writing, along with who approves production changes.
Does Microsoft Entra Connect change the plan?
Yes, if your users originate in on-premises Active Directory. Microsoft's comparison notes that existing Active Directory organizations use Microsoft Entra Connect to sync identities to Microsoft Entra ID, so the users Keycloak sees through Entra are the synced accounts. Check which attributes are synchronized, whether group membership is cloud-only or synced, and how disabled accounts are handled, because those settings determine what claims Keycloak receives. Confirm the sync design with the team that operates Entra Connect before you fix the claim mapping.
How do Keycloak upgrades affect an Entra ID setup?
Upgrades are usually manageable when the provider configuration is documented and tested in a non-production realm first. The Keycloak project plans four minor releases a year and a major release every two to three years, and it states that breaking changes in a minor release will be opt-in, so routine patches are less risky than major ones. Read the upgrade notes for each target version, retest the Entra login flow, group claims and first-login linking after every change, and keep the Keycloak Operator on manual approval if you run it on Kubernetes. Ask any partner to include upgrade testing in the scope and in any retainer.
How DeployOpen scopes and delivers an Entra ID brokering project
DeployOpen treats Microsoft Entra ID as an identity provider in Keycloak as a fixed-scope project with written decisions on the Microsoft provider versus a generic OIDC provider, app registration, tenant restriction, claim mapping and first login linking. The work is planned in your Keycloak environment and delivered inside your own infrastructure, so your identity and security teams can review every setting.
How we scope
- Written scope names the Entra ID tenants, app registrations and Keycloak realms that the engagement covers.
- We record the provider type decision, tenant restriction rules and the groups or roles that must reach each application.
- Scope states which first login linking behavior is agreed and which Keycloak clients depend on it.
- Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts.
How we build
- We configure the Entra ID app registration, redirect URIs and token claims alongside the Keycloak identity provider settings.
- Tenant restriction and issuer validation are set and tested with accounts from both allowed and blocked tenants.
- Group and role claim mappers are built and checked against real sign-in tokens from test users.
- Testing covers first login account linking, duplicate email cases and sign-in through each downstream client.
How we hand over
- Deliverables include the configuration record, mapper tables and a runbook for changing Entra ID secrets and claims.
- We document each configuration decision so compliance and security reviewers can trace it to the agreed scope.
- Your administrators receive hands-on walkthroughs of the realm, provider and mapper settings they will maintain.
- Handover covers the test cases used, with the expected results for future regression checks after changes.
How we support
- Ongoing support, upgrades and continuous testing are available as retainers after handover.
- Retainers can cover Keycloak version upgrades and retesting after Microsoft Entra ID tenant or claim changes.
- Before an organization relies on the brokering setup, we can test it as part of a security review.
- Pricing follows from the written scope, so ask for a quote that lists each support task and its frequency.

