Skip to content

Bundle-aware private media serving#525

Merged
MaciekBaron merged 29 commits intomainfrom
CMS-1037-previewer-aware-asset-acls
Apr 21, 2026
Merged

Bundle-aware private media serving#525
MaciekBaron merged 29 commits intomainfrom
CMS-1037-previewer-aware-asset-acls

Conversation

@zerolab
Copy link
Copy Markdown
Contributor

@zerolab zerolab commented Mar 6, 2026

What is the context of this PR?

This enables previewers to view private media when previewing content in a bundle

How to review

  • create two preview teams
  • create one or more pages (information, statistical article) that with newly uploaded images and docs (1x image, 1x doc, new for each page)
  • submit the page(s) for review
  • add a new bundle, add the page(s), add one of the teams, and save the bundle for review
  • log in with a reviewer from the bundle team - you should be able to view the assets. Make a note of their URLs.
  • log in with a reviwer that is not in the bundle team, try to access the asset URLs

Screencast

Follow-up Actions

List any follow-up actions (if applicable), like needed documentation updates or additional testing.

@zerolab zerolab changed the title Cms 1037 previewer aware asset acls Previewer-aware private media serving Mar 6, 2026
@zerolab zerolab added the component: Bundles Everything for bundled publishing label Mar 6, 2026
Comment thread cms/bundles/views/preview.py Outdated
@zerolab zerolab marked this pull request as ready for review March 9, 2026 10:42
@zerolab zerolab requested a review from a team as a code owner March 9, 2026 10:42
@zerolab zerolab changed the title Previewer-aware private media serving Bundle-aware private media serving Mar 9, 2026
@sanjeevz3009 sanjeevz3009 self-requested a review March 9, 2026 21:23
Comment thread cms/private_media/utils.py Outdated
Comment thread cms/private_media/utils.py Outdated
Comment thread cms/private_media/utils.py Outdated
Comment thread cms/bundles/views/preview.py Outdated
Comment thread cms/private_media/utils.py Outdated
Copy link
Copy Markdown
Contributor

@AdamHawtin AdamHawtin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing this locally I can see it working as expected with draft, never published pages in bundle preview. However, when I add an image to an already live page and add that update page to a bundle, it's still not showing to the previewer and raising PermissionDenied. In debug I can see that the referencing_pages queryset is coming back empty for the already live pages.

@zerolab
Copy link
Copy Markdown
Contributor Author

zerolab commented Mar 10, 2026

Testing this locally I can see it working as expected with draft, never published pages in bundle preview. However, when I add an image to an already live page and add that update page to a bundle, it's still not showing to the previewer and raising PermissionDenied. In debug I can see that the referencing_pages queryset is coming back empty for the already live pages.

@AdamHawtin 567daae

That hit a limitation of the reference index

Comment thread cms/jinja2/templates/components/streamfield/image_block.html
Comment thread cms/jinja2/templates/components/streamfield/image_block.html
Comment thread cms/jinja2/templates/components/streamfield/image_block.html Outdated
Copy link
Copy Markdown
Contributor

@sanjeevz3009 sanjeevz3009 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good so far. Will do another round of review later today.

Comment thread cms/private_media/utils.py Outdated
Comment thread cms/private_media/utils.py Outdated
Comment thread cms/private_media/utils.py Outdated
Comment thread cms/private_media/utils.py Outdated
Comment thread cms/jinja2/templates/components/streamfield/image_block.html
Comment thread cms/private_media/utils.py Outdated
Copy link
Copy Markdown
Contributor

@AdamHawtin AdamHawtin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Copy link
Copy Markdown
Contributor

@MebinAbraham MebinAbraham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly all are working as expected, some minor comments and an edge case that needs further consideration.

Comment thread cms/private_media/utils.py Outdated
Comment thread cms/private_media/utils.py Outdated
Comment thread cms/private_media/utils.py Outdated
Comment thread cms/private_media/utils.py
Comment thread cms/bundles/views/preview.py Outdated
Comment thread cms/private_media/tests/test_serve_views.py Outdated
Comment thread cms/private_media/views.py Outdated
Comment thread cms/private_media/utils.py Outdated
Comment thread cms/private_media/utils.py Outdated
Comment thread cms/bundles/views/preview.py Outdated
@zerolab zerolab requested a review from MebinAbraham March 13, 2026 11:39
Comment thread cms/core/models/base.py
Comment thread cms/private_media/utils.py Outdated
Comment thread cms/private_media/utils.py
Comment thread cms/private_media/utils.py Outdated
Comment thread cms/bundles/views/preview.py Outdated
@BJacksonONS
Copy link
Copy Markdown
Contributor

@MaciekBaron I'm having issues where the access cookie isn't getting set properly in safari. First thought it was part of the tracking and fingerprinting protection in private browsing but seems to be occurring in regular browsing mode too.

Can't replicate on other browsers though.

@BJacksonONS
Copy link
Copy Markdown
Contributor

@MaciekBaron I'm having issues where the access cookie isn't getting set properly in safari. First thought it was part of the tracking and fingerprinting protection in private browsing but seems to be occurring in regular browsing mode too.

Can't replicate on other browsers though.

Sorry wasn't super familiar with Safari, turns out it doesn't set 'Secure' cookies on localhost.

Copy link
Copy Markdown
Contributor

@BJacksonONS BJacksonONS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

Comment thread cms/private_media/utils.py Outdated
Copy link
Copy Markdown
Contributor

@MebinAbraham MebinAbraham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

Comment thread cms/private_media/utils.py Outdated
Comment thread cms/private_media/utils.py Outdated
@MebinAbraham MebinAbraham added the component: Previews Relevant for release previewing label Apr 16, 2026
Comment thread cms/bundles/views/preview.py
Comment thread cms/bundles/views/preview.py
Comment thread cms/private_media/utils.py Outdated
@BJacksonONS
Copy link
Copy Markdown
Contributor

Re tested with the newest changes.

Rate limiting worked when I set it to a lower value. Wasn't able to hit 20 entries even when intentionally navigating as quickly as I could between pages on a bundle of 21, so think the current default is reasonable.

Comment thread cms/core/models/base.py Outdated
Comment thread cms/private_media/utils.py Outdated
MaciekBaron and others added 3 commits April 21, 2026 09:15
Co-authored-by: Mebin Abraham <35296336+MebinAbraham@users.noreply.github.com>
Co-authored-by: Mebin Abraham <35296336+MebinAbraham@users.noreply.github.com>
@MaciekBaron MaciekBaron merged commit 6e17401 into main Apr 21, 2026
18 checks passed
@MaciekBaron MaciekBaron deleted the CMS-1037-previewer-aware-asset-acls branch April 21, 2026 08:46
Copy link
Copy Markdown
Contributor

@sanjeevz3009 sanjeevz3009 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: Bundles Everything for bundled publishing component: Previews Relevant for release previewing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants