Skip to content

End a user's other sessions when their password changes or their account is disabled - #333

Open
mraible wants to merge 9 commits into
roller-6.1.xfrom
end-sessions-on-password-change-6.1.x
Open

mraible wants to merge 9 commits into
roller-6.1.xfrom
end-sessions-on-password-change-6.1.x

Conversation

@mraible

@mraible mraible commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

The 6.1.x version of #321, including its later changes (passivated sessions, OpenID profile saves). Stacked on #306, so merge #306 first; until then this PR's diff includes its commits. Profile and UserEdit implement ServletRequestAware here, as Register does, and the session tracks the Roller user name, so OpenID logins are covered.

PasswordChangeSessionTest (including OpenID and passivated sessions): five of the original six cases fail without the change. mvn test passes, and the Selenium integration tests pass.

CHANGES entries for the 6.1.8 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. It applies to form, remember-me and OpenID logins alike, since the session tracks the Roller user name rather than the principal.

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. Both actions now receive the servlet request through ServletRequestAware, as Register already does.

(cherry picked from commit 32d476c)

@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 f3cb29a8f: The fix matches #321, with the expected Java 11, javax, Struts 2, and OpenID differences. One normal-use regression remains in OpenID configurations. This was a read-only review; no build was run.

…thout a sign-in change

Profile.save and UserEdit.save generated a new random stored password for OpenID 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 OpenID 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.
…password-change-6.1.x

# 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