Skip to content

Say when a typed password is too long, and keep the generated one out of the form - #343

Merged
mraible merged 8 commits into
masterfrom
password-length-checks
Nov 24, 2026
Merged

mraible merged 8 commits into
masterfrom
password-length-checks

Conversation

@mraible

@mraible mraible commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #304, so merge #304 first; until then this PR's diff includes its commits.

Follows up #323 from review.

  • A password over 72 bytes in UTF-8 (for example 20 emoji) made BCrypt throw when registration, the profile page or the admin user editor saved it, so the user got an error page. The forms now check the length first, with the new RollerPasswordEncoders.isTooLong, and say the password is too long (userRegister.error.passwordTooLong). The profile page checks it whether or not an OpenID URL is given, since it saves a typed password either way.
  • Registration put the random password it generates for OIDC users in the form's hidden password fields, so a registration that failed validation, for example on a taken user name, sent it back to the browser. It now keeps that password in the action and uses it only when saving the user.

Tests: PasswordFormValidationTest covers registration and the profile page (with and without an OpenID URL), a password at the limit, and the generated password staying out of the form; UserEditPasswordLengthTest covers the admin user editor.

A further review pass added these fixes:

  • Users with an old-format password longer than 72 bytes can log in again.
  • db-oidc registration asks for a password when none is given.
  • The too-long message no longer cites a character count.

… of the form

A password over 72 bytes in UTF-8, for example 20 emoji, made BCrypt throw when Register, Profile or UserEdit saved it, so the user got an error page. The forms now check the length first and say the password is too long.

Register also put the random password it generates for OIDC users in the form's hidden password fields, so a registration that failed validation, for example on a taken user name, sent it back to the browser. It now keeps that password in the action and only uses it when saving the user.
Profile only checked a typed password's length when no OpenID URL was given, but it saves a typed password either way, so a long one with an OpenID URL still failed in BCrypt.
@mraible
mraible changed the base branch from external-login-placeholder to master November 18, 2026 04:14
@mraible
mraible requested a review from snoopdave November 18, 2026 04:16
@mraible mraible closed this Nov 18, 2026
@mraible mraible reopened this Nov 18, 2026
# Conflicts:
#	app/src/main/java/org/apache/roller/weblogger/ui/struts2/core/Register.java
…hecks

A user whose password is stored with an older encoding and is longer than BCrypt's 72 bytes can log in again. The encoder returns no re-encoding for such a password instead of throwing, so the login succeeds and the stored password is left as it is.

Registration under db-oidc now asks for a password when neither a password nor an OpenID URL is given, instead of failing when the user is saved. The missing-password error uses error.add.user.missingPassword, which exists in the message bundle. The length check no longer runs for LDAP and container-managed sign-ups, where the form holds the configured placeholder rather than a typed password.

The too-long message no longer promises 72 characters, since the limit is in bytes and the form fields are shorter than that.

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

Review of 082ad3701: Reviewed the commits beyond #304. Registration, Profile and UserEdit refuse passwords over 72 UTF-8 bytes before encoding, the generated OIDC password stays out of the form bean, and a login with a long legacy password keeps its stored hash (updatePassword ignores the null encoding). All resetPassword callers are now validated first. Merge after #304.

No new issues found.

@mraible

mraible commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

@snoopdave, this one only needs your approval again: merging #304 changed its base, so GitHub marked your approval as stale. Its diff hasn't changed.

I've also pushed fixes for all your comments from today's review, replied on each thread, and opened #364, a master follow-up to #304 for the marker gap you found on #306. #300 has master merged in; the only conflict was the LDAP remember-me signature that #300 removes.

@mraible
mraible enabled auto-merge November 20, 2026 16:19
@mraible
mraible disabled auto-merge November 20, 2026 21:31
A too-long password no longer stops the other checks, so the form also says when the user name is taken or the passwords don't match.
@snoopdave
snoopdave self-requested a review November 22, 2026 20:42

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

re-approving

@mraible
mraible enabled auto-merge November 24, 2026 17:07
@mraible
mraible disabled auto-merge November 24, 2026 17:07
@mraible

mraible commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@snoopdave could you approve this once more? GitHub wouldn't merge it on your last approval: the merge API says your review "is stale because it was submitted before the merge base changed". The branch still started from an older master, so I merged current master into it (f677833, no conflicts, 916 tests pass). The rule will treat our other open PRs the same way, so each needs an approval after its branch is current with master.

While you're in there, #300 needs a fresh approval (two commits after yours), and #364 has the two changes from your review, with both threads resolved.

@mraible
mraible enabled auto-merge November 24, 2026 17:20
@mraible
mraible merged commit 35fa96e into master Nov 24, 2026
10 checks passed
@mraible
mraible deleted the password-length-checks branch November 24, 2026 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants