Skip to content

End a user's other sessions when their password changes or they're disabled - #321

Open
mraible wants to merge 12 commits into
masterfrom
end-sessions-on-password-change
Open

mraible wants to merge 12 commits into
masterfrom
end-sessions-on-password-change

Conversation

@mraible

@mraible mraible commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #343, which is stacked on #304, so merge #304 and #343 first; until then this PR's diff includes their commits.

When a user's password changes, by their own profile save or an administrator's edit, or the user is disabled, their other logged-in sessions now end on their next request to /roller-ui. The session that made the change stays logged in.

  • RollerSession keeps a SHA-256 digest of the user's stored password hash, set when the user is attached to the session. getRollerSession reloads the user (enabled users only), and if the user is gone or disabled or the digest no longer matches, it invalidates the HTTP session, clears Spring's SecurityContext and returns an empty RollerSession. A database error leaves the session alone.
  • The session also keeps the login's user name and password digest in a separate attribute that outlives the RollerSession. When the container passivates a session, RollerSession removes itself from it, and the next request used to rebuild it from the login with the user's current password; a rebuild for that user now ends the session when the password differs.
  • RollerSession.refreshPassword(request, user) updates the acting session's digest; Profile.save calls it, and UserEdit.save calls it when administrators edit themselves.
  • Profile.save and UserEdit.save used to generate a new random stored password for OIDC accounts on every save, which would now end the user's other sessions on a profile-only edit. They generate one only when the account has no stored password or its OpenID URL changes.
  • RollerLoginSessionManager.invalidate, which UserEdit already called, only cleared a cache entry, so the next request rebuilt the session from the Spring login.
  • No Spring Security configuration changes. Remember-me cookies already stop working after a password change, since their signature includes the stored hash.

Weblog page requests read the Spring login directly, so a preview in another browser keeps working until that browser next opens a /roller-ui page.

Tests: PasswordChangeSessionTest covers a user's own change, an administrator's reset, disabling a user, administrators changing their own password, an edit without a password change, profile and administrator edits of an OIDC account with another session open, switching an account to OpenID, and a passivated session with and without a password change. Four of the original five cases fail without the change. mvn test passes, and the Playwright database-login suite passes (20 run, 3 OIDC tests skipped).

CHANGES entries for this and the related fixes will come in one PR.

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.
…unt is disabled

RollerSession now keeps a SHA-256 digest of the user's stored password hash from when the session logged in. On each lookup it reloads the user and, if the user is gone, disabled, or has a different password hash, it invalidates the HTTP session, clears the Spring SecurityContext for the request, and continues with an empty session, so the browser has to log in again. The check runs before the session-cache check, which would otherwise rebuild the session from the existing login.

Profile.save and UserEdit.save (when an administrator edits their own account) refresh the digest of the session that made the change, so that session stays logged in.

@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 32d476caa: The session check covers the tested password-change and disable flows. I found one regression for OIDC users saving ordinary profile changes.

…out a sign-in change

Profile.save and UserEdit.save generated a new random stored password for OIDC accounts on every save, so with the session check a profile-only edit ended the user's other sessions. They now generate one only when the account has no stored password or its OpenID URL changes. PasswordChangeSessionTest covers a profile edit and an administrator edit of an OIDC account with another session open, and switching an account to OpenID.
…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.
…s dropped

When the container passivates a session, RollerSession removes itself from it, and the next request rebuilt it from the login with the user's current password, so the session survived a password change. The session now keeps the login's user name and password digest in a separate attribute that outlives the Roller session, and a rebuild for that user ends the session when the password differs. PasswordChangeSessionTest covers a passivated session after a password change and one without a change.
… 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.
…hange

# Conflicts:
#	app/src/main/java/org/apache/roller/weblogger/ui/struts2/admin/UserEdit.java
#	app/src/main/java/org/apache/roller/weblogger/ui/struts2/core/Profile.java
@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:

  • A session whose Roller session was dropped, as happens when the container passivates it, used to be rebuilt from the login with the new password. The session now keeps the login's user name and password digest beside the Roller session, so that rebuild ends the session if the password changed; PasswordChangeSessionTest covers a passivated session after a password change and one without a change.

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