Skip to content

fix: Identity providers should not be hidden from login page when the user goes back from the reset credentials page#48814

Open
vilmosnagy wants to merge 4 commits intokeycloak:mainfrom
vilmosnagy:vilmos/issue_33204_v2
Open

fix: Identity providers should not be hidden from login page when the user goes back from the reset credentials page#48814
vilmosnagy wants to merge 4 commits intokeycloak:mainfrom
vilmosnagy:vilmos/issue_33204_v2

Conversation

@vilmosnagy
Copy link
Copy Markdown
Contributor

Reopens #33254, closes #33204.

First of all, sorry for disappearing — a newborn arrived ~1.5 years ago and I never found the time to get back to this. Big thanks to @mposolda for keeping the previous PR open as long as he did.

I rebased the commits from #33254 and verified that the tests from last year still fail against the current main branch, so the issue is still present and the fix is still needed. I also tried to address the review discussion from last year. Specifically:

  • Cleared the RESET_CREDENTIAL_USER_CHOSEN auth note after calling context.clearUser(), so that subsequent renders of the login page within the same auth session don't needlessly clear the user again.
  • Added ResetPasswordTest::resetPasswordEmailLinkWorksAfterNavigatingBackToLoginPage to cover the scenario @mposolda raised: the user initiates a password reset, navigates back to the login page (which now clears the user from the auth session), and then clicks the email link. The test verifies the reset flow still completes successfully — it seems that a user who navigates back and then clicks the email link can still change their password and get logged in, which appears fine from a security standpoint. This test was roughly half AI-generated and half hand-reworked, using the tests I wrote for the previous PR as reference — all other code in this PR is hand-written from last year.

What the fix does

When a user submits a username on the "Forgot Password?" page, Keycloak sets that user on the authentication session. If the user then navigates back to the login page without completing the reset flow, Keycloak was showing only the identity providers linked to that specific user's account — leaking which social providers they had connected, which is a user enumeration vulnerability per the OWASP Forgot Password Cheat Sheet.

The fix detects the RESET_CREDENTIAL_USER_CHOSEN auth note in UsernamePasswordForm and clears the user from context before rendering the login page, so all configured IDPs are shown regardless of which user was identified during the reset flow.

vilmosnagy added 2 commits May 8, 2026 19:44
Signed-off-by: Vilmos Nagy <me@vnagy.eu>
Signed-off-by: Vilmos Nagy <me@vnagy.eu>
@vilmosnagy vilmosnagy force-pushed the vilmos/issue_33204_v2 branch from 6ce3187 to 0d11bb6 Compare May 8, 2026 18:53
vilmosnagy and others added 2 commits May 8, 2026 21:14
…ehaviour

Signed-off-by: Vilmos Nagy <me@vnagy.eu>
- Clear the RESET_CREDENTIAL_USER_CHOSEN auth note after clearing the user,
  so subsequent login page renders do not redundantly clear again (feedback
  from @mposolda in keycloak#33254)
- Add ResetPasswordTest::resetPasswordEmailLinkWorksAfterNavigatingBackToLoginPage
  to verify that the password reset email link still works after the user
  navigates back to the login page, covering the scenario raised in the
  review discussion of keycloak#33254

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Vilmos Nagy <me@vnagy.eu>
@vilmosnagy vilmosnagy force-pushed the vilmos/issue_33204_v2 branch from 0d11bb6 to abaabbc Compare May 8, 2026 19:14
@vilmosnagy
Copy link
Copy Markdown
Contributor Author

Is it possible that the failing test (PasskeysUsernameFormTest::passwordLoginWithNonDiscoverableKey) is a flaky one? On my machine it passes both from Jetbrains IDEA, and with running ./mvnw test -f tests/webauthn/pom.xml

If it's not flaky, can you help me reproduce the failure?

Apart from that I fixed all failing tests.

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.

Identity Providers are missing from the login page if I request a reset password for an existing user

1 participant