Security follow-ups to 1.16.7: changelog, access guide, skills, API table, release gate, reference index

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-25 02:59:44 +01:00
co-authored by Claude Fable 5.2
parent be2e6d52d9
commit ccc6f85924
15 changed files with 183 additions and 21 deletions
+42 -5
View File
@@ -93,9 +93,10 @@ try {
}
/**
* Smoke tests against a built, seeded site: pnpm build && pnpm seed && pnpm payload run e2e/create-test-admin.ts.
* Run create-test-admin.ts again before repeating the tests within ten minutes: the 2FA verify limit (5 attempts per
* account in 10 minutes) is stored in the database, and that script clears the test admins' counts.
* Smoke tests against a built, seeded site: pnpm seed && pnpm build.
* The 2FA verify limit (5 attempts per account in 10 minutes) is stored in the database; the global setup resets the
* test admins and clears their counts before every run (e2e/global-setup.ts; E2E_SKIP_ADMIN_SETUP=1 for a run that
* needs an EMPTY database, the fresh-site spec).
* E2E_BASE_URL picks the port (default 3100). Playwright starts its own server there and fails when the port is
* taken, so another project's dev server is never tested by mistake; E2E_REUSE_SERVER=1 uses a server you started.
*/
@@ -103,6 +104,8 @@ const baseURL = process.env.E2E_BASE_URL ?? 'http://localhost:3100'
export default defineConfig({
forbidOnly: !!process.env.CI,
// makes every run independent of the one before: test admins reset, stored 2FA attempt counts cleared
globalSetup: './e2e/global-setup.ts',
projects: [{ name: 'chromium', use: { ...devices['Desktop Chrome'] } }],
reporter: process.env.CI ? 'line' : 'list',
retries: process.env.CI ? 1 : 0,
@@ -1160,14 +1163,34 @@ Rules: AGENT.md §8a.
| File | What it shows |
|---|---|
| `e2e/create-test-admin.ts` | two test admins with a known TOTP secret (the specs share out the five 2FA verify attempts per account), their stored verify counts cleared, and e-mail sending pointed at the tests' mail sink (local / CI database only) |
| `e2e/late-staff-fixture.ts` | test fixture, on only with E2E_LATE_STAFF=1: a plugin listed after ipalKit that adds a staff collection without rules and a visitor collection with open sign-up (below) |
| `e2e/late-staff.spec.ts` | the account rules on a BUILT site for a staff collection a later plugin adds (run after a webpack and a Turbopack build): a visitor account gets nothing, nobody raises its own role |
| `e2e/global-setup.ts` | Playwright global setup: resets the test admins and clears their stored 2FA attempt counts before every run, so specs do not depend on run order (below) |
| `e2e/late-staff-fixture.ts` | test fixture, on only with E2E_LATE_STAFF=1: one plugin before ipalKit (a staff collection of the config whose roles are the plugin's values plus one more) and one after it (a staff collection without rules, one whose roles field is text, a visitor collection with open sign-up) (below) |
| `e2e/late-staff.spec.ts` | the account rules on a BUILT site (run by `pnpm e2e:built` after a webpack and a Turbopack build): a staff collection a later plugin adds, and staff collections whose accounts can hold `admin` — a visitor account gets nothing, nobody raises its own role or makes an admin |
| `e2e/smoke.spec.ts` | the smoke tests every release must pass: pages, showcase, forms (also a file sent by e-mail), sitemap, SEO/GEO, headers, consent, 2FA |
| `e2e/smtp-sink.ts` | a local mail sink for the smoke tests: reads what the site really sent (recipients, attachments) |
| `e2e/totp.ts` | RFC 6238 code generator for the 2FA sign-in in the smoke test, and the address of the second test admin (below) |
| `e2e/two-factor-back.spec.ts` | browser test of the 2FA screens' `back` link (twoFactor.safeBack): a prepared link — script or another host — ends on the admin root, an ordinary one is followed |
| `e2e/two-factor-setup.spec.ts` | browser check of "2FA setup required": the first admin of a fresh site, a new editor, the administrator's reset on the account page |
### `e2e/global-setup.ts`
```ts
import { execFileSync } from 'node:child_process'
/**
* Before every Playwright run: the test admins are made (or reset) and their stored 2FA attempt counts cleared
* (e2e/create-test-admin.ts). The count is kept in the database — 5 verify attempts per account in 10 minutes —
* so without this a second run within ten minutes, or one spec run after the whole suite, would find the test
* admin locked out: the result would depend on what ran before. Skipped when the test admin is not configured
* (the specs that need it skip themselves) or with E2E_SKIP_ADMIN_SETUP=1.
*/
export default function globalSetup(): void {
const { E2E_ADMIN_EMAIL, E2E_ADMIN_PASSWORD, E2E_SKIP_ADMIN_SETUP, E2E_TOTP_SECRET } = process.env
if (E2E_SKIP_ADMIN_SETUP === '1' || !E2E_ADMIN_EMAIL || !E2E_ADMIN_PASSWORD || !E2E_TOTP_SECRET) {return}
execFileSync('pnpm', ['payload', 'run', 'e2e/create-test-admin.ts'], { env: { ...process.env, NODE_ENV: 'development' }, stdio: 'inherit' })
}
```
### `e2e/late-staff-fixture.ts`
```ts
@@ -1182,6 +1205,18 @@ import type { Config, Plugin } from 'payload'
*/
export const E2E_LATE_STAFF = process.env.E2E_LATE_STAFF === '1'
/** Slugs the fixture names as staff (payload.config.ts → `access.staffCollections`). */
export const E2E_STAFF_SLUGS = ['late-staff', 'e2e-crew', 'e2e-late-text']
/**
* Listed BEFORE ipalKit: a staff collection of the project's own, without rules, whose roles are the plugin's values
* PLUS one more. `admin` on an account of it makes a plugin admin, so its accounts must not hand that value out.
*/
export const e2eEarlyStaff: Plugin = (config: Config) =>
E2E_LATE_STAFF
? { ...config, collections: [...(config.collections ?? []), { slug: 'e2e-crew', auth: true, fields: [{ name: 'roles', type: 'select', hasMany: true, options: ['user', 'editor', 'admin', 'boss'], saveToJWT: true }] }] }
: config
export const e2eLateStaff: Plugin = (config: Config) =>
E2E_LATE_STAFF
? {
@@ -1190,6 +1225,8 @@ export const e2eLateStaff: Plugin = (config: Config) =>
...(config.collections ?? []),
// no access rules at all: Payload's defaults ("any logged-in user") are what ipalKit must replace
{ slug: 'late-staff', auth: true, fields: [{ name: 'roles', type: 'select', hasMany: true, options: ['user', 'editor', 'admin'], saveToJWT: true }], versions: true },
// a late staff collection whose `roles` is a text field: any value can be written there, `admin` included
{ slug: 'e2e-late-text', auth: true, fields: [{ name: 'roles', type: 'text', hasMany: true }] },
{ slug: 'e2e-visitors', access: { create: () => true }, auth: true, fields: [] },
],
}