Skip to content

Check publish permission, upload size, scheduling and author email in AtomPub - #316

Merged
mraible merged 4 commits into
masterfrom
atompub-permission-checks
Nov 20, 2026
Merged

mraible merged 4 commits into
masterfrom
atompub-permission-checks

Conversation

@mraible

@mraible mraible commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Four AtomPub (and some MetaWeblog and Blogger) changes:

  • Publish permission on update. An AtomPub entry update that would publish or schedule the entry now requires the POST permission, as the XML-RPC handlers already do, so a Limited member can still edit a draft through AtomPub but not publish it. A refused update answers 401, through the existing AtomNotAuthorizedException.
  • Upload size. Media uploads and replacements stop reading the body once it passes uploads.file.maxsize and answer 413, instead of writing the whole body to a temporary file before checking the size. The temporary file is closed on every path, including a refused upload.
  • Scheduled entries and tag counts. A future-dated entry is marked SCHEDULED before tag counts are updated, so its tags are counted once, when it goes live. JPAWeblogEntryManagerImpl decides SCHEDULED before updating tag aggregates too, and when a save moves an entry into or out of PUBLISHED, it works out the counts from the tags the entry had before the edit and the ones it has after, so unpublishing or scheduling an entry while changing its tags doesn't leave the old tags counted, and publishing a draft with new tags counts only those. AtomPub updates and the Blogger and MetaWeblog editPost handlers refresh tag counts when an edit publishes, unpublishes or schedules an entry, as the entry editor does. AtomPub no longer marks scheduled entries as drafts, so reading one and sending it back unchanged keeps it scheduled.
  • Author email. AtomPub entries and MetaWeblog post structs include the entry creator's email address only for the creator; other weblog members see the user name. Weblog email addresses and templates are unchanged.

Tests: EntryCollectionPermissionTest (new), plus cases in RollerAtomProtocolTest, MediaCollectionPathTest and XMLRPCWeblogPermissionTest, which also cover tag counts when an edit publishes, unpublishes or schedules an entry, a scheduled entry read and sent back through AtomPub, and the temporary file of a refused upload. Six of the original cases fail without the change. mvn test passes.

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

A further review pass added these fixes:

  • An AtomPub update that omits atom:published keeps the publish time of a published or scheduled entry, so a scheduled entry doesn't go live early and a published one isn't re-dated.
  • XML-RPC edits decide "scheduled" once, so tag counts stay right at the one-minute boundary, and MetaWeblog returns the author email to the creator whatever case they log in with.

… AtomPub

AtomPub entry updates now require the POST permission when the entry would be published or scheduled, matching the XML-RPC handlers, so a Limited member can still edit a draft through AtomPub but can't publish it.

Media uploads and replacements through AtomPub stop reading the body once it passes uploads.file.maxsize and answer 413, instead of writing the whole body to a temporary file before the size check.

A future-dated entry posted or updated through AtomPub is marked SCHEDULED before tag counts are updated, so its tags appear in the weblog's tag counts once, when it goes live. JPAWeblogEntryManagerImpl also decides SCHEDULED before updating tag aggregates, and AtomPub updates that move an entry into or out of PUBLISHED refresh the entry's tag counts like the entry editor does.

AtomPub entries and MetaWeblog post structs include the entry creator's email address only when the creator is the one asking; other weblog members see the user name.

@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 0fdc945a7: The twin carries the same fixes, with differences explained by the 6.1.x and master AtomPub implementations. Two tag-count paths remain incorrect; the new tests do not cover them.

When a save moves an entry into or out of PUBLISHED, JPAWeblogEntryManagerImpl now works out the tag counts from the tags the entry had before the edit and the ones it has after it. Unpublishing or scheduling an entry while removing or changing tags no longer leaves the old tags counted, and publishing a draft while changing its tags counts only the new ones.

AtomPub entries for scheduled posts are no longer marked as drafts, so reading a scheduled entry and sending it back unchanged keeps it scheduled.

The Blogger and MetaWeblog editPost handlers now ask for a tag count refresh when an edit publishes, unpublishes or schedules an entry, including an edit that moves a published entry to a future date.

AtomPub media uploads and replacements close the temporary file they read on every path, including when the upload is refused.
@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:

  • Also in 7630b52: AtomPub no longer marks a scheduled entry as a draft, so a GET followed by an unchanged PUT keeps it scheduled (scheduledEntryStaysScheduledThroughGetAndPut). Media uploads and replacements now close the temporary file's stream on every path, including when canSave() refuses the file (refusedMediaClosesItsTemporaryFile).

@mraible
mraible requested a review from snoopdave November 18, 2026 04:16
…b and XML-RPC edits

An AtomPub PUT with no atom:published now keeps the publish time of an entry that is already published or scheduled, so a retitled scheduled entry no longer goes live early and a published entry is no longer re-dated. A draft PUT of an entry that is waiting for review leaves it waiting for review instead of turning it into a draft.

The XML-RPC edit handlers now set SCHEDULED themselves when the publish time is more than a minute ahead, so the tag count decision and saveWeblogEntry() cannot disagree at the one-minute boundary. MetaWeblog getPost and getRecentPosts compare the entry's creator with the validated user's name rather than the login string, so the creator sees their own email whatever case they logged in with.

The refreshAggregatesIfPublicationChanges helper moves above editPost's Javadoc, and EntryCollectionPermissionTest no longer turns on webservices.enableAtomPub in the shared test database, which EntryCollection does not read.
A draft PUT of an entry that is waiting for review sets it to DRAFT again, as it did before the previous commit and as it does in every release. Save as Draft in the entry editor and publish=false in the XML-RPC handlers do the same, so the three ways to edit an entry agree. Keeping such an entry in the review queue is not needed for the permission checks this branch adds.

@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 ee094c01d: The current code addresses the earlier review points, and the tests cover the changed publication and tag-count paths. The twin PR has the same fixes; its implementation differences follow the AtomPub and servlet API differences between branches. This was a source review only; no build was run.

Earlier comments: 4 of 4 resolved.

No new issues found.

@mraible
mraible merged commit 27ec936 into master Nov 20, 2026
9 checks passed
@mraible
mraible deleted the atompub-permission-checks branch November 20, 2026 00:51
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