Repository navigation
test(access): pin the client queue path, and apply the guard at the third buildConfig site - #858
Conversation
…s to API clients Payload appends payload-jobs, payload-jobs-stats, payload-locked-documents, payload-preferences, payload-migrations and payload-kv after every plugin has run, so accessPlugin never saw them, and most kept Boolean(user) access. A published client key could queue or rewrite jobs, call /api/payload-jobs/run, overwrite the job-stats global, create document locks, and PATCH another user's preference row into its own. jobs.access (run/queue/cancel) had the same default. restrictPayloadSystemEntities sets their access on the sanitized config, at both buildConfig call sites: admins only for jobs, migrations, job stats and jobs.access; active managers for locks; managers' own rows for preferences, including the /:key endpoints that skip access. An unlisted payload-* entity defaults to admins only. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`seeds/tests/test-payload.config.ts` is a third `buildConfig` call site and did not apply `restrictPayloadSystemEntities`, while the docblock and docs/rules/access.md both said there were two. Harmless today — that config registers no plugins and is never served — but the rule is enforced by prose alone, so the prose has to be right. A wrapper owning `buildConfig(...).then(...)` would not close this: a fourth site can still call `buildConfig` directly. Naming the sites and the grep is what a reader can act on. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Tk5jpo777wbp6Vqqi7EnNR
`jobs.access.queue` is admin-only now, and the one production path that queues a job — `enqueueSubmissionScreening` — forwards the submitting client's `req` with no `overrideAccess`. Every Atlas and app form submission therefore rests on Payload defaulting `overrideAccess` to `true`, a library internal no spec named. The case posts a contact submission over REST with a published `sahaj-atlas-client` key and asserts the `screenSubmission` job row appears. Reintroducing the defect (`overrideAccess: false` in the hook) fails this case and only this case. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Tk5jpo777wbp6Vqqi7EnNR
`payload-jobs` and `payload-migrations` map to the same policy the `??` fallback already supplies, so a reader cannot tell whether the entries are load-bearing or leftovers. They are the inventory of what Payload ships today; the fallback is for what a future version adds. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Tk5jpo777wbp6Vqqi7EnNR
|
🚅 Deployed to the SahajCloud-pr-858 environment in sahajcloud
1 service not affected by this PR
|
#857 squash-landed as c6511bc, so this branch's copy of its commit shares no ancestry with main's and every file it added came back as an add/add. main's `systemEntities.ts` and `payload-system-access.int.spec.ts` are byte-identical to this branch's base, so taking this side loses nothing — it is that same content plus the three commits here. `docs/rules/access.md` conflicted on the one line #858 rewrites ("both call sites" to "every call site"); main's side was the pre-#858 wording. #853's edit to that file elsewhere merged clean and is kept. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01D33Z68cuaxB8VpGSwhgkjY
|
Merged Took this side on all three hunks. Main's Re-ran the grep the new docblock cites: still three real Lean gate green, 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Stacked on #857, targeting its branch. Adopts two review threads there. One commit each.
jobs.access.queueis admin-only, and the intake path is a client'senqueueSubmissionScreeningforwards the submitting client'sreqwith nooverrideAccess, so every Atlas and app form submission rests on Payload defaulting it totrue(payload/dist/queues/localAPI.js:args?.overrideAccess !== false). That default is a library internal, and no spec named it.payload-system-access.int.spec.tsgains one case: a contact submission posted over REST with a publishedsahaj-atlas-clientkey, asserting thescreenSubmissionjob row appears. Reintroducing the defect —overrideAccess: falsein the hook — fails that case and only that case.The existing
user-submissions-createspec does exercise the path today, since every create there starts atpendingand fires the hook. It just fails opaquely, and names nothing.The third
buildConfigcall siteseeds/tests/test-payload.config.tsalso callsbuildConfigand did not applyrestrictPayloadSystemEntities, while the docblock anddocs/rules/access.mdboth said there were two sites. Harmless today — no plugins, never served — but prose is the only enforcement, so it now names three and the grep that counts them.A wrapper owning
buildConfig(...).then(restrictPayloadSystemEntities)was considered and rejected: a fourth site can still callbuildConfigdirectly, so the wrapper moves the coupling without closing it.Third commit answers the fourth thread: a line saying the
SYSTEM_COLLECTIONStable is the inventory, not a rule the??fallback would already supply.Verification
npx tsc --noEmitand-p tsconfig.test.jsonclean,eslintclean on the changed files,payload-system-access.int.spec.ts15 passed.Not run here: the full unit lane and
pnpm build. CI covers both.🤖 Generated with Claude Code
https://claude.ai/code/session_01Tk5jpo777wbp6Vqqi7EnNR
Generated by Claude Code