8000 Deprecate in-memory login failures and make persistent login failures the default by ahus1 · Pull Request #52128 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Deprecate in-memory login failures and make persistent login failures the default - #52128

Merged
pedroigor merged 37 commits into
keycloak:mainfrom
ahus1:is-52126-persistent-login-failures
Sep 9, 2026
Merged

pedroigor merged 37 commits into
keycloak:mainfrom
ahus1:is-52126-persistent-login-failures

Conversation

@ahus1
@ahus1 ahus1 commented Aug 27, 2026 •
Copy link
Copy Markdown
Member

Closes #52126

Summary

  • Introduces a new versioned feature login-failures with v1 (in-memory, deprecated) and v2 (persistent/database, default).
  • The JPA login failure provider (already used by stateless) is now active by default via LOGIN_FAILURES_V2, making database-backed login failures the standard for single-site deployments.
  • The embedded Infinispan provider activates only when login-failures:v1 is explicitly enabled.
  • Custom Hibernate dialects (KeycloakH2Dialect, KeycloakOracleDialect, KeycloakSQLServerDialect) fix INSERT ... ON CONFLICT ... DO NOTHING being silently dropped by Hibernate on H2, Oracle, and MS SQL Server.
  • MySQL/MariaDB transaction isolation switched to READ COMMITTED when the stateless feature is enabled, preventing deadlocks from gap locks on upsert statements.
  • Idempotent clearFailures() optimization: skips database locking on successful logins when no failure data exists.
  • Login failure expiration: entries are treated as expired based on maxDeltaTimeSeconds, matching the Infinispan TTL behavior.
  • Cleanup on realm/user removal via ProviderEventListener.
  • Documentation updated across release notes, upgrading guide, migration prep, and caching guide.

Decisions and assumptions

  • MULTI_SITE and CLUSTERLESS are unchanged: These features continue to store login failures in the external Infinispan cluster via RemoteUserLoginFailureProviderFactory, regardless of the login-failures feature version. No dependency on LOGIN_FAILURES_V2 was added to these features. The remote provider's isSupported() check (!STATELESS && isRemoteInfinispan()) is unchanged.
  • Only STATELESS depends on LOGIN_FAILURES_V2: Since stateless already required JPA login failures, this dependency is a natural fit. The versioned feature conflict mechanism prevents login-failures:v1 from being enabled alongside stateless.
  • Provider ordering handles multi-site/clusterless correctly: The remote provider has order()=1 vs JPA's default order()=0. When both are supported (e.g., clusterless + default v2), the 8000 remote provider wins automatically — no explicit exclusion needed in the JPA provider.
  • Custom Hibernate dialects for H2, Oracle, MS SQL Server: Hibernate's default SQL AST translators for these databases silently drop ON CONFLICT ... DO NOTHING conflict clauses instead of emitting MERGE statements. The custom dialects override visitInsertStatementOnly to call visitInsertStatementEmulateMerge when conflict columns are present. MySQL/MariaDB and PostgreSQL handle this correctly out of the box. The Quarkus distribution sets the custom dialect on all persistence units; DefaultJpaConnectionProviderFactory (used in tests) auto-detects the database and applies the dialect.
  • Explicit conflict columns in HQL queries: The MERGE emulation requires explicit conflict column names. LoginFailureEntity, OutboxEntryEntity, and RootAuthenticationSessionEntity specify ON CONFLICT(id) DO NOTHING (or composite keys) so the dialect can produce a correct MERGE ON clause.
  • MySQL/MariaDB READ COMMITTED isolation (stateless only): The default REPEATABLE READ isolation acquires gap locks on INSERT ... ON DUPLICATE KEY UPDATE, causing deadlocks under concurrent logins. READ COMMITTED is set only when stateless is enabled to limit the blast radius. This matches PostgreSQL, Oracle, and SQL Server defaults. Requires binlog_format = ROW or MIXED (default since MySQL 8.0 / MariaDB 10.6). Changing isolation for all modes is being considered for a future release.
  • Idempotent clearFailures() avoids unnecessary locking: On successful logins, clearFailures() checks whether any failure data exists before acquiring a database lock. This avoids contention on the login failure row during the common successful-login path.
  • Login failure expiration in JPA: Entries are treated as expired when lastFailure is older than maxDeltaTimeSeconds (same threshold as LoginFailureExpirationAction). Expired entries are filtered out on read and re-initialized on upsert. A background ExpirationTask periodically purges old entries.
  • Test infrastructure fixes: Jpa.java adds TimerSpi/ExecutorsSpi and their factories (required by the expiration task now loaded by default). Stateless.java removes the LOGIN_FAILURES_V1 system property set by Infinispan.java to prevent the V1/STATELESS dependency conflict. CustomJpaEntityProviderDistTest updated because Quarkus overrides dialect for all persistence units (4x KeycloakH2Dialect).
  • Galera Cluster: The default behavior of a MySQL or MariaDB Galera cluster is problematic for stateless, but also for any other mode: Replication is visible only asynchronous by default though they are replicated synchronously. This can be changed with wsrep_sync_wait = 1. Also the isolation level READ COMMITTED will only be effective within a node, but not across nodes. With that, all writes need to go to a single node.

🤖 Generated with Claude Code

@ahus1 ahus1 self-assigned this Aug 27, 2026
@ahus1
ahus1 force-pushed the is-52126-persistent-login-failures branch 2 times, most recently from 6fa88bf to 7979aa8 Compare August 27, 2026 12:22
@keycloak-github-bot keycloak-github-bot Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreported flaky test detected, please review

@keycloak-github-bot
Copy link
Copy Markdown

Unreported flaky test detected

If the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.broker.KcSamlBrokerTest#loginWithExistingUserWithBruteForceEnabled

Keycloak CI - FIPS IT (non-strict)

org.openqa.selenium.TimeoutException: 
Expected condition failed: waiting for value to contain (ignoring case) "sign in to". Current value: "AUTH_RESPONSE"
(tried for 5 seconds with 500 milliseconds interval)
Build info: version: '4.46.0', revision: 'df5a634 df5a6341cbb5f8f06b836bd595752775627c80dc'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.17.0-1022-azure', java.version: '25.0.4.1'
...

Report flaky test

@keycloak-github-bot keycloak-github-bot Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreported flaky test detected, please review

@keycloak-github-bot
Copy link
Copy Markdown

Unreported flaky test detected

If the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.broker.KcOidcBrokerTest#loginWithExistingUserWithBruteForceEnabled

Keycloak CI - Java Distribution IT (ubuntu-latest - temurin - 21)

org.opentest4j.AssertionFailedError: Expected page 'login-error' to be loaded, but currently on page 'null' after timeout
	at org.keycloak.testsuite.pages.AbstractPage.waitForPage(AbstractPage.java:62)
	at org.keycloak.testsuite.pages.AbstractPage.assertCurrent(AbstractPage.java:47)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.jboss.arquillian.graphene.proxy.GrapheneProxyHandler.invokeReal(GrapheneProxyHandler.java:143)
...
org.opentest4j.AssertionFailedError: Expected page 'login-error' to be loaded, but currently on page 'null' after timeout
	at org.keycloak.testsuite.pages.AbstractPage.waitForPage(AbstractPage.java:62)
	at org.keycloak.testsuite.pages.AbstractPage.assertCurrent(AbstractPage.java:47)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.jboss.arquillian.graphene.proxy.GrapheneProxyHandler.invokeReal(GrapheneProxyHandler.java:143)
...

Report flaky test

@keycloak-github-bot keycloak-github-bot Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreported flaky test detected, please review

@keycloak-github-bot
Copy link
Copy Markdown

Unreported flaky test detected

If the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.broker.KcOidcBrokerTest#loginWithExistingUserWithBruteForceEnabled

Keycloak CI - Java Distribution IT (ubuntu-latest - temurin - 17)

org.opentest4j.AssertionFailedError: Expected page 'login-error' to be loaded, but currently on page 'null' after timeout
	at org.keycloak.testsuite.pages.AbstractPage.waitForPage(AbstractPage.java:62)
	at org.keycloak.testsuite.pages.AbstractPage.assertCurrent(AbstractPage.java:47)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
	at org.jboss.arquillian.graphene.proxy.GrapheneProxyHandler.invokeReal(GrapheneProxyHandler.java:143)
...

Report flaky test

@ahus1
ahus1 force-pushed the is-52126-persistent-login-failures branch 2 times, most recently from e663018 to abcf9a5 Compare August 28, 2026 21:12
@keycloak-github-bot
Copy link
Copy Markdown

Unreported flaky test detected

If the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.forms.MultiFactorAuthenticationTest#testAlternativeCredentials

Keycloak CI - Forms IT (chrome)

org.openqa.selenium.WebDriverException: 
unknown error: unhandled inspector error: {"code":-32000,"message":"Node with given id does not belong to the document"}
  (Session info: chrome=151.0.7922.173)
Build info: version: '4.46.0', revision: 'df5a634 df5a6341cbb5f8f06b836bd595752775627c80dc'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.17.0-1022-azure', java.version: '25.0.4.1'
...

Report flaky test

@keycloak-github-bot keycloak-github-bot Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreported flaky test detected, please review

@keycloak-github-bot keycloak-github-bot Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreported flaky test detected, please review

@keycloak-github-bot
Copy link
Copy Markdown

Unreported flaky test detected

If the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.federation.ldap.LDAPUserLoginTest#loginLDAPUserCredentialVaultAuthenticationNoneEncryptionStartTLS

Keycloak CI - Java Distribution IT (windows-latest - temurin - 17)

org.openqa.selenium.TimeoutException: 
java.net.SocketTimeoutException: Read timed out
Build info: version: '4.46.0', revision: 'df5a634 df5a6341cbb5f8f06b836bd595752775627c80dc'
System info: os.name: 'Windows Server 2025', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.20.1'
Driver info: driver.version: HtmlUnitDriver
...

Report flaky test

< 8000 /option>

@keycloak-github-bot
Copy link
Copy Markdown

Unreported flaky test detected

If the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.webauthn.passwordless.WebAuthnPwdLessPropertyTest#timeout

Keycloak CI - WebAuthn IT

org.openqa.selenium.WebDriverException: 
unknown error: unhandled inspector error: {"code":-32000,"message":"Node with given id does not belong to the document"}
  (Session info: chrome=151.0.7922.173)
Build info: version: '4.46.0', revision: 'df5a634 df5a6341cbb5f8f06b836bd595752775627c80dc'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.17.0-1022-azure', java.version: '25.0.4.1'
...

Report flaky test

@keycloak-github-bot keycloak-github-bot Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreported flaky test detected, please review

@keycloak-github-bot keycloak-github-bot Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreported flaky test detected, please review

@keycloak-github-bot
Copy link
Copy Markdown

Unreported flaky test detected

If the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.webauthn.passwordless.WebAuthnPwdLessPropertyTest#timeout

Keycloak CI - WebAuthn IT

org.openqa.selenium.WebDriverException: 
unknown error: unhandled inspector error: {"code":-32000,"message":"Node with given id does not belong to the document"}
  (Session info: chrome=151.0.7922.173)
Build info: version: '4.46.0', revision: 'df5a634 df5a6341cbb5f8f06b836bd595752775627c80dc'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.17.0-1022-azure', java.version: '25.0.4.1'
...

Report flaky test

return false;
}
// Expired if last failure is older than maxDeltaTimeSeconds (same threshold used by LoginFailureExpirationAction).
long expireMs = TimeUnit.SECONDS.toMillis((long) Time.currentTime() - realm.getMaxDeltaTimeSeconds());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Time.currentTimeSeconds() instead

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is probably worth to move this computation to a common method to be shared between here and the expiration task.

    // returns the timestamp of expired entries, or -1 if permanent lockout is configured
    public static long computeExpiration(RealmModel realm, long currentTime) {
        if (realm.isPermanentLockout() && realm.getMaxTemporaryLockouts() == 0) {
            // If mode is permanent lockout only, the "failure reset time" cannot be configured and login failures should never expire.
            return -1L;
        }
        // expired if last-failure + max-delta-time < current time
        return TimeUnit.SECONDS.toMillis(currentTime - realm.getMaxDeltaTimeSeconds());
    }

@@ -361,6 +364,58 @@ private void checkMySQLWaitTimeout() {
}
}

private void checkMySQLBinlogFormat() {
if (!Profile.isFeatureEnabled(Profile.Feature.STATELESS)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this check be performed when login-failures-v2 is enabled?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're only switching to READ COMMITTED isolation level when stateless is enabled. It is essential for root authentication sessions, and not for login failures. I'll add a line comment in the next commit.

if (vendor != Database.Vendor.MYSQL && vendor != Database.Vendor.MARIADB && vendor != Database.Vendor.TIDB) {
return false;
}
return Profile.isFeatureEnabled(Profile.Feature.STATELESS);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't login-failures:v2 requires it too?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests didn't show it, and I hope not. The tests didn't require it. I assume there are not so many concurrent inserts here, and once the table fills it shouldn't lead to deadlocks. If there are complaints, they can roll back to login failures V1.

I don't feel ready to make this enable for all databases. We could have a follow-up discussion on that one, and then re-decide for 26.8. But it would need to be opt-in.

import org.keycloak.models.RealmModel;
import org.keycloak.models.UserModel;

public class DefaultLockingBruteForceProtector extends DefaultBlockingBruteForceProtector {
@pruivo pruivo Aug 31, 2026 •
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it extend DefaultBruteForceProtector instead? The DefaultBlockingBruteForceProtector has a Map with 1000 entries instantiated every time, wasting memory. It has no use since the instance is not shared between sessions.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this was broken, well spotted. I'm rewriting this completely in the next commit.

@@ -48,7 +49,7 @@ public void init(Config.Scope config) {

@Override
public void postInit(KeycloakSessionFactory factory) {
protector = allowConcurrentRequests ? new DefaultBruteForceProtector(factory) : new DefaultBlockingBruteForceProtector(factory);
protector = Profile.isFeatureEnabled(Profile.Feature.LOGIN_FAILURES_V2) ? null : allowConcurrentRequests ? new DefaultBruteForceProtector(factory) : new DefaultBlockingBruteForceProtector(factory);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpic, an if-else would it make more readable

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reworked in next commit.

10BC8
return;
}

try (Connection connection = getConnection();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't you do this in the connection above (line 396)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, reworked in next commit

@keycloak-github-bot keycloak-github-bot Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreported flaky test detected, please review

@keycloak-github-bot
Copy link
Copy Markdown

Unreported flaky test detected

If the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.forms.MultipleTabsLoginTest#testLoginAfterLogoutFromDifferentTab

Keycloak CI - Forms IT (chrome)

org.opentest4j.MultipleFailuresError: 
Multiple Failures (2 failures)
	org.openqa.selenium.TimeoutException: timeout: Timed out receiving message from renderer: 10.000
  (Session info: chrome=151.0.7922.173)
Build info: version: '4.46.0', revision: 'df5a634 df5a6341cbb5f8f06b836bd595752775627c80dc'
...

Report flaky test

org.keycloak.testsuite.forms.MultipleTabsLoginTest#loginActionWithoutExecution

Keycloak CI - Forms IT (chrome)

org.openqa.selenium.TimeoutException: 
timeout: Timed out receiving message from renderer: 10.000
  (Session info: chrome=151.0.7922.173)
Build info: version: '4.46.0', revision: 'df5a634 df5a6341cbb5f8f06b836bd595752775627c80dc'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.17.0-1022-azure', java.version: '25.0.4.1'
...

Report flaky test

org.keycloak.testsuite.forms.MultipleTabsLoginTest#multipleTabsParallelLoginTestWithAuthSessionExpiredAndRequiredAction

Keycloak CI - Forms IT (chrome)

org.openqa.selenium.TimeoutException: 
timeout: Timed out receiving message from renderer: 10.000
  (Session info: chrome=151.0.7922.173)
Build info: version: '4.46.0', revision: 'df5a634 df5a6341cbb5f8f06b836bd595752775627c80dc'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.17.0-1022-azure', java.version: '25.0.4.1'
...

Report flaky test

org.keycloak.testsuite.forms.MultipleTabsLoginTest#expiredAuthenticationAction_expiredCodeExpiredExecution

Keycloak CI - Forms IT (chrome)

org.openqa.selenium.TimeoutException: 
timeout: Timed out receiving message from renderer: 10.000
  (Session info: chrome=151.0.7922.173)
Build info: version: '4.46.0', revision: 'df5a634 df5a6341cbb5f8f06b836bd595752775627c80dc'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.17.0-1022-azure', java.version: '25.0.4.1'
...

Report flaky test

org.keycloak.testsuite.forms.MultipleTabsLoginTest#testWithAuthSessionExpiredInTheMiddle_badRedirectUri

Keycloak CI - Forms IT (chrome)

org.openqa.selenium.TimeoutException: 
timeout: Timed out receiving message from renderer: 10.000
  (Session info: chrome=151.0.7922.173)
Build info: version: '4.46.0', revision: 'df5a634 df5a6341cbb5f8f06b836bd595752775627c80dc'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.17.0-1022-azure', java.version: '25.0.4.1'
...

Report flaky test

org.keycloak.testsuite.forms.MultipleTabsLoginTest#testEmptyBaseUrl

Keycloak CI - Forms IT (chrome)

org.openqa.selenium.TimeoutException: 
timeout: Timed out receiving message from renderer: 10.000
  (Session info: chrome=151.0.7922.173)
Build info: version: '4.46.0', revision: 'df5a634 df5a6341cbb5f8f06b836bd595752775627c80dc'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.17.0-1022-azure', java.version: '25.0.4.1'
...

Report flaky test

org.keycloak.testsuite.forms.MultipleTabsLoginTest#testRestartFailureWithDifferentClientAfterAuthSessionExpiration

Keycloak CI - Forms IT (chrome)

org.openqa.selenium.TimeoutException: 
timeout: Timed out receiving message from renderer: 10.000
  (Session info: chrome=151.0.7922.173)
Build info: version: '4.46.0', revision: 'df5a634 df5a6341cbb5f8f06b836bd595752775627c80dc'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.17.0-1022-azure', java.version: '25.0.4.1'
...

Report flaky test

org.keycloak.testsuite.forms.MultipleTabsLoginTest#expiredAuthenticationAction_currentCodeExpiredExecution

Keycloak CI - Forms IT (chrome)

org.openqa.selenium.TimeoutException: 
timeout: Timed out receiving message from renderer: 10.000
  (Session info: chrome=151.0.7922.173)
Build info: version: '4.46.0', revision: 'df5a634 df5a6341cbb5f8f06b836bd595752775627c80dc'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.17.0-1022-azure', java.version: '25.0.4.1'
...

Report flaky test

org.keycloak.testsuite.forms.MultipleTabsLoginTest#testLogoutDifferentBrowserWithAuthenticationSessionStillPresent

Keycloak CI - Forms IT (chrome)

org.openqa.selenium.TimeoutException: 
timeout: Timed out receiving message from renderer: 10.000
  (Session info: chrome=151.0.7922.173)
Build info: version: '4.46.0', revision: 'df5a634 df5a6341cbb5f8f06b836bd595752775627c80dc'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.17.0-1022-azure', java.version: '25.0.4.1'
...

Report flaky test

org.keycloak.testsuite.forms.MultipleTabsLoginTest#multipleTabsLoginAndPassiveCheck

Keycloak CI - Forms IT (chrome)

org.openqa.selenium.TimeoutException: 
timeout: Timed out receiving message from renderer: 10.000
  (Session info: chrome=151.0.7922.173)
Build info: version: '4.46.0', revision: 'df5a634 df5a6341cbb5f8f06b836bd595752775627c80dc'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.17.0-1022-azure', java.version: '25.0.4.1'
...

Report flaky test

org.keycloak.testsuite.forms.MultipleTabsLoginTest#multipleTabsParallelLoginTestWithAuthSessionExpiredInTheMiddle

Keycloak CI - Forms IT (chrome)

org.openqa.selenium.TimeoutException: 
timeout: Timed out receiving message from renderer: 10.000
  (Session info: chrome=151.0.7922.173)
Build info: version: '4.46.0', revision: 'df5a634 df5a6341cbb5f8f06b836bd595752775627c80dc'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.17.0-1022-azure', java.version: '25.0.4.1'
...

Report flaky test

org.keycloak.testsuite.forms.MultipleTabsLoginTest#loginActionWithoutExecutionInRequiredActions

Keycloak CI - Forms IT (chrome)

org.openqa.selenium.TimeoutException: 
timeout: Timed out receiving message from renderer: 10.000
  (Session info: chrome=151.0.7922.173)
Build info: version: '4.46.0', revision: 'df5a634 df5a6341cbb5f8f06b836bd595752775627c80dc'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.17.0-1022-azure', java.version: '25.0.4.1'
...

Report flaky test

org.keycloak.testsuite.forms.MultipleTabsLoginTest#multipleTabsParallelLoginTestWithAuthSessionExpiredAndRefreshInTab1

Keycloak CI - Forms IT (chrome)

org.openqa.selenium.TimeoutException: 
timeout: Timed out receiving message from renderer: 10.000
  (Session info: chrome=151.0.7922.173)
Build info: version: '4.46.0', revision: 'df5a634 df5a6341cbb5f8f06b836bd595752775627c80dc'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.17.0-1022-azure', java.version: '25.0.4.1'
...

Report flaky test

org.keycloak.testsuite.forms.MultipleTabsLoginTest#testLoginPageRefresh

Keycloak CI - Forms IT (chrome)

org.openqa.selenium.TimeoutException: 
timeout: Timed out receiving message from renderer: 10.000
  (Session info: chrome=151.0.7922.173)
Build info: version: '4.46.0', revision: 'df5a634 df5a6341cbb5f8f06b836bd595752775627c80dc'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.17.0-1022-azure', java.version: '25.0.4.1'
...

Report flaky test

org.keycloak.testsuite.forms.MultipleTabsLoginTest#loginWithDifferentClients

Keycloak CI - Forms IT (chrome)

org.openqa.selenium.TimeoutException: 
timeout: Timed out receiving message from renderer: 10.000
  (Session info: chrome=151.0.7922.173)
Build info: version: '4.46.0', revision: 'df5a634 df5a6341cbb5f8f06b836bd595752775627c80dc'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.17.0-1022-azure', java.version: '25.0.4.1'
...

Report flaky test

org.keycloak.testsuite.forms.MultipleTabsLoginTest#multipleTabsParallelLoginTestWithAuthSessionExpiredAndRegisterClick

Keycloak CI - Forms IT (chrome)

org.openqa.selenium.TimeoutException: 
timeout: Timed out receiving message from renderer: 10.000
  (Session info: chrome=151.0.7922.173)
Build info: version: '4.46.0', revision: 'df5a634 df5a6341cbb5f8f06b836bd595752775627c80dc'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.17.0-1022-azure', java.version: '25.0.4.1'
...

Report flaky test

org.keycloak.testsuite.forms.MultipleTabsLoginTest#multipleTabsParallelLoginTest

Keycloak CI - Forms IT (chrome)

org.openqa.selenium.TimeoutException: 
timeout: Timed out receiving message from renderer: 10.000
  (Session info: chrome=151.0.7922.173)
Build info: version: '4.46.0', revision: 'df5a634 df5a6341cbb5f8f06b836bd595752775627c80dc'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.17.0-1022-azure', java.version: '25.0.4.1'
...

Report flaky test

org.keycloak.testsuite.forms.MultipleTabsLoginTest#expiredAuthenticationAction_expiredCodeCurrentExecution

Keycloak CI - Forms IT (chrome)

org.openqa.selenium.TimeoutException: 
timeout: Timed out receiving message from renderer: 10.000
  (Session info: chrome=151.0.7922.173)
Build info: version: '4.46.0', revision: 'df5a634 df5a6341cbb5f8f06b836bd595752775627c80dc'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.17.0-1022-azure', java.version: '25.0.4.1'
...

Report flaky test

org.keycloak.testsuite.forms.MultipleTabsLoginTest#testInjectRedirectUriInClientDataAfterAuthSessionExpiration

Keycloak CI - Forms IT (chrome)

org.openqa.selenium.TimeoutException: 
timeout: Timed out receiving message from renderer: 10.000
  (Session info: chrome=151.0.7922.173)
Build info: version: '4.46.0', revision: 'df5a634 df5a6341cbb5f8f06b836bd595752775627c80dc'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.17.0-1022-azure', java.version: '25.0.4.1'
...

Report flaky test

@ahus1
ahus1 requested a balanced review from Copilot August 31, 2026 16:58
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Makes persistent, database-backed login failures the default while retaining deprecated in-memory and remote-cache modes.

Changes:

  • Adds versioned login-failure features, persistence, expiration, cleanup, and locking.
  • Adds database dialect and isolation handling for reliable upserts.
  • Expands tests, CI coverage, migration guidance, and release documentation.

Reviewed changes

Copilot reviewed 34 out of 35 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
testsuite/model/.../Stateless.java Resolves stateless feature dependency.
testsuite/model/.../Jpa.java Adds expiration-task dependencies.
testsuite/model/.../Infinispan.java Enables deprecated V1 for tests.
testsuite/integration-arquillian/.../keycloak-server.json Defaults tests to JPA failures.
tests/base/.../StatelessTestSuite.java Expands stateless coverage.
tests/base/.../LoginFailureExpirationTest.java Tests real-time expiration.
services/.../DefaultLockingBruteForceProtector.java Serializes same-user logins.
services/.../DefaultBruteForceProtectorFactory.java Selects V1/V2 protection behavior.
server-spi-private/.../LoginFailureUtils.java Centralizes expiration calculation.
quarkus/tests/.../CustomJpaEntityProviderDistTest.java Updates dialect expectation.
quarkus/runtime/.../DatasourcesConfigurationTest.java Tests custom dialect defaults.
quarkus/runtime/.../ConfigurationTest.java Updates database configuration tests.
quarkus/runtime/.../QuarkusJpaConnectionProviderFactory.java Adds database startup checks.
quarkus/runtime/.../DatabasePropertyMappers.java Configures READ COMMITTED.
quarkus/config-api/.../Database.java Registers Keycloak dialects.
model/jpa/.../OutboxEntryEntity.java Specifies upsert conflict columns.
model/jpa/.../UserLoginFailureAdapter.java Optimizes failure clearing.
model/jpa/.../LoginFailureExpirationAction.java Uses shared expiration logic.
model/jpa/.../JpaUserLoginFailureProviderFactory.java Enables JPA V2 and cleanup.
model/jpa/.../JpaUserLoginFailureProvider.java Handles persistent expiration.
model/jpa/.../KeycloakSQLServerDialect.java Adds SQL Server MERGE emulation.
model/jpa/.../KeycloakOracleDialect.java Adds Oracle MERGE emulation.
model/jpa/.../KeycloakH2Dialect.java Adds H2 MERGE emulation.
model/jpa/.../DefaultJpaConnectionProviderFactory.java Auto-detects custom dialects.
model/jpa/.../RootAuthenticationSessionEntity.java Specifies upsert conflict key.
model/infinispan/.../InfinispanUserLoginFailureProviderFactory.java Restricts embedded storage to V1.
docs/guides/server/db.adoc Documents database requirements.
docs/guides/server/caching.adoc Documents login-failure storage.
docs/.../prep_migration.adoc Updates migration preparation.
docs/.../changes-26_8_0.adoc Adds notable upgrade changes.
docs/.../ignored-links Updates temporary link exclusions.
docs/.../release_notes/topics/26_8_0.adoc Announces persistent failures.
common/.../Profile.java Registers V1/V2 features.
.github/workflows/ci.yml Extends Store IT timeout.
.github/actions/run-store-tests/action.yml Runs full stateless tests.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread docs/guides/server/caching.adoc Resolved
ahus1 and others added 15 commits September 7, 2026 15:09
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@gmx.net>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@gmx.net>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
…span/DefaultInfinispanConnectionProviderFactory.java

Co-authored-by: Pedro Ruivo <pruivo@users.noreply.github.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@gmx.net>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@gmx.net>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
Copilot AI review requested due to automatic review settings September 7, 2026 13:10
@ahus1
ahus1 force-pushed the is-52126-persistent-login-failures branch from 1691cd4 to 0d1ba24 Compare September 7, 2026 13:10
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Secondary-factor counters can be reset inadvertently, and JPA cleanup is mis-scoped when the remote provider is selected.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

model/jpa/src/main/java/org/keycloak/loginfailures/jpa/JpaUserLoginFailureProviderFactory.java:88

  • Provider ordering only controls which provider getProvider() returns; every enabled factory still receives postInit. With default v2 plus a higher-order remote provider, this therefore schedules an unused JPA cleanup task that scans every realm and the database every interval. Guard scheduling so it runs only when JPA is the selected login-failure provider.
        ExpirationTask.builder()
                .withEntityId("login-failure")
                .withAction(LoginFailureExpirationAction.INSTANCE)
                .withFactory(factory)
                .withExecutor(ExpirationHelper.expirationExecutor(factory))
                .withMaxRemoval(expirationTaskMaxRemoval)
                .withMetrics(metricsEnabled)
                .withRealmExpiration(true)
                .withTimeout(expirationTaskTimeoutSeconds, TimeUnit.SECONDS)
                .withInterval(expirationTaskIntervalSeconds, TimeUnit.SECONDS)
                .build()
                .schedule();
  • Files reviewed: 35/37 changed files
  • Comments generated: 3
  • Review effort level: Balanced

@keycloak-github-bot keycloak-github-bot Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreported flaky test detected, please review

@keycloak-github-bot
Copy link
Copy Markdown

Unreported flaky test detected

If the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.adapter.servlet.SAMLServletAdapterTest#salesPostTest

Keycloak CI - Adapter IT Strict Cookies

org.opentest4j.AssertionFailedError: expected: <true> but was: <false>
	at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
	at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
	at org.junit.jupiter.api.AssertTrue.failNotTrue(AssertTrue.java:63)
	at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:36)
...

Report flaky test

org.keycloak.testsuite.adapter.servlet.SAMLServletAdapterTest#employeeSigPostNoIdpKeyTestKeyIdAsKeyNameInKeyInfo

Keycloak CI - Adapter IT Strict Cookies

org.opentest4j.AssertionFailedError: expected: <true> but was: <false>
	at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
	at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
	at org.junit.jupiter.api.AssertTrue.failNotTrue(AssertTrue.java:63)
	at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:36)
...

Report flaky test

org.keycloak.testsuite.adapter.servlet.SAMLServletAdapterTest#testMultipleTabsParallelLogin

Keycloak CI - Adapter IT Strict Cookies

org.opentest4j.AssertionFailedError: Expected page 'login-login' to be loaded, but currently on page 'null' after timeout
	at org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:38)
	at org.junit.jupiter.api.Assertions.fail(Assertions.java:138)
	at org.keycloak.testsuite.pages.AbstractPage.waitForPage(AbstractPage.java:62)
	at org.keycloak.testsuite.pages.AbstractPage.assertCurrent(AbstractPage.java:47)
...

Report flaky test

@pedroigor
pedroigor merged commit 685ee8b into keycloak:main Sep 9, 2026
105 of 107 checks passed
michalvavrik-dev-automation added a commit to michalvavrik-dev-automation/keycloak that referenced this pull request Sep 9, 2026
…stom dialects

PR keycloak#52128 introduced custom database dialects (KeycloakH2Dialect,
KeycloakSQLServerDialect, KeycloakOracleDialect) to fix Hibernate ORM
HHH-20826 ('on conflict do nothing' dropping conflict clause) and
made them the default dialects in Database.java.

When producing user-defined persistence units, resolve dialects with
the following precedence:
1. Explicit CLI/config option (--db-dialect-<datasource>) always wins.
2. Dialects declared in persistence.xml: standard Hibernate dialects
   replaced by Keycloak dialects (H2, MSSQL, Oracle) are upgraded to
   the Keycloak equivalents, while custom user dialects are honored.
3. If no dialect is declared in persistence.xml, derive dialect from
   the datasource DB kind.

Also update CustomJpaEntityProviderDistTest assertions to expect
KeycloakH2Dialect for default, client-store, and pu-without-dialect-store
persistence units, while preserving KeycloakItH2Dialect for custom user unit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecate in-memory login failures and make persistent login failures the default

5 participants

0