Keycloak brute force detection and password policies

Keycloak lets administrators set lockout behavior for repeated failed logins and enforce password rules at the realm level. This page explains how to choose between temporary and permanent lockout, configure password policies, and confirm the hashing defaults in your own environment.

On this page

Keycloak brute force detection and password policies: what they do and when you need them

An organization sign-in page that is exposed to the internet or to many users needs controls against password guessing and weak passwords. In Keycloak, brute force detection locks accounts after repeated failed logins, and password policies set the rules a new password must meet. Both are configured per realm, so a realm used for workforce sign-in and a realm used for customers can carry different settings. This section sets the scope for the rest of the page: the four areas covered are lockout modes, password history, expiry and blacklists, and the hashing defaults for stored passwords. The page addresses configuration decisions and checks you can run on your own instance. It does not promise protection against a determined attacker, because lockout and password rules reduce specific risks and do not replace MFA, monitoring or patching.

The first decision is whether you need brute force detection at all, and in what form. Any realm where users sign in with a password and where anonymous attempts can reach the login form benefits from it. The choice you make is between temporary lockout, where an account is blocked for a period and then recovers, and permanent lockout, where an administrator or a user recovery step must re-enable it. Temporary lockout is easier on help desks but can be abused to lock out a named user, so consider how your support team will respond to a flood of lockouts. Permanent lockout suits high-assurance workforce realms but raises the cost of every false positive. Confirm the exact settings and their defaults for your Keycloak version in the server administration documentation before you change anything in production.

Password policies carry their own trade-offs. Password history stops users from cycling back to recent passwords, expiry forces periodic change, and blacklists reject known weak values. Each rule adds friction, and expiry in particular is now debated by many security teams, so decide with your compliance owner which controls your frameworks actually test. Hashing is the last area. Keycloak's current defaults use Argon2, with PBKDF2 available as an alternative, and changing the algorithm affects how existing passwords are rehashed at next login. Before you go live, test sign-in with a sample of accounts, confirm that lockout events are logged for your monitoring, and check that your admin recovery path works when a legitimate administrator is locked out.

Brute force and password policy options and when each fits

This table compares the Keycloak lockout modes and password policy rules, showing what each controls, the user experience it creates and which team should own the decision. Read it as a starting point for a policy workshop, then confirm exact option names and default values in the server administration guide for your Keycloak version before you configure anything.

OptionWhat it controlsUser experience it createsTeam that owns the decision
Temporary lockoutBlocks further sign-in attempts for an account for a set wait period after repeated failures, then lets it recover automaticallyUsers wait and retry, which suits most workforce logins but can frustrate users who mistype oftenIdentity team with input from the service desk on expected support volume
Permanent lockoutDisables the account after repeated failures until an administrator re-enables itUsers must contact support to recover, which raises helpdesk load and can be abused for denial of serviceSecurity team with the identity team, and a documented unlock procedure owned by IT operations
Failure thresholds and wait timingNumber of failed attempts allowed and how long the lockout or wait lasts, set per realmToo tight creates frequent lockouts; too loose weakens protection against guessingSecurity team, validated against the organization's risk appetite and access policy
Login failure persistenceWhether failed logins are stored in the database so lockout state survives restarts and clustered nodesInvisible to users, but determines whether lockout behaves consistently across the clusterPlatform team, confirmed against the Keycloak 26.8 upgrade notes for the default behavior
Password historyPrevents reuse of a set number of previous passwords for the same userUsers must choose new passwords on each change, which can drive more reset requestsSecurity team, aligned to the password standard the organization already follows
Password expiryForces a password change after a set number of daysRegular forced changes; many teams now weigh this against the risk of predictable password patternsSecurity and compliance leads, documented in the access control standard
Blacklists and complexity rulesRejects passwords on a blocked list or missing required character classes and lengthImmediate feedback at change time; overly rigid rules push users toward predictable patternsSecurity team, with the service desk consulted on the messages users will see
Hashing algorithm and iterationsSets the algorithm (Argon2 or PBKDF2 defaults) and work factor used to store passwordsInvisible to users; higher work factors increase login server CPU use and need load testingPlatform team, sized with the high availability design and confirmed against the current hashing defaults

A login attempt meets the lockout check before the password is trusted

The flow starts when a user submits a username and password to the Keycloak login page. Brute force detection first looks up the failure state for that user and the source IP address, so a locked account or blocked address is refused before the password is evaluated. If the failure count has reached the configured threshold, the account stays locked for a temporary wait or until an administrator acts. When the password is correct and a new password is being set or changed, the password policy checks such as history, expiry and blacklist apply. Treat this as a simplified model and confirm the exact order and fields against the Keycloak release you run.

Simplified model of the lockout and password checks during a Keycloak login.

How to configure brute force detection in a Keycloak realm

This sequence takes a Keycloak realm from scoping a test realm through enabling brute force protection, choosing a lockout mode, setting password rules, and confirming that lockout and unlock behave as intended before anything reaches production.

  1. Scope the realm and create a test realm

    Decide which realm will carry brute force protection and password rules, and confirm whether those settings apply to all users in that realm or only to a subset your team manages. Create a separate test realm with a non-production user and a test client so every change can be exercised before it touches real accounts. Record which applications sign in against the realm, because lockout will affect them as well as the admin console. The step is done when the scope is written down, the test realm exists, and a test user can sign in to it.

  2. Enable brute force protection in security defenses

    In the Admin Console, open the realm settings, go to the Security defenses tab, and open the Brute force detection section. Turn on brute force protection for the test realm only. Leave the lockout mode at its default until you have chosen the mode in the next step. The check is that the setting persists after a save and that the Admin Console shows the protection as enabled for that realm.

  3. Choose the lockout mode and thresholds

    Select temporary or permanent lockout based on your support model. Temporary lockout blocks sign-in for a period and then lifts automatically, while permanent lockout requires an administrator to unlock the account. Set the failure threshold and the wait settings in the Admin Console, and write down the values so they can be reviewed later. Confirm with your security and service desk teams how they expect to receive unlock requests before you choose permanent lockout. The step is complete when the chosen mode and values are saved in the test realm.

  4. Configure password policy rules

    Open the Authentication section, go to the Policies tab, and set the password policy rules your organization requires, such as length, character classes, password history, expiry, and blacklisted values. Check each rule against your written standard, because the rules you enable must match what your auditors and users expect. Apply the policy to the test realm and then set a password for the test user that should fail each rule. The check is that every rule rejects a non-compliant password and accepts a compliant one.

  5. Reproduce failed logins against a test account

    Using the test user, attempt sign-in with a wrong password until the failure threshold is reached. Confirm that the next attempt is rejected even with the correct password, and that the error the user sees does not reveal whether the account exists. Check that the lockout lasts as long as the mode you chose and then lifts, or remains in place if you chose permanent lockout. The check is a recorded sequence of failed attempts followed by a locked state, observed from the sign-in page.

  6. Verify administrator unlock and event records

    As an administrator, open the locked test user in the Admin Console and clear the lockout. Confirm the user can sign in again with the correct password. Then review the login failure records and the admin activity for the test realm. Note that in the Keycloak 26.8 upgrade notes, login failures are persisted to the database by default, so confirm with your database owner how much additional storage this adds at your expected login failure volume before enabling the setting in production. The step is complete when unlock works, the records appear as expected, and the sizing question has an owner.

  7. Review settings before production rollout

    Compare the test realm settings against the written scope from the first step and the password standard your organization uses. Confirm with the team that operates the application sign-in flows whether any legitimate client, service account, or integration will be affected by lockout, and document how those cases are handled. Repeat the same settings in the production realm through your normal change process, then repeat the lockout and unlock checks on a controlled test account. The step is done when the production change is approved and the verification results are filed with it.

How password history, expiry and blacklists change user behavior

Password history, expiry and blacklists each shift user behavior in a different way, and each one lands on the help desk and on audit evidence differently. History stops users from cycling back to recent passwords, which blocks the common habit of alternating between two or three values. The cost is that users who must change a password they have just set often feel stuck, and they call support or write down the next value. Before you enable history depth in the realm password policy, confirm the depth with your security owner, decide whether the value applies to admin accounts too, and record the setting so an auditor can see that the control is configured rather than assumed.

Expiry forces a change on a schedule, which generates predictable support traffic: locked-out sessions, users who miss the reminder, and service accounts or shared logins that break when the password changes. Expiry also has a documented weakness. When people are required to change passwords on a fixed cycle, they often make small, predictable edits such as incrementing a number or swapping a season, which attackers test first. Many security teams now prefer to rely on lockout and blacklist controls and to reserve forced change for evidence of compromise. If you keep expiry for policy reasons, plan the reminder and self-service change path before the first deadline, and ask your compliance lead which framework requires it.

Blacklists block values that are already known to be weak, such as the organization name, common seasonal patterns and words from breach corpora. They usually create less friction than strict composition rules because users see a clear reason for the rejection and can choose another value. The trade-off is maintenance: someone must decide which lists are loaded, how often they are refreshed and who approves exceptions. Test the policy with a pilot group and read the rejection messages, because unclear errors drive the same help desk tickets that history and expiry create. Keep a short written record of the rules, the test results and the change owner, since that record is the evidence most reviewers ask for.

Security and operational risks to plan for in lockout and password settings

Lockout and password rules sit on the public login path, so they affect availability, storage security and audit evidence at the same time. The cards below cover the risks a team should decide on before turning these settings on in production, and the checks to run after each upgrade.

Lockout as a denial-of-service path

Brute force protection locks accounts after repeated failures, and an attacker who knows a username can trigger that lock on purpose. A permanent lockout mode lets one script disable real staff accounts. Decide which users can be locked out by whom, how long a temporary lock lasts, and who clears permanent locks. Test the help desk path before go-live, because a locked executive account is an outage for that person.

Keycloak server admin docs

Admin console and admin API exposure

The production guide asks you to expose the admin console and Administration REST API on a different hostname or context path from public frontend URLs. Lockout settings protect the login form only, so an exposed admin login is a separate target. Confirm that the reverse proxy blocks admin paths from the internet, that administrator accounts use strong sign-in with their own lockout rules, and that admin access is limited to managed networks.

Production configuration guide

Hashing changes and stored passwords

Keycloak's password hashing defaults are Argon2 and PBKDF2, and the hash algorithm and work factor are stored with each credential. Changing the policy does not rehash existing passwords at once. Users keep old hashes until they next sign in, or until a rehash process runs. Record the current hash settings, plan a test of sign-in for existing users after any change, and confirm the FIPS mode constraints if you run regulated workloads.

Auditing failed logins

Lockout only helps if you can see it happening. Keycloak 26.8 persists login failures to the database by default, and the metrics endpoint at /metrics is available on the management interface when --metrics-enabled=true is set. Decide where failed-login counts and lockout events go, who reviews them, and how long they are kept. Confirm that the management interface is reachable only by monitoring systems, not by public clients.

Metrics configuration guide

TLS and reverse proxy for login traffic

Passwords travel in every login request, so the production guide calls for TLS on all communication. Check that the reverse proxy terminates TLS with current settings, that it passes the original client address so lockout counts apply to the right source, and that proxy path restrictions match the admin and public split. Misconfigured proxies can make all users appear to come from one address, which either hides attacks or locks out everyone at once.

Production configuration guide

Retesting lockout after minor upgrades

Keycloak plans four minor releases a year, and since Keycloak 26.0 breaking changes in a minor release are opt-in. Even so, login failure handling and security defaults change between releases, and the 26.8 notes changed how login failures are stored. After each upgrade, run a scripted test of temporary lockout, permanent lockout, password policy checks and the admin login path in a staging realm before you promote the change.

Release update policy

Choosing temporary or permanent lockout by user population

Employees usually have a known identity record, a help desk and a manager who can confirm a lockout was legitimate. Temporary lockout is the common starting point for this group because the account recovers when the wait ends, and the help desk handles the cases that need a person. Permanent lockout across the whole workforce generates ticket volume and can block staff during an attack.

  • Mode: Temporary lockout with a failure threshold and growing wait times, so routine password mistakes clear quickly and sustained guessing is slowed.
  • Recovery path: Users wait out the timer. The help desk can clear a lockout early through the Admin Console after a verified request. Confirm the exact path in your Keycloak version.
  • Support process: Require an agreed identity check before any early reset, and record whether the lockout followed a password change, a device problem or a suspicious sign-in pattern. Keycloak 26.8 persists login failures to the database by default, which gives the help desk recent failure history to review.
  • Settings that differ: Consider stricter thresholds and alerting for finance, HR and other groups with access to sensitive systems.

Confirm with security and the service desk the threshold, maximum wait, identity check for early resets and the alert conditions for repeated lockouts.

Limits to confirm before you rely on these controls

Keycloak's lockout and password controls behave differently depending on the release, the user source and the authentication methods in your realm. The cards below list the limits to confirm in the server administration guide and in your own testing before you treat these settings as a control.

Lockout scope per user and per IP

Confirm exactly how each lockout mode behaves in the release you run, including whether a temporary lockout counts failures per user, per client address or both. Test a lockout from one address against a legitimate user on another address, and check whether an attacker spreading attempts across many accounts triggers any protection. Record the result, because the answer determines whether lockout alone limits password guessing.

Server admin guide

Password policy for federated users

Password policies in Keycloak apply to passwords stored locally. Users federated from LDAP or Active Directory, or who sign in through a brokered identity provider, may have passwords managed upstream, so local rules such as history, expiry or blacklists may not reach them. Confirm which users in your realm fall under local policy and which do not, and document the upstream rules that cover the rest.

Hashing algorithm and iteration settings

Confirm which password hashing algorithm and iteration or memory settings your deployed version uses by default, and whether existing hashes are rehashed when a user next signs in. Check the values against your own security baseline and your reviewers' expectations. Do not assume the defaults named in the documentation match the build you installed without reading the configuration in that build.

Interaction with MFA and passkeys

Test whether failed one-time password attempts, recovery code entries and failed passkey ceremonies count toward brute force detection in your realm's authentication flow. A flow that skips the password step, such as a passkey-only sign-in, may bypass password-based lockout entirely. Map each sign-in path your users take and test lockout on every one of them.

Lockout events in your SIEM

Confirm which lockout and failed-login events Keycloak records, where they are stored, and how long they are kept. Check whether your SIEM receives them through the event listener configuration, and whether the event carries the user, the address and the lockout state your detection rules need. Test an alert end to end before relying on it for incident response.

Questions buyers ask about Keycloak brute force and password policy work

What does Keycloak brute force and password policy work cost?

No price is published here, and the cost depends on the written scope. The main cost components are the configuration and documentation of lockout and password rules, the policy decisions your organization must make first, testing against your user flows, and any follow-up support. Effort rises with the number of realms, the number of client applications that sign users in, whether users arrive through federation from LDAP or Active Directory, whether MFA is in the login path, and how much testing you need before a change reaches production. Configuration is usually a one-time effort, while review after each upgrade and policy changes recur. Ask for a quote that lists each realm, each federated source, the test scope and the handover items, so you can compare it with the internal hours your team would spend.

How long does configuring and testing Keycloak lockout and password rules take?

Duration depends on how many decisions are still open when the work starts, and no fixed timeline applies to every environment. The longest phase is usually agreeing on policy: how many failed attempts trigger a lockout, whether lockout is temporary or permanent, how long a temporary lockout lasts, which password history, expiry and blocklist rules apply, and how help desk staff unlock accounts. Testing takes time because each login path, federated user and client application should be checked for the lockout and password messages users will see. A written scope should state the realms in scope, the test environment and the acceptance criteria, which is where the timeline comes from.

What must our organization provide before the work starts?

Your organization provides the decisions, access and people that the configuration depends on. The main items are the password and lockout policy your security and risk owners approve, a list of realms and clients that will receive the policy, and a named owner for exceptions. You also need admin access to the Keycloak environment, a non-production environment that resembles production, and a test set of accounts covering local users and any federated directories. Support runbooks are important: the help desk needs steps to unlock accounts, reset passwords and recognize lockout events, and it should know who approves permanent lockout releases. Confirm these items in the written scope so that gaps are found before testing begins.

Can our internal team configure brute force detection and password policies alone?

An experienced internal Keycloak team can configure these settings alone, provided it has time, a test environment and agreed policy. The settings are available in the admin console and the server administration guide, so the difficulty lies in the surrounding decisions: picking lockout thresholds that do not lock out legitimate users behind shared NAT addresses, aligning password rules with existing directory policy, and confirming that federated and social login paths behave as expected. Teams without prior Keycloak experience often benefit from an outside review of the design and test plan. Whichever route you choose, record the settings as configuration you can review and reproduce, not only as clicks in the console.

Does DeployOpen prepare evidence for an auditor, and does it issue audit reports?

DeployOpen prepares systems, controls and evidence for compliance assessments, including records that show how lockout and password rules were configured, tested and approved. DeployOpen does not issue audit reports, attestations or certifications. Independent auditors and certification bodies perform those assessments and decide whether your controls meet a given framework. Evidence typically includes the configured values, the approved policy, test results, change records and the support runbook. Ask your auditor which evidence format they expect before the work starts, and agree in the written scope which items DeployOpen will prepare.

What changes when Keycloak moves to a new release?

Lockout and password settings can behave differently after an upgrade, so each release needs a short regression check. The Keycloak project plans four minor releases a year and a major release every two to three years, and it says breaking changes in a minor release will be opt-in. Release notes can change defaults, such as how login failures are stored, so read the upgrade notes for the target version before the upgrade. Test lockout thresholds, password history checks, expiry prompts and federated login again in a non-production environment. Plan the upgrade with the schema migration method and rolling update approach in mind, because they determine how the environment is changed while users are signing in.

How do temporary and permanent lockout modes differ in Keycloak, and what should engineers check?

Temporary lockout blocks sign-in for a set period after repeated failures, while permanent lockout keeps the account blocked until an administrator unlocks it. Temporary lockout reduces help desk load but can still slow an attacker, so it often suits general user populations. Permanent lockout is stronger against sustained guessing but creates unlock work and can be abused to deny service to a named user. Engineers should check the failure counter window, the wait duration, whether the lockout applies per user or also per IP address, how service accounts and automated clients are excluded, and whether the events appear in the admin event log. Confirm each setting against the version in use, because the admin console labels and defaults can change between releases.

How DeployOpen scopes and delivers Keycloak lockout and password policy work

DeployOpen plans, configures, tests and documents Keycloak brute force detection and password policies inside the client's own infrastructure, as part of a self-hosted Keycloak deployment. Work is agreed in a written, fixed scope before it starts, and the handover package lets the client's security and identity teams review and operate the settings themselves.

How we scope

  • Confirm which realms, clients and user populations the lockout and password rules must cover, including administrator and service accounts.
  • Record the required lockout mode, failure thresholds and unlock behavior in the written scope before any change is made.
  • Agree which password rules apply, such as history, expiry and blacklist checks, and which hashing settings your policy requires.

How we build

  • Configure temporary or permanent lockout in a non-production realm first, then verify each setting against the intended user journeys.
  • Set password policy rules and hashing parameters through the admin console or configuration as code, recording every value and its reason.
  • Test lockout and password rules against identity sources, federated users and any brokered providers so that behavior matches the written design.

How we hand over

  • Deliver a settings register listing each lockout, password and hashing value, its location and its owner.
  • Provide runbooks for unlocking accounts, handling a suspected credential attack and changing the password policy safely.
  • Walk your administrators through the configuration and the test evidence so that your team can operate and review it independently.

How we support

  • Engagements are fixed-scope, and ongoing support, upgrades and continuous testing are available as a retainer.
  • Re-check lockout and password settings after each Keycloak upgrade, since release notes can change defaults and migration behavior.
  • Retest policy changes when your requirements, identity sources or authentication flows change, under the retainer or a new written scope.

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.