Repository navigation
feat(core)!: reads fail closed: no context reads as public, no ambient session (2c) - #30
Conversation
|
Important Review skippedToo many files! This PR contains 159 files, which is 9 over the limit of 150. To get a review, reduce the PR to 150 files or fewer by splitting it into smaller PRs or changing its base branch. Upgrade to a paid plan to raise the limit. This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry.
|
🦋 Changeset detectedLatest commit: 62bd8c6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
a9287ec to
c00ad35
Compare
f70436c to
a2c8059
Compare
c00ad35 to
62bd8c6
Compare
Implements cms-refactor-plan.md § Phase 2c (item 4, "Access context for reads"). It also covers the revision-log rulings of 2026-11-05 on the slug-read leak, the populate
publicReadquirk and the preview-token redaction quirk.Merge chain: step 15 of 24. Base:
main. Merge it right after #37. The branch ismain3b4a112, then one commit for each PR before this one in the merge order, then this PR's own commitc00ad35(tree5113fbb).What
@tanstack/cms-core/serverare@deprecatedand now read aspublicContext(): published documents only, redacted for an anonymous visitor. Before, they read everything, drafts included. Phase 6 removes them.session,publishedOnlyandpublicReadare gone from every read verb and fromcreateCmsSearch, which takesaccessinstead.runWithSessionandcurrentSessionare removed.runOp,cmsMcp.fetchandcmsToolsrequire a context and throwUNAUTHORIZEDwithout one.afterChange/afterDeletehooks receive the writer'ssession.'redirect lookup'and'revision restore', so every bypass says why it exists. The sitemap reads as public.null, as a missing one would.publicRead.search_documentstakesmode(live,previeworedit) instead ofpublishedOnly. It can only narrow the caller's access, never widen it.pnpm codemod access-context, with 7 fixtures, rewrites deprecated reads to the…As(ctx, …)form. It warns onrunWithSession/currentSession, which need rewriting by hand.publicContext(). This fixes real draft leaks in db-markdown and in several starters' public ops:searchVersionedDocs,searchDirectoryListings,addToCart,readPublicationIssueand the lesson lookup.uploadMediarelied on the ambient session to attribute uploads. It now passes the caller's session.runWithSession/currentSessionmarkers are retired..changeset/access-fail-closed.md, breaking, for core, api, cli and search-cms.Breaking changes
pnpm codemod access-context, then give eachsystemContextit adds a real reason.session/publishedOnly/publicReadread options,runWithSessionandcurrentSession.search_documents:publishedOnlybecomesmode.resolveSession()without a request resolves as a request with no credentials.atproto publishreports "No published document" for drafts.Assumptions (tasks 8–12 defaults)
edit. Visitors getlivethroughpublicContext()orgetCmsAccessContext().Divergence from plan
runWithSession/currentSession.session, not a write context, because writes are phase 5.runOp's target lookup, admin ops that check their own results, media usage and translation links.app/basekeeps itspostReadaccess hook. Its scoped-session tests depend on it.systemContext.How verified
publicRead;runOp/cmsToolsrefusing a call without a context;search_documentsandnarrowModeonly narrowing.pnpm test:scripts.pnpm test:pr: passes on all 174 tasks except thecms-apioxlint error thatmainalready has.app/base42 andapp/prm9.test:dtsandtest:dialects: pass.Merge chain (local verification, CI down)
This PR's commits are squashed into one commit on the linear merge chain. That commit holds this PR's own changes, resolved against every PR before it, with the integration rehearsal's fixes for this PR applied.
18 files conflicted, and I resolved them as on the integration rehearsal.
ops.ts,review.tsandwrite.tstake #40's merge resolution (32d8e18), minus #40's own write-actions (3a) changes.Three changes had no textual conflict but were still needed:
app/base/src/collection-runtime.ts(feat(core)!: split plugins and app configs into a definition and a runtime #25's file) reads the session from the hook arguments instead of callingcurrentSession().executeStrategyWritepasses the session torunAfterChangeandrunAfterDelete.act-on-changeanddocument-statetests read withreadDocumentAs(systemContext('test'), …).This PR's upgrading section is step 25, and the link to it is updated.
The chain tip's tree is exactly the integration rehearsal plus #46 (
c4e6d7c), and the tip passes the full local suite. I simulated merging every PR in order, with a merge commit or a fast-forward at each step, and every step is clean. A plain squash of the next PR would conflict, because the squash commit isn't an ancestor of the next branch. To squash instead, first rebase the branch's one commit onto the newmain; that rebase is always clean.