Skip to content

feat(cms): add public read access and draft mode support - #35

Merged
ASPactores merged 4 commits into
mainfrom
15-cms-migrate-setup-cms-api-client-type-sync-draft-mode
Aug 20, 2026
Merged

feat(cms): add public read access and draft mode support#35
ASPactores merged 4 commits into
mainfrom
15-cms-migrate-setup-cms-api-client-type-sync-draft-mode

Conversation

@jlorion

@jlorion jlorion commented Jul 27, 2026

Copy link
Copy Markdown
Member

📝 Overview

What does this PR do? Briefly describe the changes and the goal of this PR.

🚀 Type of Change

  • 🐛 Bug Fix: Fixed something that was broken.
  • New Feature: Added new functionality or pages.
  • 🗄️ CMS / Database: Updated collections, fields, or config in Payload CMS.
  • 🧹 Chore / Clean up: Text updates, typos, or code cleanup.

🧱 CMS & Database Changes

Skip this section if no CMS or database changes were made.

  • Migration Created: Ran payload migrate:create and saved the file.
  • Local Verification: Verified changes in the local admin panel.

📊 Data Structure

Describe the new fields/tables or drag-and-drop a screenshot here:


🧪 Testing & Validation

  • Test Case Approval: Verified that test cases were commented on the assigned GitHub issue and approved by the Project Lead before development started.
  • Unit Tests: Added or updated unit test scripts covering the new logic.
  • Admin Panel: Verified behavior in the CMS Admin UI.
  • API Check: Tested REST/GraphQL endpoints for correct data.

📸 Visual Evidence (Mandatory)

Important

Visual proof is required to demonstrate that the approved test cases from the issue were successfully met.
Please provide screenshots, screen recordings (GIFs/Videos), or sample API outputs proving that the feature satisfies all approved test cases and do not introduce regressions.

cms client
image
type sync
image
collection with draft
{DAF6804A-7EE3-4CC9-AAC6-2B46AE1E645B}
collection without draft
{4C9F49BF-83C8-48A3-B1A5-EF3BFCBAB5FD}


📋 Final Checklist

  • Sync: Rebased from main and resolved conflicts.
  • Pre-commit: Installed and ran pre-commit hooks successfully.
  • Security: Verified no secrets or local credentials are included.
  • Build: Project builds without errors.
  • Visuals: Attached mandatory visual evidence proving all test cases passed.
  • Migrations: Migration script included (if applicable).

🧠 Extra Notes / Questions

Add any additional context or questions for the reviewers here.

@jlorion
jlorion requested a review from a team July 27, 2026 06:47
@jlorion jlorion linked an issue Jul 27, 2026 that may be closed by this pull request
@jlorion
jlorion requested review from ASPactores and seangaaab July 27, 2026 06:47
@jlorion jlorion self-assigned this Jul 27, 2026

@seangaaab seangaaab 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.

Please see comments @jlorion

Great job so far on your tasks! 💪 Thanks for stepping up and taking the initiative for adding these changes!

Comment thread src/access/anyone.ts

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.

@ASPactores Do you think we should add some sort of authorizer here to check the tokens?

Comment thread src/access/anyone.ts

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.

  • Provide a sample scenario or model where this access pattern will be used for.
  • Provide tests for this collection access function. Just provide screenshots that it works for unauthenticated

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.

Let's revisit this for endpoint once all models for the durianpy website CMS integration is done, so we can check if all types are generated properly

Comment thread src/access/anyone.ts

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.

If this is a needed change for the other tickets, then we can move this file change to a separate PR, or move the change for the endpoints/durianpy-website-types in another separate PR

jlorion and others added 3 commits August 18, 2026 01:28
- add `anyone` access control function with draft-token bypass
  for unpublished/draft documents
- generate and wire up CMS_DRAFT_SECRET_TOKEN for draft mode auth
- add custom /durianpy-website-types endpoint to sync only
  relevant collection types to the website repo
Extend the `anyone` access function to handle global reads, which
require a boolean return instead of a where clause. Detects global
requests via routeParams/pathname and gates access on the `draft`
query param so unpublished draft content isn't exposed to anonymous
requests.
@ASPactores
ASPactores force-pushed the 15-cms-migrate-setup-cms-api-client-type-sync-draft-mode branch from 11c90a9 to fa42c07 Compare August 18, 2026 11:22

@ASPactores ASPactores 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.

Kindly do:

git fetch origin
git checkout 15-cms-migrate-setup-cms-api-client-type-sync-draft-mode
git rebase origin/15-cms-migrate-setup-cms-api-client-type-sync-draft-mode -X ours

Then perform some tests to our API security. To do this, you may create a service account through the service account collection in the PayloadCMS admin console and then apply different combination of permissions to the service account. Sample curl request:

curl --location 'http://localhost:3000/api/durianpy-website-types' \
--header 'Authorization: service-accounts API-Key <generate one from the service account collection>'

You may perform this test case:
#57

@jlorion

@ASPactores
ASPactores self-requested a review August 20, 2026 14:17

@ASPactores ASPactores 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.

PR Looks good to me. Test passed based on #57. Thanks @jlorion

@ASPactores
ASPactores merged commit d5d452f into main Aug 20, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CMS-MIGRATE]: Setup CMS API Client, Type Sync, & Draft Mode

3 participants