Skip to content

fix(broker): Allows cross session email validation (#52604) - #52626

Merged
rmartinc merged 2 commits into
keycloak:mainfrom
olivierboudet:fix/issue-52604
Oct 8, 2026
Merged

rmartinc merged 2 commits into
keycloak:mainfrom
olivierboudet:fix/issue-52604

Conversation

@olivierboudet

Copy link
Copy Markdown
Contributor

Fixes #52604

Allows cross session email validation when using IdpDetectExistingBrokerUserAuthentication instead of IdpCreateUserIfUniqueAuthenticator

Copilot AI balanced review requested due to automatic review settings September 10, 2026 13:31
@olivierboudet
olivierboudet requested a review from a team as a code owner September 10, 2026 13:31

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

The new cross-session path needs a dedicated regression test.

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

Pull request overview

Enables cross-session email verification for detect-existing-user broker flows.

Changes:

  • Consumes the verified-user marker.
  • Restores the user and verification state before continuing account linking.
File summaries
File Description
IdpDetectExistingBrokerUserAuthenticator.java Handles cross-session verification for existing broker users.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Balanced

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

Comment on lines +82 to +89
runIfUserVerified(context.getSession(), user, broker, brokerContext.getBrokerUserId(),
() -> {
context.setUser(user);
context.getAuthenticationSession().setAuthNote(
IdpEmailVerificationAuthenticator.VERIFY_ACCOUNT_IDP_USERNAME,
brokerContext.getUsername()
);
});
Copilot AI review requested due to automatic review settings September 11, 2026 07:00
@olivierboudet
olivierboudet requested review from a team as code owners September 11, 2026 07:00

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

The test places email verification after auto-linking, so it does not reproduce the reported flow ordering.

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

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • 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.forms.BruteForceTest#testCacheExpiryForTemporaryLockout

Keycloak CI - Base IT (5)

org.opentest4j.AssertionFailedError: cache entry should have expired ==> expected: <null> but was: <org.keycloak.loginfailures.jpa.UserLoginFailureAdapter@95e6f76d>
	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.AssertNull.failNotNull(AssertNull.java:50)
	at org.junit.jupiter.api.AssertNull.assertNull(AssertNull.java:35)
...
org.opentest4j.AssertionFailedError: cache entry should have expired ==> expected: <null> but was: <org.keycloak.loginfailures.jpa.UserLoginFailureAdapter@af9edbf7>
	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.AssertNull.failNotNull(AssertNull.java:50)
	at org.junit.jupiter.api.AssertNull.assertNull(AssertNull.java:35)
...

Report flaky test

Copilot AI review requested due to automatic review settings September 11, 2026 08:50

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.

🟢 Approval recommended

No unresolved review issues were identified.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@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.BruteForceTest#testCacheExpiryForTemporaryLockout

Keycloak CI - Forms IT (chrome)

org.opentest4j.AssertionFailedError: cache entry should have expired ==> expected: <null> but was: <org.keycloak.loginfailures.jpa.UserLoginFailureAdapter@47378b0f>
	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.AssertNull.failNotNull(AssertNull.java:50)
	at org.junit.jupiter.api.AssertNull.assertNull(AssertNull.java:35)
...

Report flaky test

@vaceksimon

Copy link
Copy Markdown
Contributor

Hi @olivierboudet. The fix looks ok to me. Can you please rebase the PR on main?

Please keep in mind that in the meantime, the KcOidcFirstBrokerLoginDetectExistingUserTest was migrated from the legacy test suite to the new one in #52787. This might mean re-writing the test.

Refer to the test framework documentation, or ask away if you need any help.

@vaceksimon vaceksimon self-assigned this Oct 5, 2026
Allows cross session email validation when using IdpDetectExistingBrokerUserAuthentication instead of IdpCreateUserIfUniqueAuthenticator

Signed-off-by: Olivier Boudet <o.boudet@gmail.com>
Copilot AI balanced review requested due to automatic review settings October 7, 2026 07:56

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@olivierboudet

Copy link
Copy Markdown
Contributor Author

hi @vaceksimon thank you, I have rebased the branch and fix updated the test 👍

@vaceksimon vaceksimon 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.

LGTM, thank you @olivierboudet

@msdaly200 msdaly200 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.

Just one comment about priorities of the steps being set for the test.

Copilot AI balanced review requested due to automatic review settings October 7, 2026 15:54

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Signed-off-by: Olivier Boudet <o.boudet@gmail.com>

@msdaly200 msdaly200 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.

LGTM

@rmartinc rmartinc 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.

Thanks @olivierboudet, @vaceksimon and @msdaly200! LGTM too!

@rmartinc
rmartinc merged commit ad732f9 into keycloak:main Oct 8, 2026
97 checks passed
PadzerButch pushed a commit to PadzerButch/-50764_test_migration_keycloak that referenced this pull request Oct 22, 2026
…eycloak#52626)

* fix(broker): Allows cross session email validation (keycloak#52604)

Allows cross session email validation when using IdpDetectExistingBrokerUserAuthentication instead of IdpCreateUserIfUniqueAuthenticator

Signed-off-by: Olivier Boudet <o.boudet@gmail.com>

* fix priority

Signed-off-by: Olivier Boudet <o.boudet@gmail.com>

---------

Signed-off-by: Olivier Boudet <o.boudet@gmail.com>
PadzerButch pushed a commit to PadzerButch/-50764_test_migration_keycloak that referenced this pull request Oct 23, 2026
…eycloak#52626)

* fix(broker): Allows cross session email validation (keycloak#52604)

Allows cross session email validation when using IdpDetectExistingBrokerUserAuthentication instead of IdpCreateUserIfUniqueAuthenticator

Signed-off-by: Olivier Boudet <o.boudet@gmail.com>

* fix priority

Signed-off-by: Olivier Boudet <o.boudet@gmail.com>

---------

Signed-off-by: Olivier Boudet <o.boudet@gmail.com>
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.

IdpDetectExistingBrokerUserAuthenticator misses cross-browser account-link verification handling implemented in IdpCreateUserIfUniqueAuthenticator

5 participants