How do you add Keycloak MFA without locking users out?
Keycloak supports OTP authenticator apps, W3C WebAuthn security keys, passkeys with conditional and modal sign-in UI, and recovery codes, so the technology choice is rarely the hard part. The harder work is deciding who must enroll, when, with which factor, and what happens when a user loses the device. An identity team or application owner adding a second factor usually does so under a compliance or security deadline while keeping the existing user base signing in every day. The rollout and recovery design determine whether that deadline is met without a flood of helpdesk tickets. The first complication is that requirements differ per application. A back-office console may need a hardware-backed factor, a customer portal may accept OTP, and a low-risk internal tool may need nothing beyond the current password. In Keycloak these requirements are typically expressed through authentication flows and conditions rather than one realm-wide switch, so the team should inventory each client, its risk level and its required assurance before changing any flow. Write that inventory down, because it becomes the acceptance list for testing. Users also work across several devices. A passkey created on a laptop is not automatically available on a phone or a shared workstation, and a security key may be issued to only some staff. Confirm with your identity team how passkeys synchronize in your environment, which browsers and operating systems your users run, and whether you will allow more than one credential per user. Passkeys are also tied to the relying party domain, so a change of hostname, a new regional URL or a split between public and admin endpoints can strand enrolled credentials. Settle the public hostname before enrollment begins. Helpdesk load is where rollouts most often fail. Every lost phone or reset OTP becomes a ticket, and the people answering it need a verified procedure for re-identifying the user and removing a factor. Decide in advance who may reset a second factor, what evidence is required, whether recovery codes are issued at enrollment and how users store them, and whether a grace period allows sign-in with the old method while enrollment completes. Test these steps with the actual helpdesk staff, not only the engineers. Finally, many logins are federated or brokered. If users sign in through an external OIDC or SAML provider, or a social login, the second factor may already happen at that provider, and Keycloak may be trusting an assertion it cannot re-verify. The server administration guide documents identity brokering, the authentication flow options and the WebAuthn and passkey features. Read those sections alongside the Keycloak release your team runs, because exact behavior, default settings and UI labels can change between releases, and the team should verify each flow in a test realm before production.
Which Keycloak MFA method fits each user group
This table compares OTP authenticator apps, WebAuthn security keys, passkeys and recovery codes by fit, user and helpdesk effort, and operational cost. Read each row as a question to answer for your own user groups, then use the final rows to decide how far to enforce each method. The main takeaway is that no single method suits every group, so most rollouts pair a primary method with a recovery path.
| Decision point | What it fits and what it asks | Operational cost and risk |
|---|---|---|
| OTP authenticator apps | Broad fallback for staff and customers with personal phones. Users install an app, scan a QR code once and type a six-digit code at each sign-in, if the realm's OTP policy allows it. | Low licensing cost. Helpdesk load rises with lost or replaced phones, and enrollment needs clock-accurate devices and clear self-service steps. |
| WebAuthn security keys | Privileged administrators and finance or security roles that need phishing-resistant sign-in and can carry a hardware key. Each key is registered to a user account. | Keys cost money per user and must be replaced or re-registered when lost. Plan a second registered key or a recovery path before enforcement. |
| Passkeys | Users on modern phones, laptops or browsers who want fast sign-in. Passkeys are discoverable credentials that sync through the user's device ecosystem where the platform supports it. | Lowest user friction where supported. Dependence on the platform sync service means a user's account provider becomes part of your recovery plan. Confirm browser and OS coverage for your user base. |
| Recovery codes | A one-time fallback for any user who loses the primary factor. They should be stored offline by the user and issued only after identity is verified through a defined process. | Low tooling cost but a common support path. Weak handling of codes becomes an account takeover route, so set a rule for regenerating and revoking them. |
| Realm-wide policy | Suits a single population with one sign-in standard, such as all employees. Simpler to explain and audit, but it applies the same method and friction to every client in the realm. | Fewer configuration objects to maintain. Changes affect every application at once, so test in a non-production realm before a broad rollout. |
| Per-client or per-role enforcement | Suits mixed estates, such as stricter MFA for an admin console or payment application while a low-risk portal keeps lighter sign-in. Usually implemented through conditional authentication flows. | More flows to design, test and document. Each new rule adds upgrade and support work, so confirm the flow configuration in the target Keycloak release before you commit. |
| Passkeys as a replacement for a password | Possible only where the configuration allows passwordless sign-in for the relevant users. Confirm in the target release how the sign-in flow, required actions and fallback behave for each group. | Removing passwords shifts all recovery to the device or alternate factor. Keep a password or recovery path until helpdesk procedures are tested. |
| Passkeys as an addition to a password | Adds a second factor or a faster sign-in option while the password remains. This is the lower-risk first step for most user groups. | The password stays a dependency, so credential stuffing and password policy work continue. Confirm the step-up behavior in the target release before relying on it for sensitive clients. |
How conditional authentication decides when to ask for a second factor
The main design choice for MFA in Keycloak is whether the second factor applies to every login in a realm or only to the logins that meet a condition. Keycloak runs sign-in as an authentication flow made of executions, and each execution can be set to required, alternative, conditional or disabled. A second-factor step such as OTP or WebAuthn can sit in the browser flow as a conditional sub-flow, so Keycloak evaluates the condition at sign-in and asks for the second factor only when the condition is true. The conditions are the part that decides who gets challenged, so they belong in the design before any flow is built.
A single realm-wide requirement is the simplest option to explain and to audit. One flow, one set of required executions, and every user and client follows the same path. The cost appears during rollout. If the organization needs to phase MFA in by application, team or user population, a realm-wide step forces a choice between a hard cutover and a temporary exception outside the flow, which is harder to track. Conditional steps let you start with a narrow scope, such as one administrative client or one role, and widen it later. The trade-off is that each condition adds a branch, and every branch needs its own test cases and documentation. A flow that looks small on a diagram can produce many more sign-in paths than the team expects.
Before you design the flow, list the condition types available in the Keycloak release you plan to run and write down how each one is evaluated. The server administration guide describes the authenticator conditions that Keycloak provides. Check the exact list against your release, since conditions are added and changed between versions, and confirm the behavior of each condition for brokered and federated users. A user who signs in through an external identity provider or from LDAP or Active Directory may not carry the same role, group or attribute data as a local user, and a condition that depends on that data can evaluate differently for these users. Brokered sign-ins also pass through a first broker login flow, so confirm which flow applies and whether MFA should be enforced there, in the upstream provider, or both.
Write the decision as a table before building anything. For each application, role, group or sign-in context, record whether the second factor is required, which condition selects it, which flow it lives in, and who owns the exception. Then test each row with a local user, a federated user and a brokered user, and with a client that uses the authorization code flow and one that does not. Illustrative example: a team might require WebAuthn for members of an administrators group on the admin client, and OTP as a fallback for everyone else, and find during testing that one group mapping does not reach brokered users. That gap is easier to find in a table than in production logs.
Keep the number of flows small and name them for their purpose so auditors and on-call engineers can read them. Export each flow definition into version control so changes are reviewed like code, and record which conditions depend on directory data that another team controls. The effort for this section grows with the number of conditions, the number of identity sources, and the number of clients that need different treatment. Ask any partner to show the condition matrix, the test cases for each branch, and the change process for adding a new client to the policy before you agree on scope.
How to set up Keycloak MFA step by step
This sequence takes a Keycloak realm from password-only sign-in to a tested second factor that users can enroll in without being locked out. Each step ends with a check you can run before moving on, so problems surface in a pilot before full rollout.
Inventory applications, users, devices and obligations
Before changing anything, list every client application that signs in through the realm, the user populations behind each one (employees, contractors, customers, service accounts), the browsers and devices those users rely on, and the compliance requirements that set the minimum second factor. Record which applications can accept a passkey or WebAuthn key and which need a fallback. The identity lead owns this with each application owner. Check: every application owner has signed off the inventory, and the populations to be excluded or phased first are written down.
Set OTP, WebAuthn and passkey policies
In the realm settings, configure the OTP policy (algorithm, digits and period) and the WebAuthn policies for registration and passwordless use. Then choose how passkeys are offered: as a passwordless sign-in option, as a second factor, or both. Confirm option names and defaults in the server administration guide for the release you run, because labels can change between versions. Check: create a test user, open the account console's signing-in section, and confirm the expected credential types appear under the chosen policy.
Copy the browser flow and add the second factor
Duplicate the built-in browser authentication flow and edit only the copy. Add a second-factor execution after the password step, inside a conditional subflow. Leave the original flow untouched so the realm can be switched back to it immediately if sign-in breaks. Do not bind the new flow to browser authentication until step 4 testing is complete. Check: the copy shows the second-factor step in the intended order, and the original flow is still bound and still allows password-only sign-in for the test account.
Add conditions and test every branch
Set conditions on the second-factor subflow based on the condition types your version offers, such as user role, group, client or network location. Test each branch with a separate account: a user who must complete MFA, a user who is excluded, a user with no enrolled credential, and a user with both OTP and a passkey. Keep a written test matrix. Check: every branch produces its expected result, and the event log entries or screenshots for each test are saved in the change record.
Configure enrollment and recovery codes
Set OTP or WebAuthn registration as a required action for pilot users so they enroll at next sign-in. Enable recovery code issuance in the realm's credential settings if your version supports it. Decide in advance who can reset a credential, what identity checks apply before a reset, and where those requests are logged, because helpdesk resets are a common point of lockout. Check: a test user with no credential is prompted to enroll, receives recovery codes, signs out, and signs in once with a recovery code.
Configure email delivery for email-based steps
If any step sends email, such as a reset or verification message, configure the SMTP server in the realm email settings. The Keycloak 26.8 upgrade notes enforce StartTLS without plaintext fallback, so confirm your mail relay supports StartTLS with a certificate Keycloak trusts before cutover. Check: send a test email from the realm email settings, confirm it is delivered over an encrypted session, and keep the mail server log entry as evidence.
Pilot with test accounts across browsers and devices
Enroll a small group of test accounts and run them through sign-in, enrollment and recovery on the browsers, operating systems and devices your users hold. Include platform authenticators, roaming security keys and phone-based passkeys if your policy supports them. Log failures by browser and device, and fix flow or policy issues before widening the group. Check: every combination in the pilot matrix completes sign-in, enrollment and recovery, and the pilot group and exit criteria are written into the rollout plan.
Confirm hostname and proxy settings before passkey enrollment
Passkeys are bound to the site they were registered on, so confirm the public frontend hostname and reverse proxy configuration before any user enrolls one. Keep public frontend URLs separate from the admin console and Administration REST API hostname or path, confirm TLS terminates where intended, and check that forwarded host and protocol headers match what browsers see. Check: the sign-in page shows the expected hostname in the browser, a passkey registers successfully, and a credential registered in the pilot still authenticates after a proxy restart.
How to roll MFA out to users without locking them out
The safest MFA rollout in Keycloak moves users through stages that each add pressure without removing access. Start with a pilot group, move to a prompted enrollment window where users are asked to register a second factor but can still sign in with a password alone, and enforce the requirement only group by group once support volume is understood. In Keycloak this maps to the Required actions and conditional authentication settings on the browser flow, so you can change who is challenged without rewriting the flow itself. Decide the stages, the group that enters each one, and the exit criteria for each stage before anyone is enrolled. The pilot group should be small, mixed and willing. Include administrators and people who will test the helpdesk procedure, not only technical staff. Use it to confirm the enrollment screens for OTP, WebAuthn security keys and passkeys in the browsers and devices your users actually run, and to check how the conditional UI for passkeys behaves on each. Record every confusing prompt. Pilot findings usually concern wording and device handling, not the protocol, so review them with the people who write user communication as well as the identity team. During the prompted enrollment window, users should see a clear message and a reminder, but not a hard block. This is the point to distribute recovery codes. Recovery codes are only useful if the user has them before losing a device, so require each user to generate and store them at enrollment, and tell them explicitly that a code is single use and must be kept somewhere other than the device it recovers. Confirm with your own policy whether codes are generated during the required action or on demand from the account console, and whether users can regenerate them. Do not enforce MFA for a group until its recovery code rate is at a level your helpdesk can handle. Before switching on enforcement for a group, write the helpdesk procedure for lost or replaced devices. The procedure should verify identity through a channel the attacker cannot easily control, such as a manager confirmation or a callback to a number already on file, and then have an administrator remove the lost credential or issue a new required action. It should never simply disable the OTP requirement for an account, because that creates a silent bypass that outlives the incident. Keep enrolling a new device and recovering an account as separate tickets with separate checks: enrollment adds a credential to a session the user already controls, while recovery reestablishes trust after a credential is lost. Expect support spikes at the start of the enrollment window, after each enforcement date, and after device refresh cycles. Keep the previous flow available until enforcement has run stably for a defined period that you set, and document how to revert a group to the prior browser flow binding. Rollback should change one group's binding, not restart the whole realm. Communicate each phase in advance through the channels users already trust, state what they will see and what to do if they cannot sign in, and link to the helpdesk contact. Confirm your support hours, staffing and escalation path with the people who will run them, since these are the costs that rise sharply if enforcement is switched on too broadly.
What drives the effort of a Keycloak MFA rollout
This table lists the factors that move effort and cost in a Keycloak MFA rollout, how each one changes the work, and how to keep it down. Read it before asking for a quote, because most of the recurring cost comes from the drivers in the lower rows. Keeping one realm-wide policy, a recovery process agreed before enforcement, and one shared test matrix across environments keeps both one-time and ongoing effort lower.
| Driver | Why it changes effort or cost | How to keep it down |
|---|---|---|
| Applications and clients | Each client with its own MFA rule adds flow variants, test cases and token checks. Clients that need step-up for sensitive actions multiply the conditions to verify. | Use one realm-wide browser flow with few conditions. Add step-up only for a short list of high-risk clients, and document each exception. |
| Users and device spread | Users with passkeys, security keys, authenticator apps or none at all need different enrollment help. Mixed device fleets raise helpdesk volume during enforcement. | Survey device types before setting the enrollment order. Start with a group that can enroll passkeys or security keys, and keep OTP as the fallback. |
| Brokered, LDAP and Active Directory sign-in | If MFA already exists in an upstream identity provider or directory, Keycloak may duplicate it or conflict with it. Each identity source needs its own check of which factor was used. | Decide early which system enforces MFA for each sign-in path. Confirm with the directory or upstream provider owner what authentication context they pass to Keycloak. |
| Number of realms | Each realm needs its own flows, required actions, policies, test runs and admin review. Realm count multiplies both build and run effort. | Keep one realm where possible. Use Organizations or client-level settings for differences that do not justify a separate realm. |
| Helpdesk process maturity | Lost devices and failed enrollments drive support tickets. Without a documented recovery process, each case becomes an escalation to the identity team. | Write the recovery process before enforcement, including identity verification steps, recovery code use and when an administrator resets a credential. Train the helpdesk on it. |
| Compliance evidence needs | Assessors may ask for proof of enforcement settings, exception approvals, enrollment records and event logs. Collecting this evidence adds design and documentation work and recurring reporting. | Agree the evidence list with your auditor or compliance lead before build. Confirm which Keycloak events are retained and where they are stored. DeployOpen prepares evidence but does not issue audit opinions. |
| Environments (dev, test, production) | Each environment needs its own realm configuration, test accounts and device matrix. Settings that drift between environments cause failures that appear only in production. | Export realm configuration as code and promote it through environments. Reuse the same MFA test matrix in every environment, covering enrollment, sign-in, recovery and step-up. |
| One-time versus recurring costs | One-time work covers design, flow build, testing, user communication, training and documentation. Recurring work covers helpdesk support, policy review, and release testing after Keycloak upgrades. | Ask a partner quote to separate these two groups. Ask how many release test cycles per year are included, and whether helpdesk support is in scope or billed separately. |
How the MFA design changes by deployment model
A single node is the simplest place to validate passkeys, WebAuthn and OTP, because one hostname, one process and one database connection make origin and session behavior easy to trace. Most early problems trace back to the public address the browser sees, and that address is easier to diagnose here than in a larger topology.
- Public hostname and proxy: WebAuthn and passkeys bind credentials to the relying party ID, which comes from the public hostname. Set the hostname and proxy headers so the browser origin matches what Keycloak expects. Changing the hostname later may make registered passkeys unusable, so confirm this behavior for your version.
- Brute force and login failures: Confirm how failed attempts are counted and whether failure records persist to the database in the version you run.
- OTP and recovery codes: Test enrollment, reset and recovery code use from start to finish before any user group is enrolled.
- Email second factors: If email is a second factor, the node needs outbound access to the mail relay. Confirm the StartTLS behavior for your release.
- In-place upgrades: A single node is often upgraded in place, so rehearse authentication flow changes in a copy of the realm first.
Before go-live, confirm the hostname, proxy headers and brute force settings against your Keycloak version and the reverse proxy you run.
In a clustered design, MFA state must be consistent across nodes. A user can start a login on one node and finish it on another, and lockout counts must reflect failures from every node, not only the one that handled the request. The choice of high availability architecture and database replication determines how much of this behaves without extra work.
- Shared hostname: All nodes behind the load balancer must present the same public hostname and proxy headers. Mismatched values cause passkey and WebAuthn origin failures that appear only on some requests.
- Session and failure persistence: Confirm how user sessions and login failure records are shared across nodes. Login failures are persisted to the database by default in Keycloak 26.8, so lockout counts should be consistent, but verify the behavior in your release and design.
- Database replication: Both supported high availability designs need a synchronously replicated database. Confirm this with your database team before using OTP or passkey lockout thresholds in production.
- Failover during MFA steps: Test a node failure midway through an OTP or passkey challenge, and check whether the user is asked to restart the step.
- Rolling upgrades: Plan node-by-node restarts so that users mid-enrollment are not disrupted. Confirm the behavior of your chosen design during schema migration.
Before go-live, run a failover test with real MFA steps against your availability targets and the high availability design you selected.
When Keycloak runs under the Keycloak Operator, the custom resources define the public hostname, database connection and most runtime settings. MFA changes are therefore partly configuration and partly the operator's upgrade process, so the design has to account for both. The operator documentation strongly recommends manual approval mode for operator updates.
- Hostname in the custom resource: Set the public hostname and proxy settings in the Keycloak resource. Passkey and WebAuthn origin checks depend on these values, so review them after every change to ingress or the load balancer.
- Manual update approval: Use manual approval so that an operator update, which can change authentication flows or defaults, is reviewed in a test realm before it reaches production.
- Flow changes on upgrade: Compare MFA-related flows and required actions in the new release against your realm exports before approving an update. Confirm the behavior for your Keycloak version.
- Database secrets and schema migration: Confirm how database credentials are supplied and whether schema migration runs at startup or is applied manually for your deployment size.
- SMTP and metrics: Store SMTP settings in a managed secret, and enable metrics on the management interface if you alert on login failures.
Before go-live, confirm the operator version, approval mode and hostname settings in a staging cluster that mirrors production ingress.
In an air-gapped or restricted network, Keycloak cannot reach external services, so every MFA dependency must be available inside the boundary. Passkey and WebAuthn still require a stable internal hostname with TLS that browsers trust, and email second factors work only if an internal mail relay is reachable. Plan these dependencies before selecting MFA methods.
- Internal hostname and certificates: Passkeys bind to the hostname the browser uses. Use an internal name with a certificate issued by the organization's trusted certificate authority, and confirm that browsers on managed devices accept it.
- Email second factors: Email OTP depends on a reachable SMTP service. Confirm that an internal relay is available and that its TLS requirements match the Keycloak version you run, or choose OTP or WebAuthn instead.
- Software delivery: Upgrades, container images and operator bundles must come from an internal registry or mirror. Confirm which artifacts your version needs and how they are updated.
- Recovery paths: Without external email or outside help, plan how users recover lost authenticators, such as recovery codes issued during enrollment and a documented administrator reset process.
- Device and browser support: Confirm that the security keys, platform authenticators and browsers used inside the network support the WebAuthn and passkey features you enable.
Before go-live, test every MFA method end to end inside the restricted network, using the internal hostname, the internal mail relay and the artifacts you will actually deploy.
How to harden Keycloak MFA and recovery
Second factors only protect accounts when the surrounding controls hold. The cards below cover transport, admin exposure, lockout behavior, recovery paths, and auditing, which together decide whether an attacker can bypass MFA through a weaker route.
TLS on all communication
Keycloak's production guidance calls for TLS on every connection, including the path between the reverse proxy and Keycloak, not only the browser session. WebAuthn and passkey ceremonies depend on a secure origin, so the public hostname must be served over HTTPS with a valid certificate. Check that SMTP delivery uses StartTLS, which Keycloak 26.8 enforces without plaintext fallback, and confirm database and cache connections are encrypted where your environment supports it.
Separating admin access from public login
Expose the admin console and Administration REST API on a different hostname or context path from public frontend URLs, as the production guide recommends. Pair this with reverse proxy path rules so that only the intended paths reach Keycloak from the internet. Confirm that administrative sign-in is itself protected by MFA and that the admin hostname is reachable only from management networks or approved addresses.
Brute force protection and MFA
Brute force detection locks or delays accounts after repeated failures, which limits password guessing against the first factor. Test how lockout interacts with OTP and WebAuthn prompts so that an attacker cannot exhaust a user's account to force a help desk reset, and so legitimate users are not locked out during an MFA rollout. Tune the thresholds and wait times with the security and service desk teams before go-live.
Recovery code storage and one-time use
Recovery codes are a fallback second factor and must be treated as credentials. Confirm that each code is accepted once, that users are shown codes only at enrollment, and that the generation and regeneration events are recorded. Define how users store codes, how many are issued, and when they are regenerated, and test that a used code cannot be replayed.
Protecting the recovery email channel
If a user can reset a second factor through email, an attacker who controls the mailbox controls the account. Require the mailbox to be protected by its own MFA, restrict which email domains can be used for recovery, and verify that SMTP settings and sending identities are managed by administrators only. Confirm that changes to a user's email address also trigger a notification to the previous address.
Limiting who can remove second factors
Removing a user's OTP device, security key or passkey should be a privileged action with a defined approval step. Review which admin roles and realm management permissions can delete credentials, and confirm that self-service removal requires a fresh strong authentication. Document the help desk procedure for identity verification before any reset, since the removal path is often the weakest point in an MFA design.
Auditing enrollment, failures and removals
Enable event logging for second-factor enrollment, failed OTP and WebAuthn attempts, and credential removal, then forward those events to your monitoring or SIEM platform. Login failures are persisted to the database by default in Keycloak 26.8, so confirm how long that data is retained, who can query it, and how it is purged. Define alert thresholds for spikes in failed second-factor attempts and for credential removals outside normal support hours.
How to test that Keycloak MFA works and fails safely
Test the MFA design before any user is asked to enroll, and treat the failure paths as first-class test cases. The goal is a written matrix that shows every authentication method works in every browser and device class your users actually use, and that a user who cannot finish MFA is routed to the documented recovery path rather than left at a dead end. Build the matrix in a non-production realm that mirrors the production authentication flow, client settings and required actions, so results carry over to the live configuration. On one axis, list each method you intend to offer: OTP through an authenticator app, a WebAuthn security key, a passkey, and a recovery code. On the other axis, list the browser and device combinations your user base uses, including the platform passkey providers on mobile devices and the conditional and modal passkey UI in each browser. Add rows for each conditional branch in the browser flow, such as the rule that prompts for a second factor only for certain clients, roles, groups or networks. Then add rows for brokered and federated users, because an identity provider that already performed MFA upstream may or may not be expected to satisfy the Keycloak condition. Confirm with your identity team which of these outcomes is intended before you write expected results. Next, test the edge cases that generate support tickets. Use an expired OTP code, a code entered twice, a security key removed mid-flow, and a passkey enrolled on one device but used on another. For each, record the exact message the user sees and whether the session can retry. Simulate lost-device recovery by removing the user's second factor through the admin console, then confirm the user can enroll a replacement through the recovery path you documented, and that recovery codes are single-use. Verify that an administrator removal of a credential takes effect at the next login, not only in a new session created later, and check the audit events that record the change. The fail-safe checks matter most. Make the MFA step fail deliberately for a test user who has no usable factor and confirm the flow lands on the documented recovery page with a clear next step. Then disable the required-MFA condition, or roll the authentication flow back to the previous binding, and confirm no account is stranded: users with only a passkey should still sign in, and nobody should be locked out because a required action was left pending. Record the rollback steps and time them, since they are the procedure you will use under pressure. Repeat the full matrix after every Keycloak upgrade and before each enforcement phase, not only at initial launch. Upgrade notes and minor-release changes can alter authentication behavior, and a rollout that passed in one release may need retesting in the next. Keep the results in a versioned sheet, record the Keycloak version and realm export used, and ask your implementation partner or internal team to confirm the expected outcome for each row before the test cycle starts.
What to monitor, document and maintain after MFA goes live
Turning on MFA is the start of the work, not the end. The controls below show what your team watches, what it records and how it keeps authentication behavior predictable across Keycloak releases and user changes.
Monitor login and second-factor failures
Enable metrics with the metrics-enabled option so Keycloak exposes Prometheus-format data at /metrics on its management interface. Scrape that endpoint from your monitoring system and confirm the management port is reachable only from the monitoring network, not from public frontend hostnames. Track failed password and second-factor attempts separately so a rise in OTP or WebAuthn failures stands out from ordinary password typos.
Alert on rollout and attack spikes
Set alerts on sudden changes in failure rates per realm or per client, not only on absolute counts. A spike that begins right after a flow change or a campaign to enroll users usually points to a rollout problem, such as a misconfigured required action or a browser that cannot complete WebAuthn. A spike spread across many accounts with few successes may indicate credential stuffing and should route to the security team. Agree on thresholds during testing, then tune them after the first weeks of real traffic.
Review upgrade notes before each update
The Keycloak project plans four minor releases a year, and breaking changes in minor releases are opt-in. Even so, authentication behavior can change through new defaults or enforced settings, so read the release notes for each planned version before you schedule an update. The 26.8 upgrade notes, for example, list changes to login failure persistence and SMTP StartTLS that can affect MFA-related email and audit data. Record the review decision in your change ticket.
Version-control flow and condition definitions
Document each browser flow, required action and conditional rule that decides when a second factor is requested, including which roles, groups or client settings trigger it. Keep this documentation and exported realm definitions in a version-controlled repository with review on every change. When an auditor, an incident responder or a new administrator asks why a user was prompted, the answer should come from a dated record rather than from memory of the console.
Back up the realm configuration
Schedule regular exports of the realm configuration, including authentication flows, OTP policies, WebAuthn policies and client definitions, and store them outside the Keycloak cluster. Remember that a realm export does not replace a database backup, since user credentials, registered authenticators and recovery codes live in the database. Test a restore into a non-production environment at least after each major change, and confirm that the restored realm still enforces the intended MFA conditions.
Audit enrollment and recovery actions
Log who registers, removes or resets a second factor, and when recovery codes are issued or used. Keycloak's event records can capture these actions, so confirm that event storage and retention meet your policy before go-live. Review enrollment changes on a schedule and compare them with approved helpdesk tickets, since an unexpected new passkey on a privileged account is one of the more serious signals MFA can produce.
Maintain the helpdesk runbook
Write a runbook that tells support staff how to verify identity before resetting an authenticator, which recovery options to offer, when to escalate, and how to record each action. Include steps for a user who lost a security key, a user whose phone changed, and a locked account caused by repeated failures. Revisit the runbook after every flow change, because a procedure that assumed OTP may not match a passkey-first sign-in.
Questions teams ask before they add Keycloak MFA
How much does a Keycloak MFA project cost?
Scope drives the cost more than the MFA features do. Most of the one-time cost is people time: discovery, design of the authentication flows and recovery policy, configuration of realms and clients, a test matrix, rollout communications and helpdesk runbooks. Recurring costs include the infrastructure that runs Keycloak, the database and monitoring, any Red Hat build of Keycloak subscription if you choose that distribution, and optional support or upgrade retainers. Ask for a quote that lists each item separately, states what is one-time and what recurs, and names the assumptions about client count, user count and environments.
How long does a Keycloak MFA rollout take?
The duration is set by the number of clients, the size and make-up of the user population, and the number of rollout phases. A single realm with a few clients and a pilot group moves faster than several realms with mixed applications and external directories. Phases usually run from a pilot group, to a staged expansion, to enforcement for all users, and each phase waits for helpdesk readiness and clean error data. Ask any partner to tie the timeline to a written scope with named phases and exit criteria, and confirm which dates depend on your change calendar and access approvals.
What must our internal team provide for Keycloak MFA?
Your team supplies the decisions and access that no outside party can make for you. Identity administrators own realm settings, authentication flows and the OTP, WebAuthn and passkey policies. Application owners confirm which clients must enforce MFA and test their sign-in paths. Helpdesk leads write the reset and lost-device procedures and staff the pilot. A test group of real users must sign in during each phase, and a named approver must sign off the recovery policy before enforcement starts. Plan time for these people now, because delays in sign-off usually extend the schedule more than technical work does.
Can our own team add Keycloak MFA without a partner?
Yes, for a single realm with a small set of clients, your team can usually do the work alone if it already runs Keycloak and understands its authentication flows. The main load is not the configuration itself. It is the test matrix covering browsers, devices, authenticator types and each client, plus a rollout plan with rollback steps and helpdesk procedures. Teams that lack recent Keycloak administration experience, or that must migrate existing users, often bring in outside help for those parts. Check your skills against the test matrix before you commit to a date.
Do passkeys replace passwords in Keycloak?
Keycloak documents passkeys alongside W3C WebAuthn, with conditional and modal sign-in interfaces, but whether passkeys can fully replace passwords in your setup depends on the release you target and on your flow design. Confirm in the Keycloak server administration guide for that release how passkeys are registered, whether password removal can be enforced for specific users or clients, and how recovery works when a device is lost. Test each path with a pilot group before you remove the password requirement from any client.
What changes in Keycloak MFA after an upgrade?
Keycloak ships minor releases four times a year, and breaking changes in a minor release are opt-in, but each upgrade still needs a review of its notes. Read the upgrade notes for the target version, such as the Keycloak 26.8 notes, which cover items like SMTP StartTLS enforcement and persisted login failures. Retest OTP policies, WebAuthn settings, passkey flows and recovery paths in a staging realm with your test group. Confirm how database schema migration will run, automatic at startup or applied manually, and schedule the upgrade with a rollback plan.
How do we request a fixed-scope Keycloak MFA quote from a partner?
Send a written scope before asking for a price. Include the realms and clients in scope, the authentication methods to enable (OTP, WebAuthn security keys, passkeys, recovery codes), the user count and any directory integration, the environments, the recovery policy you need approved, the rollout phases, and what support you expect after go-live. Ask the partner to restate the deliverables, acceptance criteria and timeline in writing before work starts. Fixed-scope engagements from DeployOpen are agreed this way, and any change to the scope should be re-quoted in writing.
How DeployOpen scopes, builds and hands over Keycloak MFA
DeployOpen plans, implements, documents and supports self-hosted Keycloak inside your own infrastructure, including OTP, WebAuthn security keys, passkeys and recovery codes. Each engagement starts from a written, fixed scope that names the users, applications, authentication flows and rollout waves covered, so you know what is delivered before work begins.
How we scope
- Inventory which applications, realms and user groups need OTP, WebAuthn or passkeys, and which stay on password only
- Agree in writing which authentication flows change, including conditional rules by role, network or client
- Confirm the target enrollment, recovery and helpdesk model so users are not locked out during rollout
How we build
- Configure OTP policies, W3C WebAuthn settings and passkey conditional and modal sign-in in a non-production realm first
- Set up recovery code generation and enrollment flows, then test each path with pilot users and the helpdesk runbook
- Run negative tests for lost devices, expired codes, failed attempts and fallback to recovery codes before production
How we hand over
- Document each authentication flow, required actions, policy settings and the reasons behind them in a written runbook
- Provide the exported realm configuration and a rollout checklist covering communications, waves and rollback steps
- Walk your identity and helpdesk teams through enrollment support, recovery code handling and escalation paths
How we support
- Offer ongoing support, upgrades and testing of MFA flows as a retainer, scoped separately from the initial build
- Review Keycloak upgrade notes that touch authentication behavior before each minor release reaches production
- Confirm with your team which login failure and MFA events are monitored after go-live and who responds to them

