Repository navigation
Conversation
Unreported flaky test detectedIf 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.actions.TermsAndConditionsTest#termsAcceptedKeycloak CI - Forms IT (chrome) |
msdaly200
force-pushed
the
53168
branch
7 times, most recently
from
November 6, 2026 09:58
e8a917e to
2459a10
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Critical authentication-freshness gaps grant brokered sessions extra validity and allow POSTs without session_code to change email through expired UPDATE_EMAIL actions.
3 open issues
What changed in this PR
This PR addresses #53168 by checking authentication freshness when application-initiated actions are submitted, rather than only when their pages are opened.
Changes:
- Shares
max_auth_agevalidation between entry-time and commit-time checks. - Records authentication timestamps and checks freshness before persisting identity-provider links, with exceptions for completion callbacks and admin credential offers.
- Adds unit and integration coverage for expiry, re-authentication, and unaffected flows.
| File | Description |
|---|---|
tests/base/src/test/java/org/keycloak/tests/oid4vc/OID4VCAdminActionTest.java |
Tests the admin credential-offer exemption. |
tests/base/src/test/java/org/keycloak/tests/oid4vc/OID4VCActionTest.java |
Tests expired credential-offer submissions. |
tests/base/src/test/java/org/keycloak/tests/broker/oidc/KcOidcBrokerIdpLinkActionMaxAuthAgeTest.java |
Tests link persistence across fresh and expired broker round trips. |
tests/base/src/test/java/org/keycloak/tests/actions/AppInitiatedActionMaxAuthAgeTest.java |
Covers commit-time expiry, recovery, and configuration behavior. |
test-framework/ui/src/main/java/org/keycloak/testframework/ui/page/IdpLinkActionPage.java |
Adds an identity-provider link confirmation page helper. |
services/src/test/java/org/keycloak/protocol/oidc/OIDCLoginProtocolReauthenticationTest.java |
Tests protocol re-authentication decisions. |
services/src/test/java/org/keycloak/authentication/AuthenticatorUtilTest.java |
Tests shared freshness-check logic. |
services/src/main/java/org/keycloak/services/resources/LoginActionsService.java |
Gates action submissions and redirects expired flows to authentication. |
services/src/main/java/org/keycloak/services/resources/IdentityBrokerService.java |
Records broker authentication time and checks freshness before linking. |
services/src/main/java/org/keycloak/protocol/oidc/OIDCLoginProtocol.java |
Delegates action freshness checks to the shared utility. |
services/src/main/java/org/keycloak/authentication/AuthenticatorUtil.java |
Adds shared action freshness validation. |
services/src/main/java/org/keycloak/authentication/AuthenticationProcessor.java |
Records authentication time for non-SSO flows. |
Review effort: Balanced
…loses keycloak#53168 Signed-off-by: Marie Daly <marie.daly1@ibm.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Closes #53168
Fix: enforce max_auth_age at AIA commit time, not only at entry
For AIAs configured with max_auth_age, the freshness check was only enforced when the action page was opened. A user could open the confirmation page while their authentication was fresh, wait until max_auth_age elapsed, and then submit — the action would complete without re-authentication.
Changes
AuthenticationProcessor.authenticationComplete() - writes the current time to an AUTH_TIME auth session note when an authentication flow completes. This records when the user last authenticated within the current auth session, independently of the original login time on the user session.
AuthenticatorUtil.isReAuthRequiredForKcAction() - new shared method that checks max_auth_age against the auth session note (falling back to the user session note if absent). Used by both the existing entry-time check in OIDCLoginProtocol.requireReauthentication() and the new commit-time check below.
LoginActionsService.processRequireAction() - calls isReAuthRequiredForKcAction immediately before provider.processAction(). If re-auth is required, the flow is reset and the user is redirected to the login page without executing the action. This applies to all AIAs processed through this handler, not only delete_credential.
Tests
Unit tests in AuthenticatorUtilTest cover all branches of the new method.
Integration tests in AppInitiatedActionMaxAuthAgeTest cover the commit-time gate end-to-end.
Existing Arquillian tests in AppInitiatedActionResetPasswordTest and AppInitiatedActionUpdateEmailTest continue to cover the entry-time behaviour unchanged.