Keycloak workflows for user onboarding and offboarding

Keycloak workflows can run scheduled and event-triggered steps such as notifying owners or disabling accounts when users join, leave or go inactive. This page explains what they cover, how to set them up and where a full identity governance tool becomes necessary.

On this page

How Keycloak user onboarding and offboarding workflows fit your lifecycle process

Keycloak workflows automate the repeatable steps of joiner, leaver and inactivity handling inside the identity server itself, so an identity team does not have to move every account change through a ticket. A workflow can run a set of steps when a user event happens or on a schedule, for example notifying an administrator or disabling an account that has not signed in for a defined period. The practical question for your team is which of those steps you want Keycloak to own and which must stay with the system that already knows who works where, usually an HR platform or a provisioning source.

The exact trigger and action list depends on the Keycloak version and distribution you run, so confirm it before you design anything. Check the server administration guide for the workflow triggers, step types and conditions available in your release, and test each one in a non-production realm. Red Hat build of Keycloak follows the upstream project but is supported on its own release line, so confirm its feature set separately if that is your distribution. Record the exact version and the workflow behavior you tested, because a later upgrade can change what a step does. Plan a retest after every upgrade rather than assuming earlier results still hold.

Before you build, decide where the source of truth lives. If joiners and leavers are entered in an HR system, a workflow in Keycloak should react to the accounts that arrive from that feed, not invent its own population of people. Decide who approves a disable or deletion, how the action is logged for audit, and how a disabled account is restored if a leaver returns or a dormant account was wrongly flagged. Those decisions define the boundary of the workflow. Once an organization needs approvals across several systems, access certification or role models, it has moved past what a workflow is meant to cover and needs a dedicated identity governance product.

Which workflow triggers and actions fit which lifecycle step

This table compares joiner, leaver and inactivity needs against the workflow triggers and actions you should confirm in your Keycloak version. Read each row as a pairing: the trigger that starts the step, the action it runs, what the step depends on, and the main risk to plan for before enabling it.

Lifecycle needTrigger and action that fitDepends onMain risk
Joiner: welcome and first sign-in noticeEvent-triggered notify action on user creation, confirmed in your version's workflow optionsValid user email, working SMTP delivery with StartTLS enforced in 26.8Notice sent to a wrong or unverified address if the user record is incomplete
Joiner: group or role assignmentEvent-triggered role or group action, if your version offers it; otherwise handle through SCIM or an external toolConsistent group naming, an upstream attribute that marks the joiner's teamOver-granting access when a broad group is assigned by default
Leaver: disable account on terminationScheduled or event-triggered disable action driven by an HR or directory signalA reliable termination signal from the source system, such as federated directory state or SCIM updatesDisabling the wrong account if identifiers do not match across systems
Leaver: remove sessions and revoke accessDisable action paired with session logout, confirmed in the admin events and session settings for your versionKnown list of active sessions and client dependenciesLong-lived refresh tokens remaining valid if sessions are not terminated
Inactivity: notify before actionScheduled step that notifies users or managers after a defined idle periodLast-login data recorded in the user event store and event retention configuredNotices going to shared or stale mailboxes, or missing login data if events are not stored
Inactivity: disable dormant accountsScheduled disable action run after a notice window, confirmed in your versionLogin event history, an agreed inactivity threshold set by policy, and an owner for exceptionsLocking out service or seasonal users who rarely sign in
Delete or role-change actionsDelete or role-change action, only if your version documents it and an approver is definedRetention rules, an audit trail, and a rollback pathIrreversible data loss or accumulated privileges when role changes are not reviewed
Access reviews and approvalsNot a native workflow step in most setups; confirm with your version or plan a governance toolApproval records, certification campaigns and reviewer ownershipRelying on automation alone to prove an access decision was reviewed

What to automate for joiners, leavers and inactive accounts

A joiner workflow starts once an identity exists in Keycloak, whether it came from HR-driven provisioning, a SCIM feed or a manual create. Keycloak can own the steps that act on that account: setting required actions so the user completes them at first sign-in, sending a welcome message, and adding the user to baseline groups that carry default application access. Illustrative example: a new engineer's account is created before the start date, and on first sign-in the user must change the password and enroll an OTP credential before reaching any application.

  • Required actions: Set actions such as password update, email verification or OTP setup so they run at first sign-in.
  • Welcome notices: Send sign-in instructions through the realm email settings, and test delivery before relying on it.
  • Baseline groups: Add the user to the groups that represent default access, and keep elevated access out of the automatic path.
  • Still with HR or the manager: Confirm the start date, job family and any access beyond the baseline.
  • Still with tickets: Track hardware, application onboarding and access requests that need an approver.

After the workflow fires, check that the account has the expected attributes, that required actions appear at first sign-in, that the welcome message arrives, and that group membership matches the approved request.

How a lifecycle event moves through Keycloak and out to people

The flow starts when an HR or directory change reaches Keycloak as a user event or a scheduled check. A workflow then evaluates conditions on user attributes or group membership and chooses between a notify action, a disable action, or a branch that hands the step to a ticket or manual approval outside Keycloak. The trust boundary sits between Keycloak and the external systems that feed it or receive tickets. Check which events trigger the workflow, which actions it can run, and who owns the ticket queue before relying on it for leavers.

Lifecycle changes flow from HR into Keycloak workflows, with manual steps handed to tickets.

How to set up a joiner and leaver workflow in Keycloak

This sequence takes a joiner and a leaver workflow from version check to production change, so each step runs as designed and leaves evidence. It produces two tested workflow definitions, each checked against test accounts, events and notifications before promotion.

  1. Confirm the Keycloak version and workflow support

    Check which Keycloak release your environment runs, then confirm in the Keycloak server administration guide whether workflows exist in that release and whether they are enabled by default or behind a feature flag. The project lists 26.8.1 as its current release, but design against the version you actually run. The platform owner records the version, the feature state and the guide section in the change ticket. This step is done when the team can name all three without looking them up again.

  2. Define the attributes and groups for each workflow

    Decide which user attributes start the joiner workflow, which end the leaver workflow, and which groups or roles each one assigns or removes. Name the system that owns each value, such as an HR feed or an identity governance tool, and keep one owner for each value so Keycloak acts on a single source. Illustrative example: a joiner runs when employment status is set to active and a department value is present, and a leaver runs when status changes to terminated. Record the trigger, condition, action and owner in a table, and confirm every attribute exists in the user profile.

  3. Create a dedicated test realm

    Create a separate realm for testing, with its own test users, a mail capture tool or test mailbox for notifications, and no link to production directories or brokered identity providers. Keeping the test realm apart from production means a disable action or notification cannot reach an employee. Check the realm for any user federation or identity provider link, and confirm that every account is a test account with a name that marks it as one. The step is complete when the realm has no production connection and the team can show that to a reviewer.

  4. Build one joiner and one leaver workflow

    In the test realm, create the joiner workflow with its trigger, conditions, group assignment and notification. Then create the leaver workflow with its trigger, a notification to the manager or service desk, and the disable action. Keep each workflow to one purpose so a failure points to one definition. Confirm whether disabling an account also ends its active sessions and revokes its tokens, and record the answer. Check that both workflows save, show as enabled, and display the triggers you designed in step two.

  5. Run both workflows against test users

    Create a joiner test user that meets the joiner condition, and set a test leaver user to the leaver value. For the inactivity path, use a test account with no sign-ins, and confirm in the guide whether a short test schedule is possible before you wait on a scheduled step. Run each case once, then run one case whose condition is not met to confirm the workflow does not fire. The check: the joiner user has the expected groups, the leaver user shows as disabled in the admin console, and the non-matching user is unchanged.

  6. Check events and notifications for each run

    Open the admin events for each run and confirm an entry exists for each state change, with the actor and the affected user recorded. If user events are enabled, check that sign-in attempts for the disabled account fail and are logged. Confirm each notification reached the test mailbox with the right recipient and content, and that nothing went to a production address. Also test one failure, such as a missing notification address, and confirm an administrator can see it. Event storage and retention depend on your event settings, so confirm them in your audit logging setup before you rely on the trail.

  7. Promote the configuration through change control

    Record the workflow definitions, group mappings and attribute rules in the change record, then apply them to staging and production through your normal approval process, with no manual edits in production. Start production with the disable action limited to named, approved accounts or a small pilot group, and watch the first runs. Check that the first production joiner and leaver runs produce the same events and notifications as the test runs. Keep the evidence from the test steps in the change record, so the link between test and production is clear.

Security risks in automated disable and notify actions

Automated joiner, leaver and inactivity steps act on real accounts without a person reviewing each change, so one bad attribute or one overly broad permission can affect many users at once. The cards below cover the failure modes that matter most in Keycloak workflows, each with the control to put in place and the check to run in your own environment.

Disabling the wrong accounts

A workflow that keys on an attribute such as an employee status, department or last-login date will disable users whenever that value is wrong, stale or empty. An empty field can match far more accounts than intended. Require a non-empty match on a stable identifier, cap how many accounts one run may disable, and test the condition against a copy of real data before it goes live. Verify that a dry run lists the affected users for review.

Keycloak docs

Notifications that expose personal data

Notify actions can send user details, account names or reset links to the wrong recipient, or to a shared mailbox that more people can read. Keep notification templates to the minimum data the recipient needs, and send links that require the user to authenticate. Confirm that the SMTP connection uses StartTLS, since Keycloak 26.8 enforces it without plaintext fallback, and check which mailbox receives manager and HR copies.

Service accounts with broad admin roles

The workflow needs a service account or admin role to change users, and that credential becomes a high-value target. Grant only the realm-management roles the steps use, rather than full administrator rights. Keep the client secret or certificate in a secrets store, rotate it on a schedule, and confirm that the account cannot change its own roles or the workflow definitions.

Automated changes without audit trails

If a workflow disables or deletes accounts and no event record shows which step made the change, investigators cannot tell a bad rule from a compromised credential. Turn on admin and user events, decide how long they are kept, and forward them to your log platform. Check that each automated action names the workflow as its actor so it can be separated from manual administration.

Sessions that survive a disable

Disabling a user stops new sign-ins, but existing sessions and refresh tokens can remain valid for some time unless they are revoked. A leaver flow that only flips the enabled flag can leave a departed employee with working access to connected applications. Add a step that logs out the user's sessions, then test it by signing in through a client app, disabling the account and confirming the session ends. Also confirm the token lifetimes your clients use.

Unreviewed changes to workflow definitions

A workflow definition is code-like configuration, and an edit to a condition or recipient list changes live behavior for every user it touches. Store definitions in version control, require a second reviewer for changes, and test each change in a non-production realm before promotion. Verify who can edit workflows in the admin console and that every change is recorded, so a rollback is possible.

Where Keycloak workflows end and identity governance tooling begins

Keycloak workflows stop at the boundary of Keycloak's own accounts and events. They can react to a user being created or a login occurring, run steps on a schedule, notify people, and disable or delete accounts inside the realm. That is useful for a single realm where the identity source is Keycloak itself or a directory it federates. It does not decide who should have access in the first place, and it does not prove later that the decision was right. Before you build workflows, confirm which system is the authoritative source for joiners, movers and leavers, and whether Keycloak is that source or only a consumer of it.

Identity governance tooling takes over when the lifecycle must be driven by an HR system of record and carried out across many target systems: applications outside Keycloak, directories, cloud accounts and privileged tools. It adds role models that group entitlements, approval chains for requests, segregation-of-duties rules that block conflicting access, and periodic access certification where reviewers attest to what each person can reach and the campaign leaves evidence for auditors. Signals that you need this layer include several target applications that each hold their own accounts, approvals required before access is granted, certification campaigns required by your control framework, or conflicting-role rules that Keycloak cannot evaluate on its own.

Within the DeployOpen catalog, midPoint is one open-source option for the governance layer, covering HR-driven lifecycle, connectors to target systems, role models, approvals and access certification in infrastructure you control. Whether it fits depends on your connector coverage, approval design, reporting needs and team capacity to run it, so confirm those requirements against the product's documented capabilities before choosing it. Many organizations use Keycloak workflows for in-realm housekeeping alongside a governance tool that owns the decisions, and agreeing on which system owns each step is the design task that matters most.

Limits to confirm before you design around workflows

Workflow designs for joiners, leavers and inactive users depend on details that vary by Keycloak version, deployment shape and identity source. Check each item below against the release you plan to run before you commit a lifecycle design to it.

Trigger and action types in your version

Start by confirming which trigger types and actions the installed Keycloak release offers. Event-triggered steps, scheduled steps, notify actions and disable actions may differ in availability, configuration options and maturity between releases. Ask the vendor or check the server administration guide for the exact list, and record the version you tested against so the design can be re-checked at each upgrade.

Keycloak docs

Federated and SCIM-provisioned users

Confirm whether workflows can act on users that come from LDAP, Active Directory, brokered identity providers or SCIM provisioning. Where the directory is the source of truth, a disable action in Keycloak may be overwritten by the next sync or may not reach the upstream account at all. Test a leaver case on each user source you plan to support, and document which system owns the final disable decision.

Sessions and tokens after a disable

Establish how a disabled user's active sessions and issued tokens behave. Access tokens that are still valid may keep working until they expire, and refresh tokens and offline sessions may need explicit revocation. Confirm the behavior in your version by disabling a test user during an active session, then calling a protected API, and check the timing against your token lifetime settings.

Behavior in a clustered deployment

Confirm how scheduled steps and event handling run when several Keycloak nodes share one database. Duplicate execution, missed runs during node restarts and timing differences across nodes are all possible failure modes to rule out. Ask the vendor how scheduled work is coordinated across the cluster, and test a restart during a scheduled run in a staging environment that matches your high availability design.

High availability overview

Dependence on SMTP delivery

Determine whether notify actions depend on the realm's SMTP configuration. If messages fail silently, are queued without alerting, or are blocked by a TLS requirement, joiner welcome emails and leaver notices will never reach their recipients. Check the email settings against the upgrade notes for your release and send a test message through the same relay and TLS path that production will use.

Export, versioning and change control

Find out how workflow definitions are exported, imported and versioned. If a definition lives only in the admin console, it is hard to review, roll back or reproduce in a new realm. Ask whether definitions can be exported as files, how they are stored in your source control, and who approves a change before it reaches production.

Questions buyers ask about Keycloak lifecycle automation

How much effort does a Keycloak lifecycle workflow build take?

Effort depends mostly on how many sources feed the workflow, how many systems must be notified or have accounts disabled, and how many joiner, mover and leaver paths the business defines. A build that reads one HR export, sets a few attributes and disables accounts in one realm is small. Each additional source, approval step, exception path or downstream application adds design, test and documentation work. Inactivity rules add definition work, because the business must agree what counts as inactive and which accounts are exempt, such as service or break-glass accounts. Ask for the quote to break effort into those components. Also confirm which workflow capabilities your Keycloak version supports, starting with the Keycloak server administration guide.

Can our internal team build Keycloak lifecycle automation without outside help?

Yes, if the team already runs Keycloak in production, can read the documentation for the version it runs, and has a test environment where changes can be validated before production. The skills that matter most are Keycloak administration, configuration of event and scheduled steps, SMTP and directory knowledge, and change control for identity data. Teams new to Keycloak often underestimate testing of leaver paths, where one mistake can disable the wrong account or leave access in place. A useful check is whether one person can explain each workflow's trigger, target accounts, failure behavior and rollback steps. Many organizations build in-house and bring in a partner for the design review, a security test or the first upgrade cycle. Either model works if scope, owners and test evidence are written down before go-live.

What does a lifecycle workflow need from HR, the directory and service owners?

It needs a defined source of joiner, mover and leaver events, a user store that Keycloak reads from, and a named owner for each application that will be notified or affected. The main inputs are:

  • HR: employment status, effective dates for starts and departures, manager and department attributes, and a rule for which system is authoritative when records conflict.
  • Directory: the attribute names, group membership and federation settings Keycloak will read, plus the account types excluded from automation.
  • Service owners: which applications must drop access when someone leaves, what delay they accept, and who signs off on test results.

Ask HR to confirm that terminations are entered on the effective date, because late entries shift every downstream step. Agree these inputs in writing during discovery, since missing answers are the most common cause of schedule slippage in identity projects.

How long does a pilot need to validate lifecycle workflow tests?

The pilot length depends on several drivers, and the written scope should state the duration for your case. The main drivers are the number of joiner, mover and leaver paths under test, whether a representative copy of the directory and HR data is available in a test environment, and how many edge cases the business wants covered, such as rehires, transfers during a leave period and shared mailboxes. Other drivers are whether notification targets exist in test, how many review rounds HR and service owners need, and whether auditors or internal governance will expect written test evidence. Each change to a workflow usually requires rerunning the affected tests, so plan for a repeat cycle. Ask the partner to list test cases with expected results before the pilot starts.

Do Keycloak workflows replace SCIM provisioning?

No. SCIM and workflows solve different parts of the lifecycle and often run side by side. SCIM is the interface an external system uses to create, update or deactivate users and groups in Keycloak. Workflows run inside Keycloak in response to events or schedules, for example to notify an owner, disable an account after a set period or flag inactivity. If your HR or governance tool already pushes changes over SCIM, workflows may only handle the steps that follow an account change. Check for overlap so that one system does not disable an account the other is still updating. The SCIM provisioning topic on this site covers the provisioning side in more detail.

What recurring work follows go-live for lifecycle workflows?

Recurring work comes from the platform, the workflows and the business process. The Keycloak project plans four minor releases a year and a major release every two to three years, and breaking changes in minor releases are opt-in. Upgrade notes for 26.8 include enforced SMTP StartTLS without plaintext fallback, which can break notify steps if a mail relay does not support it. They also require signature validation for backchannel logout tokens from external providers and persist login failures to the database by default. Each upgrade should rerun the workflow test cases. Workflow reviews are also recurring: rules change when HR processes, applications or inactivity policies change. Decide whether upgrades and reviews are covered by a retainer or by internal staff, and read the upgrading guide before each version change.

What should a quote for Keycloak lifecycle automation include?

A quote should follow from a written scope, because DeployOpen does not publish a price list and most engagements are fixed-scope with scope, deliverables and timelines agreed in writing before work starts. Ask the quote to show:

  • Scope: named joiner, mover and leaver paths, inactivity rules, and each system a workflow touches.
  • Assumptions: who provides HR data, directory access, SMTP details, test environments and service owner sign-off.
  • Deliverables: workflow configuration, test cases with expected results, a runbook, rollback steps and handover notes.
  • Exclusions: SCIM provisioning, approval or certification features, and any target system not listed.
  • Recurring items: upgrade support, workflow reviews and whether they are priced as a retainer.

Compare quotes on these lines, not on total cost alone, because differing exclusions often explain most of the gap.

How DeployOpen scopes and delivers Keycloak lifecycle automation

DeployOpen plans, implements, hardens, documents and supports self-hosted open-source platforms inside your own cloud accounts, data centers or air-gapped networks. For Keycloak workflows for user onboarding and offboarding, we start from your joiner, leaver and inactivity rules, build them in your Keycloak environment, and hand over the configuration, tests and runbooks your team needs to operate them.

How we scope

  • Map joiner, leaver and inactivity events to the Keycloak realms, groups and roles they affect.
  • Agree which steps are automated, which need human approval, and which remain with your identity governance tool.
  • Confirm the written scope, deliverables and timeline before any work starts, since most engagements are fixed-scope.

How we build

  • Configure event-triggered and scheduled workflow steps for notify and disable actions in a non-production Keycloak first.
  • Test each workflow with representative joiner, leaver and dormant account cases, including failure and rollback paths.
  • Run the build inside your own infrastructure, with access and secrets handled under your controls.

How we hand over

  • Document each workflow, its triggers, its schedule and its effect on sessions and sign-in, in plain operational terms.
  • Deliver a runbook covering how to pause, change or audit workflows and how to recover from a failed step.
  • Walk your administrators through the configuration so your team can operate it without us.

How we support

  • Offer ongoing support, upgrades and continuous testing as a retainer after the initial handover.
  • Review workflow behavior again when you upgrade Keycloak, since workflow features can change between releases.
  • Ask us to scope a separate engagement when requirements move into access reviews, approvals or certification, which need a full identity governance tool.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.