What Is Just-in-Time Provisioning in Keycloak?

What Is Just-in-Time Provisioning in Keycloak?

A complete, beginner-friendly walkthrough of how Keycloak creates and updates local user accounts automatically, right at the moment someone logs in — instead of provisioning them ahead of time.

Imagine a hotel that doesn’t pre-print a room key for every guest who might ever visit. Instead, the moment a verified guest walks up to the front desk with valid identification, the system creates their room key on the spot, based on the details on that ID. No advance list of every possible guest is needed — the account is built exactly when it’s first needed, and not a moment before. That’s the essence of Just-in-Time (JIT) Provisioning in Keycloak: rather than an administrator manually creating every user account ahead of time, Keycloak creates (and keeps updating) local user records automatically, right at the moment of login, based on information it receives from a trusted external source.

1What Is JIT Provisioning, Really?

Before touching Keycloak’s screens, let’s fix the plain-English idea in place.

Just-in-Time Provisioning is the practice of creating a user’s account record automatically, at the exact moment they first authenticate, rather than requiring someone to create that account beforehand through a separate administrative process. In Keycloak, this most commonly happens in two situations: when a user logs in for the first time through a brokered Identity Provider (like a corporate SSO system or a social login), and when a user authenticates against an external directory through User Federation (like LDAP) configured in import mode.

In both cases, the underlying idea is the same: Keycloak trusts that the external system has already verified who this person is, so instead of asking an administrator to separately go create a matching local record, it builds — or refreshes — that record itself, using the attributes handed back by the external system at login time.

Simple Analogy

Think of a library that doesn’t issue library cards in advance for every resident of a city. Instead, the first time someone shows up with a valid ID, the librarian creates their card on the spot, copying their name and address straight off that ID. Nobody had to predict who would show up — the record is built exactly when it’s first needed.

i
Where the name comes from

“Just-in-time” is borrowed from manufacturing and supply-chain thinking, where materials arrive exactly when needed rather than being stockpiled in advance. Applied to identity, it means accounts are created exactly when needed, not stockpiled ahead of time.

2Why JIT Provisioning Exists

Understanding the problem it solves makes the whole feature click into place.

Manually provisioning every user account ahead of time works fine for small, stable populations of users. It quickly becomes painful at scale — think of an organization onboarding thousands of employees from a corporate directory, or a public-facing application expecting an unpredictable stream of new sign-ups through social login. Pre-creating every possible account either requires constant administrative effort to keep synchronized, or simply isn’t practical when the exact set of future users isn’t known in advance.

JIT provisioning sidesteps that problem entirely: there’s nothing to pre-create, and nothing to keep manually synchronized as the underlying population changes. The account simply appears — accurately reflecting the external source — the very first time it’s actually needed, and can keep refreshing itself on every subsequent login.

No more “please create my account first” tickets

With JIT provisioning, there’s no separate onboarding step where a new user has to wait for an administrator to manually add them before they can log in for the first time.

3JIT Provisioning vs. Other Provisioning Approaches

JIT is one of several ways user accounts can end up inside Keycloak — it helps to see it alongside the alternatives.

ApproachWhen the Account Is CreatedWho Triggers It
Manual CreationAhead of time, one by oneAn administrator, by hand
Bulk Import / SCIM SyncAhead of time, in batchesA scheduled sync process or provisioning system
Just-in-Time ProvisioningAt the moment of first loginThe login event itself

Keycloak doesn’t force an all-or-nothing choice between these. It’s common for an organization to use JIT for the everyday flow of new users logging in for the first time, while still occasionally relying on bulk imports or manual creation for special cases, like service accounts or accounts that need to exist before anyone has actually logged in.

!
Common Misconception

JIT provisioning is not a single toggle somewhere in Keycloak — it’s a natural side effect of how Identity Brokering’s First Broker Login flow and LDAP User Federation’s import mode already behave.

JIT provisioning in Keycloak happens through two related, but distinct, mechanisms.

Federated Login

Via Identity Brokering

The first time a user logs in through a configured external Identity Provider, Keycloak’s First Broker Login flow can automatically create a matching local user, populated from claims the provider returned.

Directory Login

Via LDAP User Federation (Import Mode)

The first time a user authenticates against an LDAP-backed User Federation provider running in import mode, Keycloak copies that user’s directory attributes into a local, cached user record.

Both paths share the same underlying philosophy — trust an external source, and build the local record from it, exactly when it’s first needed — but they differ in what triggers them and where the “source of truth” for future attribute updates lives afterward.

5JIT Through Identity Brokering

This is the path most people mean when they talk about JIT provisioning in Keycloak.

When a user authenticates through a brokered Identity Provider for the very first time, and no existing federated identity link is found, Keycloak’s First Broker Login flow kicks in. Depending on how that flow is configured, it can automatically create a new local user, pre-filling attributes like name and email straight from the claims the external provider returned — all without an administrator ever touching the admin console.

flowchart LR
    A["User logs in via
Identity Provider (first time)"] --> B{"Federated Identity
Link exists?"} B -- No --> C["First Broker Login Flow"] C --> D["Create local user
from provider claims"] D --> E["Identity Provider Mappers
set attributes/roles/groups"] E --> F["Local session issued"] B -- Yes --> F
FIG 1 — The very first login is where the local account is actually built; every login after that simply reuses it.

6JIT Through LDAP User Federation

The second common path runs through Keycloak’s directory integration rather than a login-page redirect.

When an LDAP-backed User Federation provider is configured with the Import edit mode, the first time a user successfully authenticates against that directory, Keycloak copies the relevant LDAP attributes into a local user record inside its own database. On future logins, Keycloak re-validates the password against LDAP again, and can refresh the cached local attributes to stay in sync with any changes made in the directory.

Import mode vs. unsynced mode

Import mode is what enables the JIT-style local caching described here. Keycloak also supports other LDAP modes with different trade-offs around where passwords and attributes are ultimately treated as the source of truth.

i
Practical Tip

Import mode is popular because it lets applications built against Keycloak’s own database work unmodified with LDAP-backed users, since a real local user record actually exists after the first login.

7The JIT Flow, Step by Step

Here’s the sequence of events for a brand-new user’s very first login, brought together in one place.

1

User attempts to log in

They authenticate through a brokered Identity Provider or against an LDAP directory configured for import.

2

External authentication succeeds

The external system confirms the person is who they claim to be and returns identity information back to Keycloak.

3

Keycloak checks for an existing local record

No matching local user or federated link is found, since this is genuinely the first login.

4

A new local user is created automatically

Keycloak builds the local record on the spot, populated using mappers that translate external attributes into Keycloak’s own fields.

5

Roles and groups are assigned

Configured mappers can also assign roles or group memberships based on the external attributes, all as part of this same first-login moment.

6

A normal session is issued

From this point forward, the user has a real, local Keycloak account and can be treated exactly like any manually created user.

8Attribute & Role Sync at Login Time

JIT provisioning doesn’t stop at account creation — it can keep refreshing details on every subsequent login too.

Both brokering-based and LDAP-based JIT flows can be configured to re-apply mappers on every login, not only the very first one. That means if a user’s job title changes in the corporate directory, or their department claim changes at the external Identity Provider, the next time they log in, Keycloak can automatically update the corresponding local attribute, role, or group membership to match.

On Create

Initial Population

Runs once, the first time the account is created, setting up the baseline attributes and role assignments.

On Every Login

Ongoing Sync

Certain mappers can be configured to re-evaluate and update attributes every time the user logs in, keeping the local record fresh.

“JIT provisioning isn’t just about creating an account once — done well, it keeps that account quietly accurate for as long as the user keeps logging in.”

9Data Flow & Lifecycle

Zooming out to see how a JIT-provisioned account behaves across its whole lifetime, not just at creation.

sequenceDiagram
    participant U as User
    participant K as Keycloak
    participant Ext as External System (IdP / LDAP)

    U->>K: First login attempt
    K->>Ext: Authenticate / verify identity
    Ext-->>K: Success + attributes
    K->>K: No local user found — create one
    K-->>U: Session issued (account now exists)

    Note over U,Ext: Time passes — attributes change externally

    U->>K: Later login
    K->>Ext: Authenticate again
    Ext-->>K: Success + updated attributes
    K->>K: Refresh existing local user's attributes
    K-->>U: Session issued (account now up to date)
        
FIG 2 — Every login is an opportunity for Keycloak to both authenticate the user and quietly keep their local record current.

10The Deprovisioning Gap

JIT provisioning is excellent at creating and updating accounts — it’s worth being honest about what it doesn’t automatically handle.

Because a JIT-provisioned account is only ever touched when its owner logs in, there’s a natural gap: if a user is removed from the external directory or Identity Provider but never logs in again, their local Keycloak account can simply sit there, unchanged, since nothing triggers an update for a login that never happens. This is sometimes called the “deprovisioning gap,” and it’s a well-known limitation of purely login-triggered provisioning.

!
Security Consideration

Relying on JIT provisioning alone is not a substitute for a proper offboarding process. Organizations with strict access requirements typically pair JIT with a separate, scheduled process — or a real-time SCIM-based sync — to actively disable or remove accounts when someone leaves.

Common mitigation

Some organizations combine JIT provisioning for smooth onboarding with a periodic reconciliation job that compares Keycloak’s user list against the external source and disables anyone no longer present there.

11Security Considerations

Automatically creating accounts based on external input is convenient, but it deserves the same scrutiny as any other trust boundary.

Trust Source

Only JIT-provision from trusted sources

Since the local account is built directly from external claims or directory attributes, the external source must be one Keycloak genuinely trusts to be accurate.

Default Roles

Be deliberate about default access

Consider what roles or groups a newly auto-created account should have by default, since an overly generous default can grant more access than intended to every new user.

Offboarding

Pair with a deprovisioning process

As covered above, JIT alone doesn’t remove access when someone leaves the external source — that needs a separate, deliberate mechanism.

ANTI-PATTERN-01 Avoid
Problem

Enabling JIT provisioning from an Identity Provider or LDAP source without reviewing which roles or groups get assigned to newly created accounts by default.

Why It’s Harmful

Every new user created this way silently inherits whatever the default mapper configuration provides — an overly broad default can quietly over-provision access at scale.

Correct Approach

Review and intentionally scope default role and group mappers before enabling JIT provisioning in production, treating that configuration as a security-relevant decision.

12Advantages, Disadvantages & Trade-offs

JIT provisioning trades some control for a lot of operational simplicity.

Advantages

  • Removes the need to pre-create accounts for users who may never actually log in
  • Scales naturally to large or unpredictable user populations
  • Keeps local attributes fresh automatically, without a separate sync job, when configured to update on every login
  • Reduces onboarding friction — no waiting for an administrator before a first login can happen

Disadvantages / Trade-offs

  • Leaves a deprovisioning gap for users who stop logging in without being explicitly removed
  • Default role and group assignment mistakes affect every newly created user at scale
  • Local data can briefly lag behind the external source between logins
  • Debugging “why does this user look wrong” issues requires understanding both Keycloak and the external source

13Design Patterns & Anti-Patterns

A few recurring habits separate smooth JIT rollouts from confusing ones.

Pattern: Minimal, Well-Scoped Default Access

Grant newly JIT-provisioned users the smallest reasonable set of roles and groups by default, expanding access deliberately afterward rather than upfront.

Pattern: Combine JIT with Scheduled Reconciliation

Use JIT for smooth onboarding, paired with a periodic job or SCIM integration that catches and disables accounts for users removed from the external source.

Pattern: Keep Mapper Logic Declarative

Favor Keycloak’s built-in mapper types for attribute, role, and group assignment over custom scripting, keeping the provisioning logic easy to audit.

ANTI-PATTERN-02 Avoid
Problem

Treating JIT provisioning as a complete substitute for a formal user lifecycle process, with no plan for handling departures from the external source.

Why It’s Harmful

Accounts for people who have left an organization or lost access elsewhere can remain fully active in Keycloak indefinitely, since nothing about JIT alone detects their absence.

Correct Approach

Pair JIT provisioning with an explicit offboarding mechanism, whether that’s a scheduled reconciliation job, a SCIM-based sync, or a manual review process.

14Best Practices & Common Mistakes

A short, practical checklist for teams enabling JIT provisioning for the first time.

1

Map only the attributes you actually need

Avoid pulling in every available external claim or LDAP attribute by default — copy over what the application genuinely uses.

2

Test the very first login carefully

That’s the moment account creation and default role assignment actually happen — a normal “already exists” test login won’t reveal the same behavior.

3

Decide explicitly whether attributes refresh on every login

Choose deliberately whether local data should stay in sync with the external source on every login, or only be set once at creation.

4

Plan for offboarding from day one

Don’t wait for the first departure to discover the deprovisioning gap — design a mitigation before going live.

!
Common Mistake

Assuming that because an account was JIT-provisioned correctly once, it will always stay accurate — without ongoing sync configured, a user’s local attributes can quietly drift out of date after their very first login.

15Real-World Use Cases

JIT provisioning shows up anywhere the exact set of future users isn’t fully known in advance.

Enterprise Onboarding

Large Corporate Directories

New employees automatically get a working Keycloak account the moment they first log in through the company’s Identity Provider, with no separate manual step.

Consumer Products

Social Login Sign-Ups

A public application accepting “Login with Google” style sign-ups relies entirely on JIT provisioning to create accounts for an unpredictable stream of new users.

Mergers & Acquisitions

Bridging Two Organizations

Employees from an acquired company can start using shared systems immediately by logging in through their existing directory, without a manual bulk-migration project first.

Multi-Tenant SaaS

Customer-Owned Directories

A SaaS platform lets each customer connect their own Identity Provider, and JIT provisioning creates that customer’s users inside the platform automatically as they log in.

16Monitoring, Logging & Metrics

Because JIT provisioning creates accounts silently, having visibility into what’s happening matters.

Track new-account creation rate

Watching how many brand-new local accounts get JIT-created per day helps catch both healthy onboarding growth and unexpected spikes worth investigating.

Log default role and group assignments

Recording what access a newly created account received by default supports later audits of who was granted what, and when.

Periodically compare against the external source

Running a scheduled comparison between Keycloak’s user list and the external directory or Identity Provider’s population helps surface the deprovisioning gap before it becomes a real security issue.

17Frequently Asked Questions

Q1Is JIT provisioning a specific setting Keycloak has?

Not exactly. It’s the natural result of how Identity Brokering’s First Broker Login flow and LDAP User Federation’s import mode already behave — there’s no single dedicated “JIT” toggle.

Q2Does JIT provisioning work with SAML as well as OIDC?

Yes. Since JIT provisioning through brokering is a property of the First Broker Login flow, it applies regardless of whether the underlying Identity Provider uses OIDC or SAML.

Q3What happens to a JIT-provisioned account if the external source is later removed?

The local Keycloak account remains as-is; JIT provisioning doesn’t automatically detect or react to removal at the external source, which is why a separate deprovisioning process is important.

Q4Can an administrator manually edit a JIT-provisioned account afterward?

Yes. Once created, it’s a normal local Keycloak user and can be edited like any other account, though changes may be overwritten later if attributes are configured to sync on every login.

Q5Is JIT provisioning suitable for highly regulated environments?

It can be, but typically only when paired with a proper offboarding and audit process, since regulated environments usually require timely, verifiable access removal that JIT alone doesn’t provide.

Q6Does JIT provisioning create passwords for new local accounts?

No. Since authentication is delegated to the external source, JIT-created accounts typically don’t get a local password at all — they continue authenticating through the same external system going forward.

18Summary and Key Takeaways

Just-in-Time Provisioning is Keycloak’s way of building — and optionally continuing to refresh — a local user account automatically, exactly at the moment it’s first needed, rather than requiring it to be created in advance. It shows up naturally through Identity Brokering’s First Broker Login flow and through LDAP User Federation running in import mode, both of which trust an external source enough to build a local record straight from its attributes. Used thoughtfully — with tightly scoped default access and a real plan for offboarding — JIT provisioning removes a huge amount of manual account-management overhead, at the cost of needing a deliberate answer for what happens when someone eventually leaves the external source behind.

Key Takeaways

  • Accounts are created at first login — not pre-provisioned ahead of time by an administrator.
  • Two main doors trigger it — Identity Brokering’s First Broker Login flow, and LDAP User Federation in import mode.
  • Mappers drive the details — translating external claims or attributes into local user fields, roles, and groups.
  • It can keep syncing, not just create once — attributes can refresh on every subsequent login if configured to do so.
  • There’s a real deprovisioning gap — JIT alone doesn’t detect or react to a user disappearing from the external source.
  • Default access deserves scrutiny — since it applies automatically to every newly created account.
  • It shines at scale — large or unpredictable user populations are exactly where JIT provisioning saves the most manual effort.