Merge claude/security-c-1172: form submissions over REST only for staff, the job queue for an admin or Bearer CRON_SECRET, doctor visitor-writes
Conflicts with security-a-1172 kept both sides: imports (adminSameOrigin, jobsAccess), the doctor status (originKnown and visitorWrites), its test, and the e2e:built line (A's sign-in answers spec with C's CRON_SECRET). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -1231,6 +1231,40 @@ a root endpoint to the config and the check names it as "not judged".
|
||||
**In the plugin repository:** `pnpm routes:check` (`--update` after a Payload upgrade) on the reference site, also
|
||||
the first step of `pnpm e2e:built`; the test fixtures are switched off for it.
|
||||
|
||||
## Payload's job queue (`jobsRunAccess`, 1.17.2)
|
||||
|
||||
Payload runs its queue over HTTP at `GET /api/payload-jobs/run` and `/api/payload-jobs/handle-schedules`, checked by
|
||||
`jobs.access.run`. Payload's default is **any signed-in account of any auth collection** — a shop's customer could
|
||||
run the queue whenever they like. Since 1.17.2, when the project writes **no** `jobs.access.run`, iapl sets: an
|
||||
**admin signed in with the second factor** (an admin's API key counts), or **`Authorization: Bearer <CRON_SECRET>`**
|
||||
(16+ characters, compared in constant time). It is set even when the config has no `jobs` (Payload turns the queue on
|
||||
by itself for scheduled publishing). A route that does not exist (no tasks, no workflows) stays 404.
|
||||
|
||||
**A project with jobs keeps its cron working** — check which of these it uses:
|
||||
- jobs run **in-process** (`jobs.autoRun`, `pnpm payload jobs:run`, `payload.jobs.run()` in code): nothing changes;
|
||||
- a **Coolify scheduled task** (or any cron) that calls the run route: set `CRON_SECRET` in the app's environment and
|
||||
in the task, and send the header —
|
||||
`curl -fsS -H "Authorization: Bearer $CRON_SECRET" "$NEXT_PUBLIC_SERVER_URL/api/payload-jobs/run"`;
|
||||
- a cron that signs in with an **admin's API key**: works as before; with a **non-admin** account's key: switch to
|
||||
`CRON_SECRET`, or write your own rule;
|
||||
- the project's **own** `jobs.access.run`: always wins, nothing changes.
|
||||
At start, when the queue is on, the rule is iapl's and `CRON_SECRET` is missing or short, the log says so in one
|
||||
line. Overrides: `iapl({ jobsRunAccess: false })` keeps Payload's default; `{ secretVar: 'MY_VAR' }` reads another
|
||||
variable; `jobsRunAccess()` is exported to reuse in a rule of your own. Verify: without the header
|
||||
`/api/payload-jobs/run` answers 401, with it 200 (the closed-doors spec does both on the built reference site).
|
||||
|
||||
## Visitor accounts (customers, members) and Payload's default write rules
|
||||
|
||||
Payload fills every missing access rule with **"any signed-in account"** — an account of a visitor login collection
|
||||
included. The plugin narrows its own collections and globals and the staff accounts; **your** collections and
|
||||
globals are yours to rule. On a site that has (or may get) a visitor login collection, give every collection
|
||||
`create` / `update` / `delete` and every global `update` a rule of its own — the reference site and every new site
|
||||
from `iapl create` do (`adminOrEditor`, since 1.17.2). `iapl-doctor --url` (deep) lists what such an account may
|
||||
write (`visitor-writes`, warning), checked by behaviour: it asks every rule with a stand-in visitor account. Payload's
|
||||
own `payload-locked-documents` (who edits which document) also runs on Payload's default and is listed there; a
|
||||
plugin-wide default for it is planned for 2.0. Verify: the doctor shows no `visitor-writes` finding, and the
|
||||
closed-doors spec's customer gets 403 on every write door.
|
||||
|
||||
## Turn off, override, extend
|
||||
|
||||
- **Stored secrets:** `secrets: { writeOnly: false }`, `secrets: { reenterOnChange: false }`; `writeOnlySecret` /
|
||||
|
||||
Reference in New Issue
Block a user