Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Minimal outbound SCIM provider for Keycloak

A minimal SCIM 2.0 provider extension for Keycloak 26.6.4. Keycloak is the source of truth: user, group, membership, and selected role changes are sent to configured SCIM targets. It is a Kotlin rewrite inspired by mitodl/keycloak-scim, under the in.sunal.keycloak namespace.

Code layout

  • config — realm component settings and the User Federation configuration provider
  • event — Keycloak event handling and dispatch to configured SCIM targets
  • client — outbound SCIM HTTP transport and authentication
  • sync — user/group payload mapping and synchronization orchestration
  • persistence — the SCIM_RESOURCE entity, repository, and JPA registration

Synchronization behavior

  • Creates use POST /Users or POST /Groups.
  • Updates use full-resource PUT /Users/{id} or PUT /Groups/{id}.
  • Deletes use DELETE /Users/{id} or DELETE /Groups/{id}.
  • User roles are included only when the Keycloak role attribute scim is exactly true. Roles inherited from direct group membership are included.
  • Groups contain direct user members only. Nested groups are not exported.
  • A user or group with the attribute scim-skip=true is not synchronized.
  • Local-to-remote IDs are stored in the SCIM_RESOURCE table per realm and target component.
  • Realm and client role assignments are handled from both the standard Admin API and the Admin UI bulk-delete endpoint.
  • A permanent-lockout event updates the remote user's active state.
  • Deleting a user refreshes mapped groups so their membership no longer relies on target-side delete cascading. Deleting a group or changing/deleting a role refreshes mapped users so inherited or renamed roles are removed.

This provider is outbound only. It never reads remote users or groups into Keycloak, and enabling it does not export all existing resources. It reacts to events that occur after enablement. An existing resource is created remotely when a later create/update/membership event first reaches the provider.

Delivery is best effort and each event makes one HTTP attempt. A timeout, connection failure, or non-success response is logged but never rolls back the Keycloak change. There is no automatic retry, durable queue, periodic reconciliation, or one-off export:

  • A failed create stores no mapping; a later event can attempt creation again.
  • A failed update keeps its mapping; a later event can attempt the PUT again.
  • A failed delete keeps its mapping, but because the local resource is already gone there may be no later event to retry it. Operators must inspect the log and delete the remote resource manually or otherwise re-drive the operation.
  • A remote 404 during delete is treated as success and removes the mapping.

Some uncommon cleanup events can fan out. User deletion refreshes all mapped groups for that target; group deletion and role updates/deletions refresh all mapped users. These passes only update entries already present in SCIM_RESOURCE: they are not an initial export and do not create unrelated existing users or groups. A failure for one refreshed resource is logged and does not stop the remaining resources.

Nested groups, organizations, LDAP/import reconciliation, retries, and an outbox remain outside this provider's scope.

Configuration

Enable the scim event listener in the realm, then add a scim entry under User Federation. Each entry represents one independent outbound target and can enable or disable user and group propagation separately.

Configuration supports:

  • SCIM 2.0 base endpoint
  • no authentication, bearer-token authentication, or HTTP Basic authentication
  • connection and request timeouts

Credentials are stored in the Keycloak component configuration. The bearer token/basic password field is rendered as a password field, but this provider does not integrate with the Keycloak vault.

Build and installation

Build with JDK 21:

gradle clean test integrationTest shadowJar

Copy build/libs/keycloak-scim-1.0.0.jar to /opt/keycloak/providers/, then rebuild the Keycloak installation:

bin/kc.sh build

License

Licensed under the Apache License 2.0. See NOTICE for upstream attribution.

About

Outbound SCIM extension for keycloak

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages