14.12.2 14.12.1 14.12.0 14.11.0 14.10.0 14.9.0 14.8.0 14.7 14.6 14.5 14.4 14.3
14.12.2 14.12.1 14.12.0 14.11.0 14.10.0 14.9.0 14.8.0 14.7 14.6 14.5 14.4 14.3

Login account lockout (Keycloak Brute Force Detection)

Lock a VRS Keycloak user after too many wrong passwords, show a clear message in the VRS UI, and unlock the user in Keycloak when needed.

Configure Brute Force Detection on the Keycloak realm your environment uses for VRS login. Lock duration and failure count are controlled in Keycloak, not by a VRS environment variable.

The Keycloak Admin console layout can look slightly different by install. Follow the same setting names below.

What Users See in VRS

Case

Snackbar text

Wrong password (account not locked yet)

Invalid username and/or password

Account locked by Brute Force Detection

Account is locked. Try again later.

Successful login

Login Successful

The UI does not show remaining attempts or a countdown. After the Keycloak wait time (or after an admin unlock), the user can try again.

Prerequisites

  • VRS apis and front-end are deployed and reachable.

  • You can open Keycloak Admin for the realm used by VRS login (for example VRS or Expertflow; use whatever your site uses).

  • The confidential client service account VRS uses can call Keycloak Admin APIs for users and attack detection. Assign at least realm-management roles view-users and query-users (see below). Without those roles, locked users may still see only the invalid-password message.

Service Account Roles (Required for Locked Snackbar)

VRS must call Keycloak Admin as the confidential client service account. Without the right roles, the lock check returns 403, APIs fail open, and the UI only ever shows Invalid username and/or password even when Keycloak shows the user locked.

  1. Open Clients → select the confidential client VRS uses for login (for example vrs or cim).

  2. Open Service accounts roles → Assign role.

  3. Filter by realm-management and assign view-users and query-users.

If Brute Force Detection locks the user but the service account is missing those roles, Admin APIs return 403 and VRS always returns the invalid-password snackbar. Assign the roles, then retest.

1. Open Realm Settings

  1. Log in to the Keycloak Admin console for your environment.

  2. Select the realm used for VRS login.

  3. In the left menu under Configure, open Realm settings.

You land on the General tab. Next open Security defenses:

Keycloak Realm settings General tab
Realm settings — General. Open Security defenses next.

2. Enable Brute Force Detection

  1. Open the Security defenses tab.

  2. Open the Brute force detection sub-tab.

  3. Configure the settings as shown below, then Save.

Setting

Value

Notes

Enabled

On

Turns on lockout. Must be On for any of the other settings to apply.

Max login failures

5

Number of wrong passwords before a temporary lock.

Permanent lockout

Off

Keep Off so the lock can clear after Max wait (temporary lock, not a permanent BFD lockout policy).

Wait increment

10 Minutes

Initial lock wait duration.

Max wait

10 Minutes

Cap on lock wait. Set equal to Wait increment for a simple fixed wait.

Failure reset time

12 Hours

How long failure history is remembered.

Quick login check milliseconds

0

Use 0 to avoid odd early locks.

Minimum quick login wait

empty

Leave empty (or 0) when Quick login check is 0.

Configured Brute force detection:

Keycloak Brute force detection enabled On Max login failures 5 Wait 10 minutes
Security defenses → Brute force detection (5 failures, 10-minute wait, Permanent lockout Off).

Important: Lock duration and failure count are controlled only in Keycloak. Changing these values changes lock behavior for all realm users. There is no separate VRS config.env lock timer.

3. What a Temporary Lock Looks Like

After the user exceeds Max login failures, Keycloak locks the account. You typically need to clear both Temporarily locked and Disabled / Enabled before login works again.

Users List

While locked, the Users list may show a Temporarily locked Status badge (depending on your Keycloak Admin UI). If there is no badge, open the user Details to confirm the lock.

Users list showing Temporarily locked status badge
Users list — Status may show Temporarily locked while BFD-locked.

User Details

Open the user (Details). Confirm both:

  • Temporarily locked is On.

  • The account is not Enabled (Disabled / Enabled Off). Placement of the Enabled control can differ by Keycloak Admin UI; look for Enabled / Disabled on the user Details page.

User details Temporarily locked On while account disabled
User details after lock: Temporarily locked On; account not Enabled.

4. Admin unlock (temporary lock)

To unlock immediately without waiting for Max wait, clear both controls:

  1. Open Users → select the user.

  2. On Details, set Temporarily locked to Off.

  3. Set the account to Enabled (On).

  4. Click Save.

After a full unlock, Temporarily locked is Off and Enabled is On:

User details Temporarily locked Off and Enabled On after unlock
After unlock: Temporarily locked Off, Enabled On.

The user can log in again with the correct password (subject to any other Keycloak rules).

5. If You Only Clear Temporarily Locked

When the account is locked, Keycloak uses two controls. You must fix both for login to work again.

Control

After a lock

What you must do

Temporarily locked

On

Set to Off and Save, or wait for Max wait.

Disabled / Enabled

Enabled Off (account Disabled)

Set Enabled to On and Save.

If you only turn Temporarily locked Off and leave the account Disabled, the user still cannot log in. The Users list may then show Disabled. Always finish unlock with Enabled On.

Users list showing Disabled status badge after clearing only temporarily locked
Users list — Disabled after clearing only Temporarily locked. Turn Enabled On to restore login.

4. Admin Unlock (Temporary Lock)

  1. Valid login → Login Successful.

  2. Wrong password under the max → Invalid username and/or password.

  3. Fail until Max login failures (for example, 5) → Account is locked. Try again later.. In Keycloak, open user Details and confirm Temporarily locked On (and that the account is not Enabled).

  4. Wait Max wait or admin unlock (Temporarily locked Off and Enabled On) → correct password works again.

7. Troubleshooting

Symptom

Likely cause

Always “invalid password” even when Details shows Temporarily locked On

Service account missing view-users / query-users (or attack-detection access); Brute Force Detection not Enabled on the correct realm; or VRS APIs/FE build without lock check

Users list looks normal while the user cannot log in

Status badge may be missing in your Admin UI; open Details and check Temporarily locked / Enabled

Users list shows Disabled after you turned Temporarily locked Off

Expected; account is still Disabled; set Enabled On and Save

Locks too early

Quick login check not 0; Wait values too small

User stuck after wait / after clearing temp lock

Temporarily locked was cleared but the account is still Disabled; set Enabled On and Save

UI shows raw Http failure response…

Login error handling is not mapping Keycloak lock responses to the snackbar message