Skip to content

Let password managers use the username on password-only login pages - #53208

Open
fbelliardtp wants to merge 1 commit into
keycloak:mainfrom
fbelliardtp:53207-password-page-username-hint
Open

fbelliardtp wants to merge 1 commit into
keycloak:mainfrom
fbelliardtp:53207-password-page-username-hint

Conversation

@fbelliardtp

@fbelliardtp fbelliardtp commented Sep 25, 2026 •

Copy link
Copy Markdown

Two changes in the keycloak.v2 login theme, so that browser password managers can associate the password with the right account when the username isn't on the page:

  • Password page after a username step (Organizations identity-first login, Username Form + Password Form): the username is only shown in the read-only kc-attempted-username input from template.ftl, which sits outside the login <form> and has no autocomplete hint, so Chrome does not autofill the password. This adds autocomplete="username" to that input and associates it with the login form via form="kc-form-login". On pages without a kc-form-login form the attribute does not resolve and has no effect.
  • Update password page (login-update-password.ftl): the page has no username at all, so a password manager saves the new password without one. This adds a hidden autocomplete="username" input using the username attribute already passed by the UpdatePassword required action. Suggested in Password-only login pages should expose the username to password managers #53207 (comment).

Neither input has a name, so the submitted form data is unchanged.

Closes #53207

Testing

Manual, on 26.7.2 with the templates overridden in a custom theme, in Chrome with no saved credential for the site:

Page Before After
Password page, Organizations identity-first flow password not autofilled password autofilled
Update password, forced at login new password saved with an empty username saved under the right username
Update password, from the reset credentials email new password saved with an empty username saved under the right username

Firefox and 1Password already handled the password page fine. autocomplete="username" alone on kc-attempted-username was not enough for Chrome; form="kc-form-login" is needed as well. Submitted form data is unchanged and login and password update work as before.

Automated: extended OrganizationAuthenticationTest#testAuthenticateUnmanagedMember (asserts autocomplete/form on kc-attempted-username) and ResetPasswordTest#resetPasswordEmailLinkWorksAfterNavigatingBackToLoginPage (asserts the hidden username input's value, autocomplete, hidden, no name). Both fail against main and pass with this change.

Notes

Unrelated, pre-existing: the label of the kc-attempted-username group is rendered as <label for="username"> by field.group, while the input's id is kc-attempted-username, which Chrome reports as an incorrect label for. Left out of this PR.

AI assistance

This change was prepared with the help of an AI coding agent (Claude Code), including the investigation and the local testing. I reviewed the change and verified the behaviour in Chrome myself.

Copilot AI balanced review requested due to automatic review settings September 25, 2026 15:06
@fbelliardtp
fbelliardtp requested review from a team as code owners September 25, 2026 15:06

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 review overview

🟢 Approval recommended

The focused markup changes correctly implement the requested password-manager behavior without changing submitted data.

Review effort: Balanced
Findings: None

What changed in this PR

Adds username metadata to password-only pages so password managers can associate and autofill credentials without altering submitted form data.

Changes:

  • Adds hidden, read-only username inputs before password fields.
  • Covers identity-first and split username/password flows.
File Description
themes/​src/​main/​resources/​theme/​keycloak.v2/​login/​login.ftl Exposes the attempted username when the visible username field is hidden.
themes/​src/​main/​resources/​theme/​keycloak.v2/​login/​login-password.ftl Exposes the attempted username on password-only forms.

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

Copilot AI review requested due to automatic review settings September 28, 2026 06:36
@fbelliardtp
fbelliardtp force-pushed the 53207-password-page-username-hint branch from 890d9dd to 7456785 Compare September 28, 2026 06:36
@fbelliardtp fbelliardtp changed the title Expose attempted username to password managers on password-only login pages Let password managers use the attempted username on password-only login pages Sep 28, 2026

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 review overview

🟢 Approval recommended

The focused change is valid, preserves submitted form data, and matches the documented manually verified behavior.

Review effort: Balanced
Findings: None

@fbelliardtp
fbelliardtp force-pushed the 53207-password-page-username-hint branch from 7456785 to 7caf575 Compare October 5, 2026 14:41
Copilot AI balanced review requested due to automatic review settings October 5, 2026 14:41
@fbelliardtp fbelliardtp changed the title Let password managers use the attempted username on password-only login pages Let password managers use the username on password-only login pages Oct 5, 2026

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 review overview

🟡 Changes recommended

The new password-manager markup lacks automated regression coverage despite existing UI tests for both affected pages.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)

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 review overview

🟢 Approval recommended

The focused theme changes satisfy the stated behavior and are covered by appropriate regression assertions.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)

@fbelliardtp
fbelliardtp force-pushed the 53207-password-page-username-hint branch from e3600dd to 875f622 Compare October 26, 2026 07:43
Copilot AI balanced review requested due to automatic review settings October 26, 2026 07:43

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

The focused markup changes preserve form submission behavior and include targeted regression assertions, with no blocking issues identified.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

edewit
edewit previously approved these changes Oct 26, 2026
When the username was entered on a previous step, the password page only
shows it in the read-only kc-attempted-username input, which sits outside
the login form and has no autocomplete hint, so Chrome's password manager
cannot match the saved credential. Add autocomplete="username" to that
input and associate it with the login form via form="kc-form-login".

The update password page has no username at all, so a password manager
saves the new password without one. Add a hidden autocomplete="username"
input using the username already passed by the UpdatePassword required
action.

Neither input has a name, so the submitted form data is unchanged.

Closes keycloak#53207

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Florian BELLIARD <fbelliard@trustpair.com>
@fbelliardtp
fbelliardtp force-pushed the 53207-password-page-username-hint branch from 875f622 to 2f9ae83 Compare November 18, 2026 07:38
Copilot AI balanced review requested due to automatic review settings November 18, 2026 07:38

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 active review issues remain for the password-manager username-hint changes.

No open issues 🎉

Review effort: Balanced

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.

Password-only login pages should expose the username to password managers

3 participants