User federation
User federation lets Keycloak authenticate members held in an external store, such as an LDAP directory, a REST service or a database, without copying them into its own database.
Federation is not provisioning
This page is about authentication: delegating sign-in to another store. Provisioning, which fills the platform's directory from an external information system, is a separate subject.
Concepts
- A user storage provider is the Keycloak interface to an external store of members, groups and roles. Keycloak ships providers, such as LDAP, and accepts custom ones.
- User federation is the use of such providers to authenticate members, read their information and, where allowed, manage their roles and groups.
Kinds of federation
| Source | How |
|---|---|
| LDAP | Built-in provider: import, synchronization and authentication |
| Active Directory | Built-in provider, as a specific kind of LDAP |
| Custom database | A user storage provider written for that database |
| REST or other service | A user storage provider that calls the service |
How it works
- Lookup. Keycloak searches its local database first. If the member is not found, it queries the configured federation sources, in the order they are defined.
- Authentication. When the member is found in a federated source, Keycloak delegates the credential check to that source.
- Synchronization. Keycloak can synchronize members from the external store periodically, or keep only a reference and import a few attributes such as the name and e-mail.
- Updates. Some stores, such as LDAP, accept updates made through Keycloak, for example a password change. Others are configured read-only.
Federating the Open ENT directory
Open ENT ships a user storage provider that reads members from its own directory in Neo4j.
- In the Keycloak administration console, select the realm, then User Federation.
- Choose Add Provider, then Add user-storage-openent provider.
- Enter the address of the Neo4j server and the account used to read it.
- Choose whether members are synchronized or federated on demand, then save.
Testing
Search for a member of the directory in the Users screen of the realm, then sign in as that member. If federation is configured correctly, authentication succeeds and the member appears in Keycloak without having been created there.