Skip to main content

Runtime Sync

Summary

Runtime Sync enables real-time synchronization of user data, credentials, and events between Keycloak and external systems. Through Keycloak SPI extensions, Runtime Sync propagates changes to external systems when users update their passwords, modify their profiles, or perform authentication actions — maintaining consistency across integrated platforms.

Why It Exists

Enterprise environments often maintain user data in multiple systems:

  • Legacy identity systems that predate Keycloak adoption
  • External workforce management platforms
  • Partner systems requiring credential synchronization
  • Compliance systems requiring real-time event feeds

Without runtime synchronization:

  • Password drift — Users update passwords in Keycloak, but external systems retain old credentials
  • Attribute inconsistency — Profile changes in Keycloak are not reflected elsewhere
  • Audit gaps — Authentication events are not captured by external compliance systems

Runtime Sync addresses these challenges through event-driven synchronization that propagates changes in real time.

Where It Fits in Keymate

Runtime Sync operates through Keycloak's Service Provider Interface (SPI) mechanism. Extensions register as event listeners and sync providers, receiving callbacks when relevant events occur.

Boundaries

What it covers:

  • Password synchronization to external systems
  • User attribute synchronization
  • Authentication event propagation
  • Non-blocking sync with graceful failure handling

What it does not cover:

How It Works

Sync Provider Model

Sync providers implement a standard interface for credential synchronization:

MethodTriggerPurpose
Password SyncPassword updatePropagate new credentials to external systems
Attribute SyncProfile updatePropagate attribute changes
Event NotifyAny Keycloak eventForward events to external listeners

Non-Blocking Design

Runtime Sync operates in a non-blocking manner:

  1. User performs an action in Keycloak (e.g., password update)
  2. Keycloak completes the action locally
  3. Sync providers receive callbacks asynchronously
  4. External sync failures do not block the original operation
  5. The system logs failures for monitoring and manual intervention

This design ensures that external system availability does not affect Keycloak operations.

User Targeting

Sync providers support selective synchronization based on user attributes:

AttributePurpose
Sync enabledFlag indicating whether sync is active for this user
User typeClassification determining sync behavior
External IDIdentifier in the external system

Configuration

Sync providers use environment variables for configuration:

ParameterDescription
Sync enabledGlobal toggle for sync functionality
External API URLEndpoint for external system API
Default user typeDefault classification for new users

Event Types

The following events trigger sync provider callbacks:

EventSync Action
Password updateCredential sync
Profile updateAttribute sync
Login successEvent notification
Login failureEvent notification
LogoutEvent notification

Diagram

Example Scenario

Scenario

A user updates their password in Keycloak. The password sync provider propagates the new credential to an external workforce system.

Input

  • Actor: End user updating password
  • Resource: Password sync provider
  • Action: Password change
  • Context: User has sync enabled attribute set to true

Expected Outcome

  • Password updates successfully in Keycloak
  • Sync provider receives password change callback
  • Provider checks user eligibility (sync enabled, correct user type)
  • Provider sends credential update to external system API
  • The system logs success or failure
  • User can log in with new password regardless of sync result

Common Misunderstandings

  • Sync failure blocks user actions — Sync operations are non-blocking. Users can continue even if external sync fails.
  • All users sync automatically — Only users with sync enabled attributes participate in synchronization.
  • Sync is bidirectional — Runtime Sync is typically unidirectional (Keycloak → external). Reverse sync requires separate mechanisms.
warning

External system failures do not prevent Keycloak operations, but they create credential drift. Monitor sync failure logs and implement alerting for prompt intervention.

Design Notes / Best Practices

  • Mark users for sync explicitly using user attributes
  • Monitor sync failure rates and response times
  • Implement retry logic in external system integrations
  • Use meaningful user type classifications
  • Log all sync operations for audit trails
tip

Configure alerting on sync failure patterns to detect external system outages before they cause widespread credential drift.

  • Password synchronization with legacy identity systems
  • Real-time event feeds to compliance platforms
  • Attribute propagation to HR systems
  • Credential sync for partner access management