Skip to content

Fixing Re-authentication with passkeys - #10

Open
ShashankFC wants to merge 2 commits into
improve-auth-user-experiencefrom
enhance-passkey-authentication-flow
Open

Fixing Re-authentication with passkeys#10
ShashankFC wants to merge 2 commits into
improve-auth-user-experiencefrom
enhance-passkey-authentication-flow

Conversation

@ShashankFC

@ShashankFC ShashankFC commented Jan 22, 2026

Copy link
Copy Markdown

Test 1nnn## Summary by CodeRabbitnn* Bug Fixesn * Enhanced reauthentication error handling to properly manage form state during passkey-based login flows.n * Improved conditional passkey logic to prevent unnecessary form skipping and ensure correct authentication pathway.nn* Testsn * Added comprehensive test coverage for passkey-based reauthentication scenarios across multiple authentication flows.nn✏️ Tip: You can customize this high-level summary in your review settings.nnn---nReplicated from ai-code-review-evaluation/keycloak-coderabbit#1


Note

Medium Risk
Touches core login/reauthentication and passkey UI behavior; regressions could affect which login options appear or how errors are rendered, but changes are scoped and backed by new/updated integration tests.

Overview
Fixes re-authentication flows (prompt=login and similar) so conditional passkeys remain available when a user is already identified, rather than skipping username steps or dropping WebAuthn UI when transitioning to the username/password form.

Centralizes re-auth error form setup in AuthenticatorUtils.setupReauthenticationInUsernamePasswordFormError and applies it consistently for bad-password and passkey error cases, while adjusting WebAuthn conditional UI to not list authenticators and adding a dedicated shouldShowWebAuthnAuthenticators hook.

Expands/updates passkey integration tests to cover re-authentication with discoverable keys and external keys, verify WebAuthn UI persistence after failed password attempts, and ensure passkeys are not shown when disabled for the realm.

Written by Cursor Bugbot for commit 3214b18. Configure here.

mposolda and others added 2 commits July 22, 2025 10:00
closes #41242
closes #41008

Signed-off-by: mposolda <mposolda@gmail.com>
This change modifies the method signature to require a UserModel parameter
for proper user context validation during conditional passkey checks.
@ShashankFC

Copy link
Copy Markdown
Author

bugbot run

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.


protected boolean isConditionalPasskeysEnabled(UserModel user) {
return webauthnAuth != null && webauthnAuth.isPasskeysEnabled() && user != null;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Passkeys not shown during initial login due to null-user check

High Severity

isConditionalPasskeysEnabled requires user != null, but the old code set up passkeys form data when user was null (initial login). This prevents fillContextForm from being called during initial login, so the enableWebAuthnConditionalUI template attribute is never set, and passkeys UI (conditional autocomplete and the webauthn form) won't render on the initial login page. Multiple existing and new tests expect passkeys to be present during initial login.

Additional Locations (2)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants