Skip to content

Identity Federation & Social Login

Every real-world Keycloak deployment eventually needs to accept identities that live outside the realm itself. Maybe your users already have a Google account and you want them to log in with it. Maybe your company has an existing Active Directory full of employees who should not have to create a new Keycloak account. Keycloak solves both problems, but with different mechanisms.

Identity brokering means Keycloak acts as a trusted middleman between your application and another identity provider (IdP). When a user chooses to “Log in with Google” (or any OIDC/SAML-compliant provider), Keycloak redirects the user to that external provider, receives a token or assertion back, and then issues its own token to your application. Your application only ever talks to Keycloak — it never sees the external provider directly.

Use identity brokering when:

  • You want to add social login (Google, GitHub, Facebook, Apple, etc.).
  • You want to federate with another organisation’s SSO system (another Keycloak, Azure AD, Okta, etc.).
  • The external system speaks OIDC or SAML.

User federation means Keycloak connects to an external user store (typically LDAP or Active Directory) and reads user records from it. Keycloak does not copy the users into its own database by default — it queries the external store on demand. The users can log in to Keycloak using their existing credentials (LDAP password), but authentication may happen locally in Keycloak or be delegated to the LDAP bind.

Use user federation when:

  • Your organisation already has thousands of users in Active Directory or OpenLDAP.
  • You want a single source of truth for user accounts.
  • You want Keycloak to appear to those users as just another app in their existing directory.
Identity brokeringUser federation
Login flowRedirects to external IdPKeycloak authenticates (uses LDAP bind for password)
User sourceExternal IdP’s user databaseLDAP / Active Directory
ProtocolOIDC or SAMLLDAP protocol
Typical use caseSocial login, org-to-org SSOCorporate directory integration
LessonWhat you will learn
Social LoginAdd Google or GitHub as a social login provider
Identity BrokeringBroker with any OIDC/SAML IdP and handle first-login flows
LDAP FederationConnect Keycloak to LDAP or Active Directory
IdP MappersMap external claims and attributes onto Keycloak users
What does identity brokering do?
When is user federation the right choice?
Which protocol does user federation with Active Directory use?