What Is Identity Brokering in Keycloak?
The complete, in-depth guide to letting users log in with Google, Microsoft, or a partner company's own identity system — while every application still trusts only Keycloak.
Picture a travel agent who doesn’t operate a single airline, but instead has standing agreements with a dozen different carriers. A customer walks in and says “I need to fly to Tokyo,” and the agent quietly figures out which specific airline can get them there, books the ticket, and hands the customer one single itinerary — the customer never has to know or care which underlying airline actually operated the flight, or learn each airline’s own separate booking process. The agent is the single point of contact; the airlines are simply providers working behind that one relationship. Keycloak can play this exact role for logins. Instead of forcing every application to individually understand how to log a user in through Google, Microsoft, or a partner company’s own identity system, Keycloak sits in the middle, quietly handling each of those relationships itself, and hands every application back one single, uniform kind of token regardless of which external system the user actually authenticated with. This role — Keycloak acting as an intermediary between a user’s real identity provider and every application — is called Identity Brokering.
This guide is a comprehensive, ground-up exploration of Identity Brokering: what it actually means for Keycloak to “broker” a login, how trust is established with an external identity provider, what happens step by step during a brokered login, how a newly arriving external identity gets linked to an account, and the real-world patterns and mistakes organizations run into when connecting Keycloak to outside identity systems. No prior identity or security background is assumed — every term is explained in full the moment it first appears.
1Core Concepts
What Is Identity Brokering?
Identity Brokering is the arrangement where Keycloak, instead of authenticating a user itself using its own stored password, delegates that authentication to an external identity system, then translates the result of that external login into Keycloak’s own standard tokens — the same ID Tokens and Access Tokens covered elsewhere in this series — so that every connected application continues to see one single, uniform login experience, entirely unaware of which external system actually did the work.
An ordinary login, covered in earlier guides, involves two parties: the user and Keycloak. A brokered login involves three: the user, the external identity provider that actually verifies the user’s credentials, and Keycloak, sitting in between, translating that external proof of identity into its own token format. Applications connected to Keycloak only ever see Keycloak’s side of this relationship — the external identity provider remains invisible to them entirely.
The External Identity Provider (IdP)
In this arrangement, the outside system that actually verifies who the user is — Google, Microsoft Entra ID, a partner organization’s own Keycloak or other identity server — is called the external Identity Provider, commonly shortened to IdP. Keycloak registers a connection to each such IdP it wants to support, configuring exactly how to redirect users there and how to interpret what comes back.
Return to the travel agent from the opening. The agent (Keycloak) doesn’t own any aircraft — every actual flight is operated by one of its partner airlines (the external IdPs). The customer (the application) only ever deals with the agent’s single itinerary and never needs to separately learn each airline’s own check-in process, baggage rules, or booking system. The agent’s entire value lies in absorbing that variety on the customer’s behalf.
Why Not Just Connect Every Application Directly to Each External Provider?
It’s worth asking directly why brokering through Keycloak is preferable to simply having each application integrate with Google or a partner’s identity system on its own. Without brokering, every single application would need to separately implement and maintain a working integration with every external provider it wants to support, separately handle that provider’s own quirks and token format, and separately manage the account-linking logic covered in Chapter 5. Brokering centralizes all of that complexity in exactly one place — Keycloak itself — so that adding support for a new external provider benefits every connected application at once, with zero changes required in any of those applications.
The Compounding Value as More Applications Join
This centralizing effect compounds as an organization’s number of connected applications grows. Integrating a single new external IdP once, at the Keycloak level, when an organization already has thirty applications relying on that same Keycloak Realm, instantly extends that new login option to all thirty applications simultaneously — a level of leverage that simply isn’t available to any single application integrating with an external provider entirely on its own.
Brokering Is Not the Same as Federation
It’s worth flagging early, and returning to in depth in Chapter 9, that Identity Brokering is a related but distinct concept from User Federation (connecting Keycloak directly to a corporate directory like LDAP or Active Directory). Both let Keycloak rely on an external source of truth rather than its own local user database, but they work in fundamentally different ways and solve somewhat different problems.
Keycloak’s Role Is Always the Broker, Never the IdP, in This Relationship
It’s worth being precise about which side of the relationship Keycloak occupies here, since the same word “provider” gets used loosely in casual conversation. Throughout this guide, Keycloak itself is the Identity Provider from the perspective of every application connected to it — exactly as established in earlier guides in this series. But from the perspective of the external system being brokered (Google, a partner’s identity platform), Keycloak temporarily switches roles and instead behaves as a relying party, exactly like any ordinary application would behave toward Keycloak. Brokering is, in this sense, Keycloak simultaneously playing both roles at once: Identity Provider to its own applications, and relying party to the external system it’s brokering.
The User Rarely Notices the Handoff Happening
From a purely visual standpoint, a well-configured brokered login often looks completely seamless to the end user — a click on “Sign in with Google,” a brief redirect, and then landing directly inside the target application, all within a couple of seconds. The three-party structure described above is entirely invisible in the everyday experience; it only becomes visible and relevant the moment something goes wrong, or the moment an administrator needs to configure or troubleshoot the relationship.
A Note on Terminology Across the Wider Industry
Different identity systems and standards documents sometimes use slightly different words for the same underlying idea described in this guide — “social login” for the specific case of consumer providers, “federated login” used loosely by some vendors to mean what this series calls brokering, or “external IdP integration” as a more generic catch-all phrase. Whatever term a specific document or vendor uses, the underlying pattern being described is almost always the same three-party relationship covered throughout this guide: a user, an external system that actually verifies them, and an intermediary translating that result into its own standard tokens.
2Architecture & Components
graph TD
User["End User"] -->|"1. Chooses to log in via"| KC["Keycloak
(the Broker)"]
KC -->|"2. Redirects to"| IdP["External Identity Provider
(Google, Entra ID, Partner Keycloak)"]
IdP -->|"3. Authenticates the user directly"| User
IdP -->|"4. Returns proof of identity"| KC
KC -->|"5. Applies IdP Mappers,
links or creates local account"| Local["Keycloak's Own User Record"]
KC -->|"6. Issues standard tokens"| App["Application
(sees only Keycloak's token)"]
Identity Provider Configuration
A Realm-level registration of one external IdP, specifying its endpoints, protocol, and the credentials Keycloak uses to trust it.
IdP Mapper
A rule translating a specific piece of information the external IdP provides (a claim, an attribute) into Keycloak’s own user model — covered fully in Chapter 7.
Identity Provider Redirector
An execution (introduced elsewhere in this series) placed inside a flow, offering the user a choice of external IdPs to log in through.
First Broker Login Flow
The specific Authentication Flow governing what happens the very first time a given external identity arrives at this Realm — the entire subject of Chapters 4 and 5.
3Supported External Providers and Protocols
| Category | Typical Examples | Underlying Protocol |
|---|---|---|
| Social Login Providers | Google, Microsoft, GitHub, Facebook | OpenID Connect (covered in depth elsewhere in this series) |
| Enterprise Identity Platforms | Microsoft Entra ID, Okta, Ping Identity | OpenID Connect or SAML |
| Another Keycloak Instance | A partner organization’s own separately run Keycloak deployment | OpenID Connect |
| Legacy Enterprise Systems | Older on-premises identity systems common in large, established organizations | SAML (an older, XML-based identity standard) |
Because Keycloak can broker through either OpenID Connect or SAML, it can sit between applications that only understand modern OIDC-based tokens and an external identity system that only speaks the older SAML standard, translating between the two seamlessly. Applications never need to know or care which protocol the external IdP actually uses.
Why SAML Still Matters in Modern Brokering Scenarios
It’s tempting to assume an older standard like SAML has been fully retired in favor of the more modern OpenID Connect, but this isn’t the reality inside many large, established organizations. Government agencies, large financial institutions, and universities frequently still run identity infrastructure built years or decades ago on SAML, and replacing it purely to satisfy a newer partner’s technology preference is often neither practical nor necessary. Keycloak’s ability to broker SAML on one side while issuing clean, modern OIDC tokens to every connected application on the other side means a newer organization can partner with one of these established institutions without either side needing to rebuild its own core identity infrastructure.
Choosing a Protocol When Both Are Available
When an external IdP genuinely supports both protocols, OpenID Connect is generally the more straightforward choice for a new integration — it tends to be simpler to configure, produces more compact tokens, and is the protocol most new identity tooling is built around first. SAML remains the right choice specifically when the external system doesn’t offer an OIDC option at all, or when an existing, already-working SAML relationship simply doesn’t need to be disturbed.
Social Login Providers as a Distinct Sub-Category
It’s worth calling out social login providers specifically, since they’re the brokering scenario most people encounter as ordinary internet users, even without ever hearing the term “Identity Brokering” itself. These providers are almost universally OpenID Connect based, tend to have well-documented, stable integration processes, and typically require the organization brokering them to register as a recognized application with that provider ahead of time — a lightweight registration process, but a genuine prerequisite step distinct from the IdP configuration performed inside Keycloak itself.
4Internal Working: A Brokered Login, Step by Step
User Chooses the External Option
On Keycloak’s login page, the user selects an option like “Sign in with Google” rather than entering a local username and password.
Keycloak Redirects to the External IdP
Keycloak, acting on behalf of the user, redirects their browser to the external IdP’s own login page, exactly as an ordinary application would redirect to Keycloak in earlier guides — here, Keycloak itself is playing the role of the requesting application relative to the external IdP.
User Authenticates at the External Provider
The user enters their credentials directly with Google (or whichever provider was chosen) — Keycloak never sees this password at any point.
External Proof Returned to Keycloak
The external IdP redirects the user’s browser back to Keycloak, carrying a proof of identity (an authorization code, exchanged for a token, exactly following the mechanics covered elsewhere in this series).
Keycloak Reconciles the External Identity
Keycloak checks whether this external identity has been seen before. For a first-time arrival, the First Broker Login flow runs, covered fully in Chapter 5. For a returning identity, Keycloak simply recognizes the already-linked local account.
IdP Mappers Applied
Information from the external identity (name, email, group membership) is translated into Keycloak’s own user model according to the configured IdP Mappers, covered in Chapter 7.
Keycloak Issues Its Own Tokens
Keycloak completes the login exactly as it would for a locally authenticated user, issuing its own standard ID Token, Access Token, and Refresh Token back to the requesting application — which never sees anything about Google, or the external exchange that just occurred, at all.
5The First Broker Login Flow and Account Linking
The Reconciliation Problem
A user might already have a local Keycloak account (created through direct registration), and separately also have a Google account carrying the exact same email address. When that user first chooses “Sign in with Google,” Keycloak must decide: is this the same person, deserving to be logged into their existing local account, or a genuinely new person who needs a brand-new account created?
Automatic Linking by Email
One common configuration automatically links a newly arriving external identity to an existing local account whenever their email addresses match exactly, on the assumption that possession of an email address is sufficient proof the two identities belong to the same real person. This is convenient and low-friction, but it rests on that specific assumption holding true, a point returned to with more nuance in Chapter 11.
Production Example: Seamless Migration to Social Login
A consumer platform originally built on local username/password accounts, later adding “Sign in with Google” as a convenience, commonly configures automatic email-based linking so that existing customers who happen to use the same email address with Google can immediately start using the new, more convenient login option without needing to go through any separate account-merging process themselves.
Prompting the User to Confirm or Link Manually
A more cautious configuration, instead of linking automatically, prompts the arriving user with a choice: log into the existing account by re-entering its local password (proving they genuinely control it), or proceed with creating a brand-new, separate account instead. This trades away some convenience for a meaningfully stronger guarantee that linking only happens with the user’s own explicit, verified confirmation.
Creating a Brand-New Account
When no matching local account exists at all, or when linking isn’t configured to happen automatically, Keycloak simply creates a fresh local user record to represent this newly arrived external identity, populated using the IdP Mappers covered in Chapter 7.
Reviewing and Confirming Profile Information Before Account Creation
Some organizations configure the First Broker Login flow to pause even for a genuinely new user, showing them a review screen summarizing the profile information about to be imported from the external IdP — their name, their email — before finalizing account creation. This adds a small extra step but gives the user a chance to correct anything the external IdP reported inaccurately, and gives the organization one last opportunity to apply any additional Required Actions (covered elsewhere in this series) before the account is considered fully onboarded.
What Happens When Reconciliation Is Ambiguous
Occasionally, the available signals don’t cleanly resolve to either “definitely the same person” or “definitely a new person” — for instance, an external IdP might not report an email address at all, leaving nothing to match against. In these ambiguous cases, a well-designed First Broker Login flow generally defaults toward the safer path: treating the arrival as a new account requiring explicit user action to link, rather than guessing at a match and potentially connecting two unrelated identities together by mistake.
6Multiple Identities, One Account
How This Works
Keycloak’s user model allows one local account to maintain links to several external identities simultaneously — the same person might link both their Google account and their Microsoft account to a single underlying Keycloak identity, letting them log in through either path interchangeably while always landing in the exact same account, with the exact same Roles, Groups, and history.
This is much like a single hotel loyalty account reachable through several different linked payment cards. Whichever card the guest happens to use to check in, the hotel recognizes the same underlying loyalty profile, with the same accumulated points and preferences — the card used is simply the path taken to reach that one profile, not a separate identity in its own right.
Production Example: Flexible Login for Returning Users
A software product allowing customers to link both a personal Google account and a work Microsoft account to the same underlying profile lets a user log in from whichever device or context is most convenient at that moment — a personal laptop via Google, a company laptop via the corporate Microsoft account — while the application always sees exactly one consistent user identity and history regardless of which path was used that day.
Managing Links From the User’s Own Account Settings
Keycloak typically exposes a self-service account management area where a logged-in user can view which external identities are currently linked to their account, add a new link to another provider they haven’t connected yet, or remove an existing link they no longer want active. This puts a meaningful degree of control directly in the user’s own hands, rather than requiring an administrator to manually adjust linkages on their behalf for routine changes.
Unlinking as a Security Response
If a user suspects one of their linked external accounts has been compromised, promptly unlinking it from their Keycloak account through this same self-service area immediately closes that specific login path, without affecting their ability to continue logging in through any other still-linked identity or their local password, if one exists. This makes account linking not just a convenience feature but also a meaningful, user-controllable security lever in its own right.
7IdP Mappers: Translating What the External Provider Sends
What an IdP Mapper Does
An IdP Mapper is a configured rule that takes one specific piece of information returned by an external IdP — a claim inside its token, an attribute inside its SAML assertion — and decides what to do with it inside Keycloak: store it as a user attribute, assign a Realm Role based on its value, or populate a specific built-in profile field like first name or email.
Attribute Import Mapper
Copies a claim from the external identity directly into a matching attribute on the local Keycloak user record.
Role Mapper
Assigns a Realm Role or Client Role to the user automatically, based on a specific value found in the external identity’s claims (like a department or group membership reported by the external IdP).
Username Template Mapper
Determines how the external identity’s information is combined into a local Keycloak username, especially useful when the external system’s own identifier format doesn’t match Keycloak’s expectations.
Production Example: Automatic Role Assignment from a Partner Directory
An organization brokering logins from a partner company’s own identity system commonly configures a Role Mapper that reads a “department” claim coming from that partner IdP and automatically assigns a corresponding Client Role inside the relevant internal application, so partner employees land with an appropriate starting level of access the very first time they ever log in, with no manual provisioning step required on the receiving organization’s side.
Mappers Run on Every Login, Not Just the First
It’s worth being clear that IdP Mappers aren’t a one-time, first-login-only affair. By default, they re-run and can update the local user’s attributes on every subsequent brokered login as well, meaning a change on the external IdP’s side (a new department, an updated name) can automatically propagate into Keycloak’s own copy the next time that user logs in.
Controlling How Aggressively Mappers Overwrite Local Data
Because mappers can run repeatedly, it’s worth thinking through what should happen if a local administrator has manually edited a user’s attribute after it was originally imported — should the next brokered login simply overwrite that manual change with whatever the external IdP currently reports, or should the manually edited value take precedence going forward? Keycloak’s mapper configuration allows this behavior to be tuned per mapper, and getting this choice right for each specific attribute avoids the frustrating experience of an administrator’s deliberate correction being silently reverted on the user’s very next login.
Mapping Group Membership, Not Just Simple Attributes
Beyond simple attributes and Roles, an IdP Mapper can also translate an external IdP’s own group-membership claims into Keycloak Group membership, letting an organization’s existing group structure at the external IdP (departments, teams, cost centers) carry over automatically into Keycloak’s own Group hierarchy, which in turn drives Role assignment through the Group-based patterns covered elsewhere in this series — a genuinely powerful way to keep two separate systems’ organizational structure in sync without manual, duplicate maintenance.
8Data Flow & Lifecycle
Registration. An administrator registers the external IdP inside the Realm, configuring its protocol, endpoints, and the credentials Keycloak will use to establish trust with it.
Mapper Configuration. IdP Mappers are set up to translate the external identity’s claims into Keycloak’s own user model, as covered in Chapter 7.
Exposure to Users. The external IdP option is surfaced to users, typically through an Identity Provider Redirector execution added to the relevant Authentication Flow.
First Arrivals. As users begin choosing this option, the First Broker Login flow governs each new external identity’s very first appearance, as covered in Chapter 5.
Ongoing Use. Returning users are recognized automatically on each subsequent login, with mappers continuing to refresh local attributes as covered in Chapter 7.
Decommissioning. If a partnership ends or an external IdP is retired, the registration can be disabled or removed, though already-linked local accounts and their history typically remain intact unless explicitly cleaned up.
graph LR
A["IdP Registered
(protocol, endpoints, trust credentials)"] --> B["Mappers Configured"]
B --> C["Exposed to Users
(via Identity Provider Redirector)"]
C --> D["First Arrivals
(First Broker Login flow)"]
D --> E["Ongoing Recognized Logins"]
E --> F{"Partnership Ends?"}
F -->|"Yes"| G["IdP Disabled or Removed"]
Treating Each Relationship as Its Own Small Project
Because each external IdP registration carries its own configuration, its own trust assumptions, and its own ongoing monitoring needs, larger organizations with several brokered relationships often benefit from tracking each one as its own small, named piece of ongoing operational ownership — with a clear answer to “who is responsible for noticing if this one breaks, and who has the authority to update its configuration” — rather than treating the entire collection of external IdPs as one undifferentiated, jointly owned configuration block that nobody feels fully responsible for in practice.
Planning for Eventual Migration Away From a Brokered Relationship
Just as an organization plans for onboarding a new brokered relationship, it’s worth planning upfront for what eventually unwinding one would involve — specifically, what happens to users whose only linked identity was through that one external IdP, once it’s disabled. A responsible decommissioning plan typically includes advance user communication and, where appropriate, prompting affected users to set a local password or link an alternative identity before the external relationship is actually switched off, so nobody is abruptly locked out of their own account with no path back in.
9Brokering vs. User Federation: A Necessary Distinction
| Aspect | Identity Brokering | User Federation |
|---|---|---|
| Who authenticates the user | The external IdP itself, directly | Keycloak, checking credentials against the federated store |
| Where the user’s password lives | Only at the external IdP — Keycloak never sees it | In the federated directory (like an LDAP server); Keycloak validates against it |
| Typical external systems | Google, Microsoft, another organization’s identity system | Corporate directories like LDAP or Active Directory |
| User’s redirect experience | Browser is redirected away to the external IdP’s own login page | User stays on Keycloak’s own login page throughout |
If the user’s browser is visibly redirected away to another login page entirely, that’s brokering. If the user stays on Keycloak’s own login screen the whole time, but Keycloak is checking their credentials against an external directory behind the scenes, that’s federation. Both let Keycloak avoid being the ultimate source of truth for a user’s password, but they achieve it through entirely different mechanisms.
When an Organization Might Genuinely Need Both at Once
These two mechanisms aren’t mutually exclusive within a single Realm. A company might federate its own employees against its internal Active Directory (so staff log in with their familiar corporate username and password, without leaving Keycloak’s own page) while simultaneously brokering a completely separate population of external partner users through those partners’ own identity systems, and a third population of consumer customers through social login providers — all coexisting inside the very same Keycloak Realm, each population served by whichever mechanism actually fits how that population’s identity is really managed.
Federation’s Trust Model Is Simpler, but Less Flexible
Because federation involves Keycloak directly checking credentials against the external directory rather than trusting a separate system’s own assertion of success, its trust model is, in one sense, simpler to reason about — there’s no third party’s own token-issuing behavior to account for. But this comes at the cost of flexibility: federation generally assumes a fairly uniform, tightly integrated relationship with one specific directory technology, whereas brokering’s redirect-based approach comfortably accommodates a much wider and more loosely coupled variety of external identity systems, including ones an organization has no direct technical relationship with beyond the standard protocol itself.
10Advantages, Disadvantages & Trade-offs
Advantages
- Users can log in with an identity they already have and already trust, reducing new-account friction and password fatigue
- Every connected application automatically gains support for a new external IdP the moment it’s configured once inside Keycloak, with zero application-side changes
- Keycloak never needs to store or manage a password for users who exclusively log in through a brokered external IdP
- Enables genuine business-to-business federation, letting partner organizations’ own employees log in using their own employer’s identity system
Disadvantages & Trade-offs
- Login availability now depends on the external IdP’s own uptime — if Google or a partner’s identity system is down, brokered users cannot log in through that path
- Account-linking logic (Chapter 5) introduces genuine security nuance that, if configured carelessly, can create an unintended account-takeover path
- Debugging a failed brokered login sometimes requires investigating an external system the organization doesn’t directly control or have full visibility into
- Users linking multiple external identities to one account can create confusion about “which login did I use last time” without clear in-product guidance
- Adopting a new external IdP typically requires ongoing relationship management — periodic contract or trust renewals, coordinating on protocol or endpoint changes the external party makes on its own schedule
None of these trade-offs argue against using brokering — they simply argue for treating each brokered relationship as a genuine, ongoing operational commitment, not a one-time configuration task completed once and never revisited.
11Security
Problem
An organization configures automatic account linking by email match, but the external IdP being brokered doesn’t actually guarantee that the email address it reports has been verified as belonging to that user.
Why It Fails
An attacker who registers a new account at the external IdP using someone else’s email address (where that external system allows unverified email entry) could potentially get automatically linked into, and gain access to, the victim’s existing local Keycloak account — a real, well-documented class of account-takeover vulnerability in brokered identity systems industry-wide.
Correct Approach
Only enable automatic email-based linking when the external IdP explicitly confirms, as part of its own token or assertion, that the email address has been verified. Where that guarantee isn’t available or trusted, prefer the safer manual confirmation pattern from Chapter 5, requiring the user to actively prove control of the existing local account before linking.
Trusting the External IdP’s Own Security Practices
Brokering inherently extends a degree of trust to however securely the external IdP itself protects its own users’ accounts. An organization brokering logins through a partner’s identity system is, in effect, also relying on that partner’s own password policies, breach response practices, and account-recovery processes — a dependency worth factoring into any risk assessment, especially for high-sensitivity applications.
Reviewing Which Claims Are Actually Trusted
Because IdP Mappers can translate external claims directly into Keycloak Roles (as shown in Chapter 7’s partner-directory example), it’s worth reviewing exactly which claims are trusted this way and confirming the external IdP itself properly restricts who can set or influence those specific claim values — an externally controllable claim mistakenly mapped into a sensitive Role assignment can become an unintended privilege-escalation path.
Signature and Endpoint Verification
Just as with the token verification principles covered elsewhere in this series, Keycloak must properly verify the cryptographic signature on whatever proof of identity an external IdP returns, and must be configured with the correct, trusted endpoint addresses for that IdP rather than accepting values supplied at request time. A misconfiguration allowing an untrusted signing key or an unverified endpoint to be accepted would undermine the entire basis of trust the brokering relationship depends on, regardless of how carefully every other setting was configured.
Revoking Trust When a Relationship Ends
When a business relationship with an external IdP ends — a partnership dissolves, a social provider’s terms change unacceptably — promptly disabling or removing that IdP’s registration is a genuine security action, not merely administrative housekeeping. A stale, still-active brokering relationship with an organization no longer subject to any ongoing due diligence or monitoring represents an open trust boundary that no longer serves any legitimate business purpose.
12Monitoring, Logging & Metrics
External IdP Availability
Monitoring the success rate of brokered login attempts specifically helps distinguish a Keycloak-side problem from an outage or issue at the external IdP itself.
Account-Linking Events
Logging every automatic or manual account-linking event provides an audit trail essential for investigating any suspected account-takeover attempt through the brokering path.
Brokered vs. Local Login Split
Tracking what fraction of logins flow through each brokered IdP versus local credentials helps gauge real adoption and informs decisions about which external relationships are actually worth maintaining.
First Broker Login Failures
Specifically tracking failures during first-time arrivals (as opposed to ordinary returning-user logins) often points to account-linking configuration issues rather than a general external IdP problem.
Watching for Silent Protocol or Certificate Changes
External IdPs occasionally rotate their own signing certificates, change their endpoint addresses, or make other protocol-level adjustments on their own schedule, sometimes with limited advance notice to every relying party depending on them. Monitoring specifically for a sudden rise in signature-verification failures for one particular brokered IdP, distinct from a general outage, often reveals exactly this kind of change happening on the external side, well before it would otherwise surface only through a wave of confused user support tickets.
Tracking Linked-Identity Growth Over Time
For organizations actively encouraging account linking (as in the flexible multi-provider pattern from Chapter 6), tracking how many accounts have zero, one, or multiple linked external identities over time offers a useful, simple gauge of how well that feature is actually being adopted, and whether further in-product prompts or education might help more users take advantage of it.
13Design Patterns & Anti-patterns
Good Patterns
- Verify before linking: only enable automatic account linking when the external IdP explicitly guarantees the claim being matched on is verified
- Map narrowly and deliberately: only translate external claims into Keycloak Roles when the external IdP’s own governance over those claims is well understood and trusted
- Monitor the brokered path separately: treat brokered login reliability as its own dedicated metric, not folded invisibly into overall login statistics
- Document each external relationship’s purpose and trust basis alongside its configuration, for the same reasons documentation matters for Conditional Flows elsewhere in this series
Anti-patterns to Avoid
Common Mistakes
- Enabling automatic email-based linking without confirming the external IdP actually verifies that email
- Mapping an externally influenced claim directly into a sensitive Role without reviewing who controls that claim’s value at the source
- Treating a brokered external IdP as “someone else’s problem” and never monitoring its actual login success rate
- Leaving a decommissioned partner IdP’s configuration active indefinitely after the business relationship has actually ended
- Configuring an ambiguous First Broker Login outcome to guess at a match rather than defaulting to the safer, explicit-confirmation path
- Assuming a working integration will keep working indefinitely without any monitoring, when external IdPs can change certificates, endpoints, or claim formats on their own independent schedule
14Real-World & Industry Examples
Consumer Platforms Offering Social Login
A retail website letting customers sign in with Google or Facebook, rather than creating yet another separate password, is a direct, familiar application of Identity Brokering — Keycloak handles the relationship with each social provider once, and every part of the retail platform simply receives a standard token regardless of which option the customer chose.
Business-to-Business Partner Federation
A software vendor granting a client company’s own employees direct access to a shared support portal, using that client’s own corporate identity system rather than creating separate accounts for each employee, is a classic enterprise brokering scenario — the client remains fully responsible for its own employees’ credentials, while the vendor’s application simply trusts Keycloak’s brokered result.
Mergers and Acquisitions
A company acquiring another organization often uses brokering as a bridging strategy during integration — employees of the newly acquired company continue logging in through their existing, familiar identity system for a transition period, brokered into the parent company’s Keycloak Realm, before eventually being fully migrated onto the parent’s own directory.
Government Cross-Agency Services
A citizen-facing government service allowing sign-in through a separate, centralized national digital identity system (rather than maintaining its own separate citizen credential store) brokers that national identity system as its external IdP, letting the citizen-facing application benefit from an identity verification process it would be impractical to replicate on its own.
Educational Platforms and Academic Federations
Universities and research institutions frequently participate in shared academic identity federations, letting a researcher from one participating university log directly into a shared research platform or journal subscription service using their home institution’s own credentials, brokered through that federation’s standard protocol — sparing the researcher from creating and remembering yet another separate account for every external service their work touches.
Developer Platforms Brokering Source-Control Identities
A developer tools platform allowing engineers to sign in with their existing GitHub or GitLab identity, rather than creating a separate account specifically for that platform, brokers those source-control providers as external IdPs — a pattern especially common in the developer tools space, where the target audience overwhelmingly already maintains an active account with one of these specific providers.
15Frequently Asked Questions
16Summary and Key Takeaways
Key Takeaways
- Identity Brokering lets Keycloak delegate authentication to an external Identity Provider, then translate the result into its own standard tokens — every connected application only ever sees Keycloak’s side of the relationship.
- Keycloak supports brokering through both OpenID Connect and SAML, covering social login providers, enterprise identity platforms, and other Keycloak deployments alike.
- The First Broker Login flow governs the critical, security-sensitive moment when a new external identity first arrives, deciding whether to link, prompt, or create a new account.
- IdP Mappers translate external claims into Keycloak’s own user model — attributes, Roles, and profile fields — and continue running on every subsequent login, not just the first.
- Brokering is distinct from User Federation: brokering redirects the user to a separate external login page, while federation checks credentials against an external directory without leaving Keycloak’s own login screen.
- Automatic account linking by email is a genuine security decision, not a convenience-only setting — it should only be enabled when the external IdP guarantees the matched claim is actually verified.
- A single local account can be linked to multiple external identities at once, letting users log in flexibly while always reaching the same underlying profile, and users can typically manage — including unlink — these connections themselves through Keycloak’s self-service account area.
- Treat each brokered relationship as an ongoing operational commitment, not a one-time setup task — external IdPs can rotate certificates, change endpoints, or end the relationship entirely, and each of those events needs a clear, planned response.