What Is an Identity Provider Configuration in Keycloak?

What Is an Identity Provider Configuration in Keycloak?

A complete, beginner-friendly walkthrough of Keycloak's identity brokering — what it is, how "Login with Google" style buttons actually work, and how Keycloak links external identities to local accounts.

Think about checking into a hotel using a boarding pass from an airline you flew in on, instead of a passport the hotel issued itself. The hotel doesn’t need to know how the airline verified you at the gate — it just needs to trust the airline’s stamp and translate it into its own “guest checked in” record. That’s the exact job Keycloak performs when it acts as an identity broker. Instead of only checking passwords against its own database, Keycloak can trust an outside identity provider’s proof of who someone is, and translate that proof into a normal, local Keycloak session. This post walks through what an Identity Provider configuration actually is in Keycloak, how it’s set up, and how the login flow works behind the scenes.

1What Is Identity Brokering, Really?

Before opening the Keycloak admin console, let’s fix the plain-English idea in place.

Identity brokering is the general practice of one identity system trusting and forwarding authentication decisions made by another identity system, rather than authenticating users itself every single time. In Keycloak, this is configured through something called an Identity Provider, often shortened to IdP. Each Identity Provider configuration tells Keycloak about one external system it should trust — Google, a corporate Microsoft Entra ID tenant, GitHub, or even another, entirely separate Keycloak realm.

Once configured, Keycloak can present a “Login with X” button on its own login page. When a user clicks it, Keycloak steps out of the way, lets the external provider handle the actual authentication, and then takes the resulting proof of identity and turns it into a normal Keycloak session — complete with its own access tokens, roles, and user record, exactly as if the user had logged in with a local Keycloak username and password.

Simple Analogy

Picture an office building lobby that accepts three kinds of ID badges: its own employee badge, a badge from a partner company’s office, and a government ID for verified visitors. The receptionist doesn’t need to personally verify each badge type from scratch — she just needs a clear rulebook for recognizing each one and translating it into a temporary building access pass. Keycloak’s Identity Provider configuration is that rulebook.

i
A Note on Terminology

“Identity broker,” “identity provider configuration,” and simply “IdP” are all used somewhat interchangeably in Keycloak’s documentation and admin console. They all refer to the same underlying feature.

2Why Brokering Exists

Understanding the problem it solves makes the feature much easier to reason about.

Without brokering, every application that wants to accept “Login with Google” or “Login with a partner company’s directory” would need to implement that specific provider’s protocol itself, store its own copy of that integration’s secrets, and maintain it independently. Multiply that by every application in an organization, and the same integration work gets duplicated many times over, each with its own chance of a subtle mistake.

By configuring the Identity Provider once, centrally, inside Keycloak, every application that already trusts Keycloak automatically gains the ability to log in through that external provider too — without any of those applications needing to know Google, or SAML, or any other protocol exists at all. From the application’s point of view, a user who logged in via a brokered identity looks exactly like any other Keycloak-authenticated user.

Centralizing trust

Instead of ten applications each independently deciding to trust a partner company’s identity system, only Keycloak needs to make and maintain that trust decision.

3Identity Providers vs. User Federation vs. Local Accounts

Keycloak actually offers three distinct ways to bring users in, and it’s easy to mix them up.

ApproachWhere Credentials LiveWho Authenticates the User
Local AccountKeycloak’s own databaseKeycloak itself
User Federation (e.g. LDAP)An external directory Keycloak queries directlyKeycloak, checking against the external directory
Identity Provider (Broker)The external provider’s own systemThe external provider — Keycloak only trusts the result

The distinction that matters most: with brokering, Keycloak never sees the user’s actual password at all. It only ever receives a signed assertion or token from the external provider confirming that authentication already happened successfully elsewhere.

!
Common Misconception

User Federation and Identity Brokering are sometimes confused because both involve an “external” system, but federation still has Keycloak perform the credential check itself; brokering delegates that check entirely to the outside provider.

A handful of pieces work together every time a brokered login happens.

The Trust Record

Identity Provider

The realm-level configuration describing one external provider — its protocol, endpoints, and credentials Keycloak uses to talk to it.

The Translator

Identity Provider Mapper

Rules that translate claims or attributes coming from the external provider into Keycloak user attributes, roles, or group memberships.

The Decision Point

First Broker Login Flow

The authentication flow Keycloak runs the very first time a specific external identity is seen, deciding whether to create a new local account or link to an existing one.

The Link

Federated Identity Link

The stored record connecting a Keycloak local user to a specific identity from a specific external provider, used on every subsequent login to recognize the returning user.

flowchart LR
    U["User"] -->|clicks Login with Provider| K["Keycloak"]
    K -->|redirects to| IdP["External Identity Provider"]
    IdP -->|authenticates user| IdP
    IdP -->|returns token / assertion| K
    K -->|checks| L[("Federated Identity Link")]
    L -->|found| S["Existing local user logged in"]
    L -->|not found| F["First Broker Login Flow
(create or link account)"]
FIG 1 — The federated identity link is what lets Keycloak recognize a returning brokered user on every login after the first.

5Supported Protocols

Keycloak doesn’t just support one flavor of “external login” — it supports several standard protocols under one roof.

Modern Standard

OpenID Connect (OIDC)

The most common choice for brokering with another Keycloak realm, Microsoft Entra ID, or any modern OAuth2-based identity system.

Enterprise Standard

SAML 2.0

Common when integrating with older enterprise identity systems, many of which were built before OIDC became widespread.

Consumer Login

Built-in Social Providers

Keycloak ships pre-configured templates for popular consumer providers like Google, GitHub, Facebook, and others, reducing setup to just entering a client ID and secret.

Regardless of which protocol a given Identity Provider configuration uses, Keycloak normalizes the result into the same internal shape once login completes — which is exactly what allows every downstream application to stay protocol-agnostic.

6How an Identity Provider Is Configured

Setting one up in the admin console follows a predictable shape, regardless of protocol.

1

Choose a protocol or provider template

Pick a generic OIDC or SAML provider, or a pre-built social provider template.

2

Give it an alias

This short identifier becomes part of the redirect URI Keycloak generates and is used internally to reference this specific provider.

3

Register Keycloak with the external provider

On the external provider’s side, register Keycloak’s generated redirect URI as an authorized callback destination, and obtain a client ID and secret.

4

Enter those credentials into Keycloak

Paste the client ID and secret into the Identity Provider configuration, along with any provider-specific endpoints if using a generic protocol type.

5

Add mappers and choose a first-login flow

Configure how incoming claims map to Keycloak attributes, and decide how first-time logins from this provider should be handled.

7The Login Flow, Step by Step

Here’s what actually happens on the wire when a user clicks a brokered login button.

sequenceDiagram
    participant U as User Browser
    participant K as Keycloak
    participant IdP as External Identity Provider

    U->>K: Clicks "Login with Provider"
    K->>IdP: Redirect to provider's login page
    U->>IdP: Enters credentials, authenticates
    IdP-->>K: Redirect back with authorization code / assertion
    K->>IdP: Exchange code for identity token (if OIDC)
    IdP-->>K: Identity token / attributes
    K->>K: Look up Federated Identity Link
    alt Link exists
        K-->>U: Local session issued immediately
    else No link yet
        K-->>U: First Broker Login flow (review, link, or create account)
    end
        
FIG 2 — Keycloak only ever talks to the external provider through standard redirects and token exchanges, never handling the user’s raw external credentials.

8Account Linking: New vs. Existing Users

The very first login from a given external identity is the trickiest moment in the whole flow, and Keycloak handles it with a dedicated flow.

The First Broker Login flow only runs the first time Keycloak sees a particular external identity for a particular Identity Provider configuration. Depending on how that flow is configured, a few outcomes are possible: Keycloak can automatically create a brand-new local user based on the external identity’s attributes; it can prompt the user to review and confirm their profile details before creating the account; or, if a local account already exists with a matching email or username, it can offer to link the external identity to that existing account instead of creating a duplicate.

Automatic linking by email

A common configuration links a new brokered login to an existing local account automatically whenever the verified email address matches — convenient, but worth pairing with strong verification requirements from the external provider.

Manual confirmation

A more cautious configuration asks the user to confirm the link, or even requires them to authenticate with their existing local credentials first, before the accounts are connected.

!
Security Consideration

Automatically linking accounts purely by an unverified email claim can be risky if the external provider doesn’t guarantee that email addresses are verified — an attacker who controls an unverified email at the provider could potentially take over an unrelated local account.

9Identity Provider Mappers

External providers rarely describe a user in exactly the shape Keycloak expects — mappers bridge that gap.

An Identity Provider Mapper is a small, configurable rule that takes a specific piece of information coming back from the external provider — a claim in an OIDC token, or an attribute in a SAML assertion — and decides what to do with it inside Keycloak. Common mapper types copy an external claim into a Keycloak user attribute, assign a Keycloak role based on a claim’s value, or add the user to a specific group automatically.

Attribute Mapper

Copy a Claim

Maps an external claim like department directly onto a matching Keycloak user attribute.

Role Mapper

Grant a Role

Assigns a specific Keycloak role automatically whenever an external claim matches a configured value.

Group Mapper

Assign a Group

Places the user into a Keycloak group based on external attributes, useful for mirroring an organization’s structure from the external provider.

Mappers typically run both during the first login (to populate a brand-new account) and on subsequent logins (to keep the local record synchronized with any changes on the external provider’s side).

10Data Flow & Lifecycle of a Federated Identity

Tracing what happens across a user’s entire relationship with a brokered login, not just a single request.

1st
login triggers account creation/linking
2nd+
logins reuse the stored federated link
Sync
mappers refresh attributes on each login

After the first login establishes the federated identity link, every future login through that same Identity Provider is far simpler: Keycloak recognizes the returning external identity, finds the linked local user, applies any configured mappers to refresh attributes, and issues a normal session — without repeating the account-creation decision each time.

What happens if the link is removed

If an administrator or the user themselves removes the federated identity link (through the account console or Admin REST API), the next login from that provider is treated as brand-new again, re-triggering the First Broker Login flow.

11Trust & Security Considerations

Brokering means placing real trust in a system Keycloak doesn’t control — that trust needs to be deliberate.

Verification

Prefer verified claims

Base account linking decisions on claims the external provider marks as verified, rather than raw, unverified fields.

Secrets

Protect client secrets

The client secret used to talk to the external provider is a sensitive credential in its own right and should be stored and rotated with the same care as any other application secret.

Scope

Request only needed claims

Ask the external provider for only the specific profile information actually needed, rather than the broadest possible scope.

Endpoint Trust

Validate signatures and issuers

Ensure tokens or assertions from the external provider are checked against the correct signing keys and issuer identity, preventing a malicious party from forging a trusted-looking login.

ANTI-PATTERN-01 Avoid
Problem

Configuring automatic account linking purely on an email match, from a provider that allows unverified or self-declared email addresses.

Why It’s Harmful

This opens the door to account takeover — anyone who can register an email at the external provider matching a victim’s Keycloak account email could potentially gain access to that account.

Correct Approach

Require verified email claims for automatic linking, or fall back to an explicit confirmation step where the user proves ownership of the existing account before linking.

12Advantages, Disadvantages & Trade-offs

Brokering is a powerful convenience, but it does shift where trust and dependency live.

Advantages

  • Lets users log in with an identity they already have, reducing password fatigue
  • Centralizes external trust decisions in one place instead of duplicating them per application
  • Supports multiple protocols under one consistent Keycloak login experience
  • Mappers keep local user data automatically synchronized with the external source

Disadvantages / Trade-offs

  • Introduces a dependency on the external provider’s uptime and security posture
  • Account-linking decisions carry real security weight and must be configured carefully
  • Debugging login issues can require investigating both Keycloak and the external provider
  • Protocol differences (OIDC vs SAML) can introduce subtle configuration quirks

13Design Patterns & Anti-Patterns

A few recurring habits distinguish smooth brokering setups from painful ones.

Pattern: One Provider per Trust Relationship

Configure a distinct Identity Provider entry for each external system, even if two happen to use the same protocol, so each can be tuned, monitored, and revoked independently.

Pattern: Use Mappers Instead of Custom Code

Prefer built-in attribute, role, and group mappers over custom scripting wherever possible, keeping the configuration declarative and easier to audit.

Pattern: Document the First Broker Login Behavior

Make the chosen account-linking policy explicit and documented, since it’s a security-relevant decision easy to overlook during initial setup.

ANTI-PATTERN-02 Avoid
Problem

Leaving an Identity Provider configuration at its default settings without reviewing the First Broker Login flow or which claims are requested.

Why It’s Harmful

Defaults are chosen for general applicability, not for any specific organization’s security requirements, and can silently create weaker account-linking behavior than intended.

Correct Approach

Treat every new Identity Provider setup as requiring a deliberate review of its linking behavior, requested scopes, and mapper configuration before going live.

14Best Practices & Common Mistakes

A short, practical checklist for teams setting up their first Identity Provider in Keycloak.

1

Register the exact redirect URI

Copy Keycloak’s generated redirect URI precisely into the external provider’s configuration — small mismatches are a frequent source of login failures.

2

Test the full first-login journey

Walk through account creation, not just the redirect, since that’s where linking decisions and mapper behavior actually show themselves.

3

Rotate client secrets on a schedule

Treat the external provider’s client secret like any other long-lived credential that needs periodic rotation.

4

Give users a way to see linked identities

Point users to Keycloak’s account console, where they can review and unlink external identities themselves.

!
Common Mistake

Assuming a working test login means the whole configuration is correct — many issues, like incorrect linking behavior or missing mapper claims, only appear on a user’s very first login and can be easy to miss during a quick manual test.

15Real-World Use Cases

Identity brokering shows up anywhere an organization wants to reuse an identity that already exists somewhere else.

Consumer Apps

Social Login

Letting users sign up and log in with an existing Google or GitHub account, reducing friction and password fatigue.

Enterprise

Corporate SSO Integration

Connecting to a company’s Microsoft Entra ID or other enterprise directory so employees can use their existing work credentials.

Cross-Realm

Multi-Realm Keycloak Deployments

Brokering between two separate Keycloak realms lets one team’s users access another team’s applications without duplicating accounts.

Partnerships

B2B Identity Federation

Trusting a partner organization’s identity provider lets their employees access shared applications without needing accounts created and managed manually on the other side.

16Monitoring, Logging & Metrics

Because brokered logins span two systems, good visibility matters even more than for purely local authentication.

Track first-login vs. returning-login counts

Watching how many logins trigger the First Broker Login flow versus reuse an existing link helps spot unexpected account-creation spikes.

Log linking decisions explicitly

Recording every time an external identity is newly linked to a local account creates an audit trail useful for later security reviews.

Alert on external provider errors

A rising rate of failed token exchanges with a specific Identity Provider often signals an external outage, an expired certificate, or a misconfigured secret.

17Frequently Asked Questions

Q1Does Keycloak store the user’s password from the external provider?

No. With brokering, Keycloak never sees the user’s raw password at the external provider at all — it only receives a signed token or assertion confirming that authentication already succeeded.

Q2Can a user link more than one external identity to the same local account?

Yes. A single Keycloak user can have multiple federated identity links, one per configured Identity Provider, letting them log in through any of several external systems.

Q3What’s the difference between an Identity Provider and a client?

A client represents an application that trusts Keycloak to log its users in. An Identity Provider represents an external system that Keycloak itself trusts to authenticate users. They serve opposite directions of trust.

Q4Can brokering be combined with multi-factor authentication?

Yes. Keycloak can require additional authentication steps, such as an OTP, on top of a brokered login, either always or only in specific configured circumstances.

Q5What happens if the external provider is temporarily unreachable?

Users attempting to log in through that specific Identity Provider will be unable to authenticate until it’s reachable again; this doesn’t affect local accounts or other configured providers.

Q6Can an administrator remove a user’s link to an external provider?

Yes, through the Admin REST API or admin console. Doing so means the next login from that provider will be treated as new and will re-trigger the First Broker Login flow.

18Summary and Key Takeaways

An Identity Provider configuration is how Keycloak extends trust outward, letting an external system perform authentication while Keycloak translates the result into a normal local session. Built on standard protocols like OIDC and SAML, and governed by mappers and a dedicated First Broker Login flow, this feature turns “Login with X” buttons from a one-off integration problem into a centrally managed, reusable capability. Used carefully — with verified claims, deliberate linking rules, and properly protected secrets — identity brokering lets organizations reuse identities that already exist, rather than asking users to create yet another password.

Key Takeaways

  • Brokering delegates authentication — Keycloak trusts the external provider’s result instead of checking credentials itself.
  • It’s distinct from user federation — federation still has Keycloak check credentials directly against an external directory.
  • The federated identity link is the key record — it’s what lets Keycloak recognize a returning brokered user without repeating account creation.
  • The First Broker Login flow matters — it governs whether a new account is created or an existing one is linked, and carries real security weight.
  • Mappers keep data in sync — translating external claims into local attributes, roles, and groups automatically.
  • Multiple protocols, one experience — OIDC, SAML, and social providers all funnel into the same consistent Keycloak login flow.
  • Trust decisions deserve deliberate review — especially around email verification and automatic account linking.