Skip to content

Don't match the external-login placeholder as a password - #306

Open
mraible wants to merge 13 commits into
roller-6.1.xfrom
external-login-placeholder-6.1.x
Open

mraible wants to merge 13 commits into
roller-6.1.xfrom
external-login-placeholder-6.1.x

Conversation

@mraible

@mraible mraible commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

The 6.1.x version of #304.

Users who log in through LDAP or the servlet container have users.passwords.externalAuthValue (by default <externalAuth>) stored in place of a Roller password. RollerContext now wraps its password encoder in a new ExternalLoginAwarePasswordEncoder, whose matches() never accepts that placeholder, the default <externalAuth> or an empty password, wherever Roller checks a password with the encoder. Encoding and upgradeEncoding are unchanged, and stored passwords aren't touched.

  • Registration, the profile page and the admin user editor refuse the placeholder as a new password, and an empty users.passwords.externalAuthValue falls back to <externalAuth>.
  • Earlier values of users.passwords.externalAuthValue can be listed in the new comma-separated users.passwords.externalAuthValue.previous setting, so accounts that still store an old marker can't log in with it. Recognize previously configured external-login markers #364 makes the same change on master, since Don't match the external-login placeholder as a password #304 had already merged.
  • BCrypt treats some other passwords as equal to a marker, so after the delegate encoder matches, the encoder also checks the current, default and previous markers against the stored value and refuses the password if one matches.
  • A missing or empty stored password answers false instead of reaching DelegatingPasswordEncoder, which throws for it.
  • A login refused because the password is a marker is logged at info level, without the password. roller.properties says that a marker containing a comma can't be listed and which accounts need an administrator to set a new password, and Roller warns at startup when the configured marker contains a comma.
  • Registering without a password outside db mode shows a validation result instead of an error page.
  • Remember-me uses the same placeholder as everything else, with no change under the default configuration.

This line builds for Java 11, so the wrapper is a class rather than the record #304 uses, and RollerContext.encoder is now typed as PasswordEncoder.

ExternalLoginAwarePasswordEncoderTest, ExternalLoginPlaceholderTest and ExternalLoginMarkerPasswordTest cover the placeholder encoded and unencoded, the default under another configured value, previous markers in the list and in the three password forms, a password that BCrypt treats as equal to a marker, an empty or missing stored password, and ordinary passwords that still work.

Users who log in through LDAP or the servlet container have users.passwords.externalAuthValue stored in place of a Roller password. Roller's password encoder no longer matches that placeholder, so it isn't treated as a password anywhere the encoder checks one.

@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 97851146f: The wrapper covers the password checks that use RollerContext’s encoder. Two marker edge cases need attention, and this PR lacks the provider-level test present in #304.

…match an empty one

Registration, the profile page and the admin user editor now reject users.passwords.externalAuthValue, and the default <externalAuth>, as a new password with a validation message, since that value never matches at login. An account that already has it can be given a new password by an administrator. An empty configured value now falls back to <externalAuth> for what Roller stores, and the password encoder never matches an empty password or the default placeholder.
@mraible

mraible commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

A second review raised a few more points, now addressed in the latest commits:

  • The encoder and the forms now also refuse the default "" whatever value is configured, so accounts stored before the setting changed can't use it either.

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

Reviewed current head 2537a6d. The stored-marker check has a conditional authentication bypass when the configured marker uses a supported password-encoder prefix.

…ember-me

Registering without a password outside db mode no longer throws a NullPointerException when the passwords are compared.

The remember-me signature for LDAP users now takes its placeholder from ExternalLoginAwarePasswordEncoder.externalLoginMarker(), so an empty users.passwords.externalAuthValue means the default there as it does everywhere else. With the default configuration the value is unchanged, so existing remember-me cookies stay valid.

The tests now restore WebloggerConfig properties even when user teardown fails or the original value was not set, and put back the password encoder that RollerContext shares.

@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 d984431e6: The current 6.1.x diff covers the earlier review points, including production encoder wiring and a provider-level test. The twin has the corresponding fix; its encoder location and test structure differ with the branch. One configuration-change case remains.

Earlier comments: 4 of 4 resolved.

Accounts created before users.passwords.externalAuthValue changed still have the old marker stored, encoded or not, and the encoder only recognized the current marker and the default, so the old marker matched at login. The new users.passwords.externalAuthValue.previous setting lists earlier markers, which are refused at login and can't be chosen as passwords, the same as the current one. Empty entries are ignored so an empty password never counts as a marker.
…rker

BCrypt gives some passwords other than a marker the same hash as the marker, so an exact comparison with the marker isn't enough to keep it from matching. After the delegate matches, the encoder now also checks whether the current, default or a previous marker matches the stored value, and refuses the password if one does. The marker list is read once per check.
DelegatingPasswordEncoder throws for a stored value without an encoder prefix when no lazy-upgrade encoder is configured, and for a null value, so such an account ended the login with an exception instead of bad credentials. The encoder now answers false for them.
An account whose real password equals the current, default or a previous marker can't log in, and until now the log didn't say why. The encoder now logs an info line for that refusal, without the password, so an administrator can tell it from a wrong password and set a new one.
The list is comma-separated, so a marker that contains a comma can't be listed there. roller.properties now says so, along with the accounts that need an administrator to set a new password. Roller also logs a warning at startup when the configured marker contains a comma.
…coder

ExternalLoginMarkerPasswordTest now checks that registration, the profile page and user administration refuse a marker listed in users.passwords.externalAuthValue.previous, and its tearDown restores the configuration in a finally block. The provider tests for previous markers also check the encoder directly, and the list test covers spaces around an entry.
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