Skip to content

Keep the OIDC identity off account forms, protect weblog admins, and limit search queries - #322

Open
mraible wants to merge 20 commits into
masterfrom
account-and-search-hardening
Open

mraible wants to merge 20 commits into
masterfrom
account-and-search-hardening

Conversation

@mraible

@mraible mraible commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Four smaller fixes:

  • OIDC identity on the profile and registration forms. Profile.save keeps the stored openIdUrl (the OIDC issuer#sub Roller uses to find an account at OIDC login), ProfileBean.copyTo no longer writes it, Register.save no longer takes it from the form, and the hidden field is gone from Profile.jsp. Only Roller's OIDC code sets it now. Admin UserEdit is unchanged. Test: FederatedIdentityFormTest.
  • Weblog membership. Declining an invitation only removes a pending permission, and a weblog's only administrator can't resign from it (new message yourWebsites.resign.lastAdmin). Resigning redirects to the main menu and keeps its messages across the redirect with the store interceptor, as accept and decline do; the chain result it used dropped them on Struts 7. Test: MemberResignResultTest, which runs the action through the Struts dispatcher. Resigning and saving the Members page go through a new UserManager.updateWeblogMembership(), which locks the weblog's row, reads its memberships again and applies the changes in the same transaction only if an enabled administrator remains, so concurrent changes run one after the other and can't leave a weblog without an administrator, and a disabled user with ADMIN doesn't count as one. It checks that each change is for a member or invitee before taking the lock, and reports a database error from the lock as a WebloggerException. Removing a weblog or a user also removes its pending invitations, so a weblog or user created later with the same name doesn't inherit them. Tests: WeblogMembershipTest, new cases in PermissionTest.
  • LDAP comment authenticator. The commenter's user name is escaped with javax.naming.ldap.Rdn.escapeValue before it goes into the bind DN. Test: new cases in LdapCommentAuthenticatorTest.
  • Search. The search query (q) is capped at 256 characters, without splitting a surrogate pair, in search and feed requests. Surrounding whitespace doesn't count toward the cap. When the cap ends inside a quoted phrase, that phrase's opening quote is dropped (escaped quotes don't count), and an escape character whose escaped character is cut off is dropped, so the rest of the query still parses. SearchOperation treats the exceptions Lucene throws for a query it can't run (IllegalArgumentException, TooManyClauses, TooComplexToDeterminizeException) like a query that doesn't parse: no results, logged at debug. Other failures are logged as errors, as before. Tests: SearchMalformedQueryTest, SearchQueryLengthTest.

The targeted membership, resign and search tests pass; CI runs the full build and the Playwright suite.

The existing CHANGES entries now also say that the main menu shows the outcome of resigning, what declining an accepted invitation does, and that spaces around a search query are dropped.

A further review pass added these fixes:

  • A weblog can be removed, and its members changed, when a member or invited user has been disabled. The Members page no longer fails to save on such a weblog.
  • The profile form rejects a mismatched password confirmation even when the account has a stored federated identity.
  • The Members page shows no "Removed" or "Changed" count when the save fails.
  • Declining an invitation that was already accepted says you're already a member (new message yourWebsites.declineMember) instead of saying the invitation was revoked.
  • Resigning now goes through the same weblog and permission checks as the other editor actions (MemberResign no longer overrides isWeblogRequired()), so a missing weblog or a user who isn't a member gets the access denied page.

The profile and registration forms no longer set User.openIdUrl, which holds the issuer#subject that an OIDC login uses to find its account. Only Roller's OIDC login code sets it. Profile.save uses the stored value for its checks, whatever the request carries, so OIDC and DB_OIDC users still save their profiles; Register ignores it; and the profile page no longer posts it as a hidden field.
…resigning

Declining a weblog invitation now removes the permission only while it is still pending, so it can no longer remove an accepted membership. Resigning from a weblog is refused, with a message, when the user is the weblog's only admin; pending invitations do not count as another admin.
…bind name

LdapCommentAuthenticator now escapes the submitted user name with Rdn.escapeValue before putting it in the uid part of the bind DN, so characters such as commas, plus signs and equals signs stay part of the user name.
…ing nothing

WeblogSearchRequest and WeblogFeedRequest now keep only the first 256 characters of the q parameter, without splitting a surrogate pair. SearchOperation now catches runtime exceptions that Lucene throws for queries that parse but cannot be built or run, such as an unfinished regular expression or a negative phrase slop. It logs them as a warning and handles them the same way as a query that does not parse.

@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 e153a6961: The shared fix hunks match #334; the differences are explained by master’s OIDC code and the javax/jakarta split. One membership consistency gap remains.

…ed operation

Resigning from a weblog and saving the Members page now go through UserManager.updateWeblogMembership(), which locks the weblog's row, reads its memberships again, and applies the changes in the same transaction only if an enabled administrator remains. Concurrent membership changes for a weblog therefore run one after the other and can't leave it without an administrator, and a disabled user who holds ADMIN no longer counts as one.
Removing a weblog or a user now also removes its pending invitations, so a weblog or user created later with the same name doesn't inherit them.
When the 256-character limit ends inside a quoted phrase, the search and feed requests now drop that phrase's opening quote, so the rest of the query still parses and finds entries instead of nothing.
@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 disabled user who holds ADMIN no longer counts as the weblog's remaining administrator when resigning or saving members, covered by a new WeblogMembershipTest case.
  • Removing a weblog or a user now also removes its pending invitations, so a weblog or user created again with the same name starts without them; PermissionTest covers both.
  • When the 256-character limit cuts a quoted phrase, the search request now drops that phrase's opening quote so the rest of the query still parses; a query Lucene can't parse was already caught and finds nothing. SearchQueryLengthTest covers both a cut and an intact phrase.
  • No change here for DB_OIDC profile saves: replacing the stored password of an account with a federated identity predates this PR, which only takes that identity from the stored user instead of the form, and keeping the stored password on Profile and UserEdit saves is handled in End a user's other sessions when their password changes or they're disabled #321.

@mraible
mraible requested a review from snoopdave November 18, 2026 04:16
Removing a weblog now deletes its permission rows directly, so a member or invited user who has since been disabled no longer stops the removal with a NullPointerException.

updateWeblogMembership changes the permission rows it read under the lock instead of revoking and granting through the user, which works for disabled members. A pending invitation whose role changes still stays pending, and a test now covers that. It also fails with "permission not found" when a change names a user who has no membership or invitation, so resigning from a weblog you don't belong to reports an error again rather than success.

The Members page skips rows for disabled members when saving, since the form has no field that can address them, instead of failing every save on that weblog.

The profile form checks that the password and its confirmation match whether or not the account has a stored federated identity.

@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 15d380310: The shared fix hunks match #334. This PR also handles quoted queries cut at the length limit and includes the OIDC form changes specific to master. One membership-page gap remains.

Earlier comments: 5 of 5 resolved.

The Members page named each row's radio buttons after the member's user id, which it got through WeblogPermission.getUser(). That lookup only finds enabled users, so a disabled member's row rendered with a blank name and a field the save could not match, and an admin could not remove the member or change their role.

Each row is now keyed by its permission id and shows the user name stored on the permission, so save() no longer needs to look up the user. New page tests remove a disabled member and change a disabled member's role.
…hardening

# Conflicts:
#	app/src/main/java/org/apache/roller/weblogger/ui/struts2/core/Profile.java
updateWeblogMembership() now checks that every change is for a member of, or a user invited to, the weblog before it takes the weblog's row lock, and checks again once the lock is held. A request to resign from a weblog the user doesn't belong to now fails straight away instead of waiting for, and then holding, the lock.

A database error while taking the lock or reading the memberships is reported as a WebloggerException, so the Members and Resign pages show their usual error message.
Members.save() counted the removals and changes while building the update, so a failed save showed "Removed 1 user(s)" next to "Error saving permissions". The counts are now cleared when the save fails.
Resigning chained to the main menu, which didn't carry over the action's messages, so neither "You have resigned" nor the refusal for a weblog's only admin was shown. Resigning now redirects to the main menu and keeps its messages across the redirect, as accepting and declining an invitation do. The redirect also ends the request as soon as the change is made or refused.

Resigning with a weblog handle that doesn't exist now shows the access denied page instead of failing with an error.
…tespace

The search query limit now skips an escaped quote when it looks for a phrase that the limit cuts off, and drops an escape character whose escaped character is cut off, so the capped query still parses. Leading and trailing whitespace is stripped before the limit is applied, so a query padded with spaces keeps its search terms.
The search operation caught every runtime exception as a query Lucene couldn't run and logged it as a one-line warning. It now catches only the exceptions Lucene throws for such queries and logs them at debug level, like a query that doesn't parse. Other failures, such as an index that can't be opened, are logged as errors with their stack trace again.
…y a member

A main menu page loaded before an invitation was accepted still offers to decline it. Declining then said that the invitation was just revoked and logged an error with a stack trace. It now says that the user is already a member of the weblog and can resign to leave it.
The membership tests no longer revoke memberships before removing the weblog, since removing it now removes its invitations too. The permission test's cleanup revokes only memberships that are still there, so it can't hide the original failure, and the federated identity test restores the password encoder and configuration even when removing its users fails. A comment about the stand-in password encoder now gives the reason it's needed.
The resign action skipped the interceptor's weblog and permission checks, so a user could post a resignation for any weblog. It now needs the weblog and the member's permission like the other editor actions, and the tests run the missing-weblog and non-member cases through Struts.
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