Merge local main (1.17.2) into security-a-118

Conflicts resolved by keeping both sides: lockedAnswer + sign-in rules in plugin.ts and switches.ts, IPv6 grouping in the
mail service's new per-visitor address count, both built-site specs in e2e:built, docs and skills (reference copies
synced). The lockedAnswer suite and the sign-in-answers spec now reach Payload's lock the 1.18.0 way: a spray from
50 IPs, one failure each (one IP alone gets 429 after five).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-12-01 12:57:52 +01:00
co-authored by Claude Opus 5.5
113 changed files with 3468 additions and 317 deletions
+11 -1
View File
@@ -36,7 +36,7 @@ async function signIn(caller: Caller, baseURL: string, playwright: { request: {
async function ask(api: APIRequestContext, door: (typeof DOORS)[number]): Promise<DoorAnswer> {
const res = door.graphql
? await api.post('/api/graphql', { data: { query: door.graphql } })
: await api.fetch(door.path!, { data: door.body, maxRedirects: 0, method: door.method ?? 'GET' })
: await api.fetch(door.path!, { data: door.body, headers: door.headers, maxRedirects: 0, method: door.method ?? 'GET' })
const text = await res.text()
let body: unknown = text
try {
@@ -72,6 +72,16 @@ for (const caller of ['anonymous', 'customer', 'editor'] as const) {
})
}
test.describe('closed doors: the cron secret opens the job queue (IAWL idea 35, 1.17.2)', () => {
test('Authorization: Bearer <CRON_SECRET> runs the queue; nothing else changes', async ({ baseURL, playwright }) => {
test.skip(lateStaff !== '1' || !process.env.CRON_SECRET, 'needs the fixture\'s job queue (E2E_LATE_STAFF=1) and CRON_SECRET (pnpm e2e:built sets both)')
const cron = await playwright.request.newContext({ baseURL, extraHTTPHeaders: { authorization: `Bearer ${process.env.CRON_SECRET}` } })
const res = await cron.get('/api/payload-jobs/run?limit=1')
expect([res.status(), await res.text()]).toEqual([200, expect.any(String)])
await cron.dispose()
})
})
test.describe('closed doors: the proxy skips /api, /admin and /_next as whole segments only (IAWL idea 36)', () => {
test('the admin and the API are not sent to a locale; a page that only starts with those letters is', async ({ request }) => {
for (const path of ['/admin', '/api/health']) {
+17 -20
View File
@@ -24,6 +24,8 @@ export type Door = {
closed?: (answer: DoorAnswer, ctx: { email?: string }) => boolean
closedFor: Caller[]
graphql?: string
/** Extra request headers (e.g. a wrong bearer token). */
headers?: Record<string, string>
method?: 'DELETE' | 'GET' | 'PATCH' | 'POST'
name: string
/** Open for these callers while the owner decides (the finding's question). */
@@ -56,7 +58,11 @@ export const DOORS: Door[] = [
{ closedFor: ALL, name: 'the deep doctor status answers 404 without its token', path: '/api/ipal/doctor', closed: notFound },
// ---- jobs, schedules and call-backs (IAWL idea 35) ---------------------------------------------------------
{ closedFor: ALL, name: 'Payload\'s job queue has no run route (no jobs on this site)', path: '/api/payload-jobs/run', closed: notFound },
// the fixture's do-nothing task turns the queue on; since 1.17.2 (owner's Q2) only an admin or Bearer CRON_SECRET runs it
// (the "with the secret" case is its own test in closed-doors.spec.ts). Payload answers 401 when refused.
{ closedFor: ALL, name: 'Payload\'s job queue cannot be run (only an admin or the cron secret)', path: '/api/payload-jobs/run' },
{ closedFor: ALL, name: 'Payload\'s job schedules cannot be handled (only an admin or the cron secret)', path: '/api/payload-jobs/handle-schedules' },
{ closedFor: ALL, name: 'a wrong cron secret runs nothing', path: '/api/payload-jobs/run', headers: { authorization: 'Bearer not-the-cron-secret-not-the-cron-secret' } },
{ closedFor: ALL, method: 'POST', name: 'the crawler\'s call-back without its token', path: '/api/ipal/cookie-crawl/results', body: { jobId: 'x', ok: true } },
{ closedFor: OUTSIDERS, method: 'POST', name: 'a crawl cannot be started without the schedule\'s token', path: '/api/ipal/cookie-crawl' },
{ closedFor: OUTSIDERS, name: 'the crawl status', path: '/api/ipal/cookie-crawl' },
@@ -94,30 +100,21 @@ export const DOORS: Door[] = [
// ---- content and visitors' data --------------------------------------------------------------------------
{ closedFor: OUTSIDERS, name: 'form submissions (visitors\' personal data)', path: '/api/form-submissions' },
{ closedFor: OUTSIDERS, graphql: '{ FormSubmissions { docs { id } } }', closed: noData('FormSubmissions'), name: 'form submissions over GraphQL' },
{
body: { form: NO_ID, submissionData: [] },
closedFor: ['anonymous'],
method: 'POST',
name: 'a submission cannot be posted past submitForm (rate limit, Turnstile, consent, validation)',
openFor: { callers: ['customer'], question: 'Q1 (iawl-ideas-c-findings.md): any signed-in account may POST /api/form-submissions' },
path: '/api/form-submissions',
closed: forbidden,
},
// since 1.17.2 (owner's Q1): a staff account with its second factor only — an editor may (it reaches validation)
{ body: { form: NO_ID, submissionData: [] }, closedFor: OUTSIDERS, method: 'POST', name: 'a submission cannot be posted past submitForm (rate limit, Turnstile, consent, validation)', path: '/api/form-submissions', closed: forbidden },
{ body: {}, closedFor: OUTSIDERS, method: 'POST', name: 'Site settings cannot be saved', path: '/api/globals/site-settings', closed: forbidden },
{ body: {}, closedFor: OUTSIDERS, method: 'POST', name: 'Cookie settings (legal texts) cannot be saved', path: '/api/globals/cookie-settings', closed: forbidden },
{
body: {},
closedFor: ['anonymous'],
method: 'PATCH',
name: 'pages cannot be changed',
openFor: { callers: ['customer'], question: 'Q3: collections without their own write rules run on Payload\'s default (any signed-in account)' },
path: `/api/pages/${NO_ID}`,
closed: forbidden,
},
// the reference site's content has write rules of its own since 1.17.2 (owner's Q3, answer (b)): editors and admins
{ body: {}, closedFor: OUTSIDERS, method: 'PATCH', name: 'pages cannot be changed', path: `/api/pages/${NO_ID}`, closed: forbidden },
{ body: {}, closedFor: OUTSIDERS, method: 'PATCH', name: 'media cannot be changed', path: `/api/media/${NO_ID}`, closed: forbidden },
{ body: {}, closedFor: OUTSIDERS, method: 'POST', name: 'the header (navigation) cannot be saved', path: '/api/globals/header', closed: forbidden },
{ body: {}, closedFor: OUTSIDERS, method: 'POST', name: 'the company data cannot be saved', path: '/api/globals/company', closed: forbidden },
{
closedFor: ['anonymous'],
name: 'who edits what (Payload\'s document locks, with the editor\'s account)',
openFor: { callers: ['customer'], question: 'Q3: payload-locked-documents runs on Payload\'s default (any signed-in account)' },
// Payload's own collection: the plugin-wide default for it is the owner's Q3 answer (a), recorded for 2.0; the doctor's
// `visitor-writes` rule lists it on a site with a visitor login collection
openFor: { callers: ['customer'], question: 'Q3 (a), 2.0: payload-locked-documents runs on Payload\'s default (any signed-in account)' },
path: '/api/payload-locked-documents',
closed: forbidden,
},
+3
View File
@@ -20,6 +20,9 @@ export const e2eEarlyStaff: Plugin = (config: Config) =>
E2E_LATE_STAFF
? {
...config,
// one do-nothing task turns Payload's job queue on, so the closed-doors spec can ask its run route
// (no `jobs.access.run` here: iapl's default applies — an admin with the second factor, or Bearer CRON_SECRET)
jobs: { ...config.jobs, tasks: [...(config.jobs?.tasks ?? []), { slug: 'e2eNoop', handler: () => ({ output: {} }) }] },
collections: [
...(config.collections ?? []),
{ slug: 'e2e-crew', auth: true, fields: [{ name: 'roles', type: 'select', hasMany: true, options: ['user', 'editor', 'admin', 'boss'], saveToJWT: true }] },
+83 -83
View File
@@ -1,29 +1,29 @@
{
"$comment": "Every public door of this site: REST routes, GraphQL operations, Next route files. One line per entry: who may use it and why it is open (or that it is closed and to whom). A new route fails `routes:check` until somebody judges it here. `--update` adds new routes with an empty reason and drops gone ones. docs/security.md \"Routes nobody has judged\".",
"routes": {
"DELETE /api/caseStudies": "delete: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"DELETE /api/caseStudies/:id": "deleteByID: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"DELETE /api/caseStudies": "delete: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"DELETE /api/caseStudies/:id": "deleteByID: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"DELETE /api/consent-records": "delete: nobody over the API (create/update false); delete: admin; visitors write through POST /api/ipal/consent",
"DELETE /api/consent-records/:id": "deleteByID: nobody over the API (create/update false); delete: admin; visitors write through POST /api/ipal/consent",
"DELETE /api/cookie-review": "delete: create/update: editor+; delete: admin",
"DELETE /api/cookie-review/:id": "deleteByID: create/update: editor+; delete: admin",
"DELETE /api/form-submissions": "delete: create: any signed-in account (owner Q1); update: Payload default; delete: admin",
"DELETE /api/form-submissions/:id": "deleteByID: create: any signed-in account (owner Q1); update: Payload default; delete: admin",
"DELETE /api/form-submissions": "delete: create: a staff account with its second factor (1.17.2; the site submits through submitForm); update: nobody (form-builder); delete: admin",
"DELETE /api/form-submissions/:id": "deleteByID: create: a staff account with its second factor (1.17.2; the site submits through submitForm); update: nobody (form-builder); delete: admin",
"DELETE /api/forms": "delete: editor+ (staffAccess)",
"DELETE /api/forms/:id": "deleteByID: editor+ (staffAccess)",
"DELETE /api/media": "delete: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"DELETE /api/media/:id": "deleteByID: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"DELETE /api/pages": "delete: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"DELETE /api/pages/:id": "deleteByID: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"DELETE /api/media": "delete: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"DELETE /api/media/:id": "deleteByID: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"DELETE /api/pages": "delete: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"DELETE /api/pages/:id": "deleteByID: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"DELETE /api/payload-kv": "delete: nobody (every rule false)",
"DELETE /api/payload-kv/:id": "deleteByID: nobody (every rule false)",
"DELETE /api/payload-locked-documents": "delete: Payload default: any signed-in account (owner Q3)",
"DELETE /api/payload-locked-documents/:id": "deleteByID: Payload default: any signed-in account (owner Q3)",
"DELETE /api/payload-locked-documents": "delete: Payload default: any signed-in account (the plugin-wide default is owner's Q3 (a), 2.0; the doctor's visitor-writes lists it)",
"DELETE /api/payload-locked-documents/:id": "deleteByID: Payload default: any signed-in account (the plugin-wide default is owner's Q3 (a), 2.0; the doctor's visitor-writes lists it)",
"DELETE /api/payload-preferences": "delete: own preferences only (Payload)",
"DELETE /api/payload-preferences/:id": "deleteByID: own preferences only (Payload)",
"DELETE /api/payload-preferences/:key": "deleteByID: own preferences only (Payload)",
"DELETE /api/posts": "delete: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"DELETE /api/posts/:id": "deleteByID: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"DELETE /api/posts": "delete: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"DELETE /api/posts/:id": "deleteByID: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"DELETE /api/users": "delete: create/delete/unlock: an admin with the second factor; update: admin or self; roles field: admin",
"DELETE /api/users/:id": "deleteByID: create/delete/unlock: an admin with the second factor; update: admin or self; roles field: admin",
"GET /api/access": "Payload: the signed-in account's permissions (what the panel may show); anonymous gets an empty map",
@@ -101,11 +101,11 @@
"GET /api/payload-kv/count": "count: nobody (Payload: every rule false; the plugin keeps 2FA counts and the mail-service token here)",
"GET /api/payload-kv/versions": "versions: readVersions = read (nobody (Payload: every rule false; the plugin keeps 2FA counts and the mail-service token here)); no version history kept here",
"GET /api/payload-kv/versions/:id": "versionByID: readVersions = read (nobody (Payload: every rule false; the plugin keeps 2FA counts and the mail-service token here)); no version history kept here",
"GET /api/payload-locked-documents": "find: Payload default: any signed-in account (owner Q3)",
"GET /api/payload-locked-documents/:id": "findByID: Payload default: any signed-in account (owner Q3)",
"GET /api/payload-locked-documents/count": "count: Payload default: any signed-in account (owner Q3)",
"GET /api/payload-locked-documents/versions": "versions: readVersions = read (Payload default: any signed-in account (owner Q3)); no version history kept here",
"GET /api/payload-locked-documents/versions/:id": "versionByID: readVersions = read (Payload default: any signed-in account (owner Q3)); no version history kept here",
"GET /api/payload-locked-documents": "find: Payload default: any signed-in account (the plugin-wide default is owner's Q3 (a), 2.0; the doctor's visitor-writes lists it)",
"GET /api/payload-locked-documents/:id": "findByID: Payload default: any signed-in account (the plugin-wide default is owner's Q3 (a), 2.0; the doctor's visitor-writes lists it)",
"GET /api/payload-locked-documents/count": "count: Payload default: any signed-in account (the plugin-wide default is owner's Q3 (a), 2.0; the doctor's visitor-writes lists it)",
"GET /api/payload-locked-documents/versions": "versions: readVersions = read (Payload default: any signed-in account (the plugin-wide default is owner's Q3 (a), 2.0; the doctor's visitor-writes lists it)); no version history kept here",
"GET /api/payload-locked-documents/versions/:id": "versionByID: readVersions = read (Payload default: any signed-in account (the plugin-wide default is owner's Q3 (a), 2.0; the doctor's visitor-writes lists it)); no version history kept here",
"GET /api/payload-preferences": "find: the signed-in account's own preferences only (Payload)",
"GET /api/payload-preferences/:id": "findByID: the signed-in account's own preferences only (Payload)",
"GET /api/payload-preferences/:key": "findByID: the signed-in account's own preferences only (Payload)",
@@ -124,36 +124,36 @@
"GET /api/users/me": "Payload: the signed-in account itself, or null; no other account",
"GET /api/users/versions": "versions: readVersions = read (an admin, or the account itself (adminOrSelfIn users)); no version history kept here",
"GET /api/users/versions/:id": "versionByID: readVersions = read (an admin, or the account itself (adminOrSelfIn users)); no version history kept here",
"PATCH /api/caseStudies": "update: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"PATCH /api/caseStudies/:id": "updateByID: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"PATCH /api/caseStudies": "update: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"PATCH /api/caseStudies/:id": "updateByID: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"PATCH /api/consent-records": "update: nobody over the API (create/update false); delete: admin; visitors write through POST /api/ipal/consent",
"PATCH /api/consent-records/:id": "updateByID: nobody over the API (create/update false); delete: admin; visitors write through POST /api/ipal/consent",
"PATCH /api/cookie-review": "update: create/update: editor+; delete: admin",
"PATCH /api/cookie-review/:id": "updateByID: create/update: editor+; delete: admin",
"PATCH /api/form-submissions": "update: create: any signed-in account (owner Q1); update: Payload default; delete: admin",
"PATCH /api/form-submissions/:id": "updateByID: create: any signed-in account (owner Q1); update: Payload default; delete: admin",
"PATCH /api/form-submissions": "update: create: a staff account with its second factor (1.17.2; the site submits through submitForm); update: nobody (form-builder); delete: admin",
"PATCH /api/form-submissions/:id": "updateByID: create: a staff account with its second factor (1.17.2; the site submits through submitForm); update: nobody (form-builder); delete: admin",
"PATCH /api/forms": "update: editor+ (staffAccess)",
"PATCH /api/forms/:id": "updateByID: editor+ (staffAccess)",
"PATCH /api/media": "update: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"PATCH /api/media/:id": "updateByID: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"PATCH /api/pages": "update: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"PATCH /api/pages/:id": "updateByID: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"PATCH /api/media": "update: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"PATCH /api/media/:id": "updateByID: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"PATCH /api/pages": "update: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"PATCH /api/pages/:id": "updateByID: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"PATCH /api/payload-kv": "update: nobody (every rule false)",
"PATCH /api/payload-kv/:id": "updateByID: nobody (every rule false)",
"PATCH /api/payload-locked-documents": "update: Payload default: any signed-in account (owner Q3)",
"PATCH /api/payload-locked-documents/:id": "updateByID: Payload default: any signed-in account (owner Q3)",
"PATCH /api/payload-locked-documents": "update: Payload default: any signed-in account (the plugin-wide default is owner's Q3 (a), 2.0; the doctor's visitor-writes lists it)",
"PATCH /api/payload-locked-documents/:id": "updateByID: Payload default: any signed-in account (the plugin-wide default is owner's Q3 (a), 2.0; the doctor's visitor-writes lists it)",
"PATCH /api/payload-preferences": "update: own preferences only (Payload)",
"PATCH /api/payload-preferences/:id": "updateByID: own preferences only (Payload)",
"PATCH /api/posts": "update: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"PATCH /api/posts/:id": "updateByID: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"PATCH /api/posts": "update: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"PATCH /api/posts/:id": "updateByID: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"PATCH /api/users": "update: create/delete/unlock: an admin with the second factor; update: admin or self; roles field: admin",
"PATCH /api/users/:id": "updateByID: create/delete/unlock: an admin with the second factor; update: admin or self; roles field: admin",
"POST /api/admin/remove-user-totp": "2FA: an admin removes another account's second factor",
"POST /api/admin/reset-user-totp": "2FA: an admin resets another account's second factor",
"POST /api/caseStudies": "create: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"POST /api/caseStudies/:id/duplicate": "duplicate: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"POST /api/caseStudies": "create: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"POST /api/caseStudies/:id/duplicate": "duplicate: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"POST /api/caseStudies/access/:id?": "the signed-in account's own permissions on caseStudies",
"POST /api/caseStudies/versions/:id": "restore a version: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"POST /api/caseStudies/versions/:id": "restore a version: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"POST /api/consent-records": "create: nobody over the API (create/update false); delete: admin; visitors write through POST /api/ipal/consent",
"POST /api/consent-records/:id/duplicate": "duplicate: nobody over the API (create/update false); delete: admin; visitors write through POST /api/ipal/consent",
"POST /api/consent-records/access/:id?": "the signed-in account's own permissions on consent-records",
@@ -162,29 +162,29 @@
"POST /api/cookie-review/:id/duplicate": "duplicate: create/update: editor+; delete: admin",
"POST /api/cookie-review/access/:id?": "the signed-in account's own permissions on cookie-review",
"POST /api/cookie-review/versions/:id": "restore a version: create/update: editor+; delete: admin",
"POST /api/form-submissions": "create: create: any signed-in account (owner Q1); update: Payload default; delete: admin",
"POST /api/form-submissions/:id/duplicate": "duplicate: create: any signed-in account (owner Q1); update: Payload default; delete: admin",
"POST /api/form-submissions": "create: a staff account with its second factor (1.17.2; the site submits through submitForm); update: nobody (form-builder); delete: admin",
"POST /api/form-submissions/:id/duplicate": "duplicate: create: a staff account with its second factor (1.17.2; the site submits through submitForm); update: nobody (form-builder); delete: admin",
"POST /api/form-submissions/access/:id?": "the signed-in account's own permissions on form-submissions",
"POST /api/form-submissions/versions/:id": "restore a version: create: any signed-in account (owner Q1); update: Payload default; delete: admin",
"POST /api/form-submissions/versions/:id": "restore a version: create: a staff account with its second factor (1.17.2; the site submits through submitForm); update: nobody (form-builder); delete: admin",
"POST /api/forms": "create: editor+ (staffAccess)",
"POST /api/forms/:id/duplicate": "duplicate: editor+ (staffAccess)",
"POST /api/forms/access/:id?": "the signed-in account's own permissions on forms",
"POST /api/forms/versions/:id": "restore a version: editor+ (staffAccess)",
"POST /api/globals/company": "update: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"POST /api/globals/company": "update: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"POST /api/globals/company/access": "the signed-in account's own permissions on globals/company",
"POST /api/globals/company/versions/:id": "restore a version: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"POST /api/globals/company/versions/:id": "restore a version: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"POST /api/globals/cookie-crawl": "update: admin; the crawl endpoints write it after their own checks",
"POST /api/globals/cookie-crawl/access": "the signed-in account's own permissions on globals/cookie-crawl",
"POST /api/globals/cookie-crawl/versions/:id": "restore a version: admin; the crawl endpoints write it after their own checks",
"POST /api/globals/cookie-settings": "update: editor+",
"POST /api/globals/cookie-settings/access": "the signed-in account's own permissions on globals/cookie-settings",
"POST /api/globals/cookie-settings/versions/:id": "restore a version: editor+",
"POST /api/globals/footer": "update: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"POST /api/globals/footer": "update: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"POST /api/globals/footer/access": "the signed-in account's own permissions on globals/footer",
"POST /api/globals/footer/versions/:id": "restore a version: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"POST /api/globals/header": "update: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"POST /api/globals/footer/versions/:id": "restore a version: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"POST /api/globals/header": "update: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"POST /api/globals/header/access": "the signed-in account's own permissions on globals/header",
"POST /api/globals/header/versions/:id": "restore a version: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"POST /api/globals/header/versions/:id": "restore a version: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"POST /api/globals/notifications": "update: editor+",
"POST /api/globals/notifications/access": "the signed-in account's own permissions on globals/notifications",
"POST /api/globals/notifications/versions/:id": "restore a version: editor+",
@@ -205,22 +205,22 @@
"POST /api/ipal/forms/submit": "public by design: a form with files; the submitForm pipeline (rate limit, Turnstile, consent, validation, file checks)",
"POST /api/ipal/test-email": "send a test e-mail: admin",
"POST /api/ipal/two-factor/reset": "reset another account's 2FA set-up window: admin signed in with the second factor",
"POST /api/media": "create: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"POST /api/media/:id/duplicate": "duplicate: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"POST /api/media": "create: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"POST /api/media/:id/duplicate": "duplicate: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"POST /api/media/access/:id?": "the signed-in account's own permissions on media",
"POST /api/media/versions/:id": "restore a version: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"POST /api/pages": "create: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"POST /api/pages/:id/duplicate": "duplicate: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"POST /api/media/versions/:id": "restore a version: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"POST /api/pages": "create: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"POST /api/pages/:id/duplicate": "duplicate: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"POST /api/pages/access/:id?": "the signed-in account's own permissions on pages",
"POST /api/pages/versions/:id": "restore a version: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"POST /api/pages/versions/:id": "restore a version: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"POST /api/payload-kv": "create: nobody (every rule false)",
"POST /api/payload-kv/:id/duplicate": "duplicate: nobody (every rule false)",
"POST /api/payload-kv/access/:id?": "the signed-in account's own permissions on payload-kv",
"POST /api/payload-kv/versions/:id": "restore a version: nobody (every rule false)",
"POST /api/payload-locked-documents": "create: Payload default: any signed-in account (owner Q3)",
"POST /api/payload-locked-documents/:id/duplicate": "duplicate: Payload default: any signed-in account (owner Q3)",
"POST /api/payload-locked-documents": "create: Payload default: any signed-in account (the plugin-wide default is owner's Q3 (a), 2.0; the doctor's visitor-writes lists it)",
"POST /api/payload-locked-documents/:id/duplicate": "duplicate: Payload default: any signed-in account (the plugin-wide default is owner's Q3 (a), 2.0; the doctor's visitor-writes lists it)",
"POST /api/payload-locked-documents/access/:id?": "the signed-in account's own permissions on payload-locked-documents",
"POST /api/payload-locked-documents/versions/:id": "restore a version: Payload default: any signed-in account (owner Q3)",
"POST /api/payload-locked-documents/versions/:id": "restore a version: Payload default: any signed-in account (the plugin-wide default is owner's Q3 (a), 2.0; the doctor's visitor-writes lists it)",
"POST /api/payload-preferences": "create: own preferences only (Payload)",
"POST /api/payload-preferences/:id/duplicate": "duplicate: own preferences only (Payload)",
"POST /api/payload-preferences/:key": "updateByID: own preferences only (Payload)",
@@ -230,10 +230,10 @@
"POST /api/plugin-seo/generate-image": "SEO plugin (panel button): Payload default (signed-in account); nothing stored",
"POST /api/plugin-seo/generate-title": "SEO plugin (panel button): Payload default (signed-in account); nothing stored",
"POST /api/plugin-seo/generate-url": "SEO plugin (panel button): Payload default (signed-in account); nothing stored",
"POST /api/posts": "create: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"POST /api/posts/:id/duplicate": "duplicate: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"POST /api/posts": "create: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"POST /api/posts/:id/duplicate": "duplicate: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"POST /api/posts/access/:id?": "the signed-in account's own permissions on posts",
"POST /api/posts/versions/:id": "restore a version: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"POST /api/posts/versions/:id": "restore a version: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"POST /api/remove-totp": "2FA: the signed-in account's own second factor, fully signed in",
"POST /api/setup-totp": "2FA: sets up the signed-in account's own authenticator; same-origin only",
"POST /api/users": "create: create/delete/unlock: an admin with the second factor; update: admin or self; roles field: admin",
@@ -248,64 +248,64 @@
"POST /api/users/verify/:id": "public by design: needs the e-mailed verification token (verify is off on users)",
"POST /api/users/versions/:id": "restore a version: create/delete/unlock: an admin with the second factor; update: admin or self; roles field: admin",
"POST /api/verify-totp": "2FA (payload-2fa): the signed-in account's own code; same-origin only, 5 tries per account in 10 min",
"graphql mutation createCaseStudy": "GraphQL create: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"graphql mutation createCaseStudy": "GraphQL create: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"graphql mutation createConsentRecord": "GraphQL create: nobody over the API (create/update false); delete: admin; visitors write through POST /api/ipal/consent",
"graphql mutation createCookieReview": "GraphQL create: create/update: editor+; delete: admin",
"graphql mutation createForm": "GraphQL create: editor+ (staffAccess)",
"graphql mutation createFormSubmission": "GraphQL create: create: any signed-in account (owner Q1); update: Payload default; delete: admin",
"graphql mutation createMedia": "GraphQL create: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"graphql mutation createPage": "GraphQL create: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"graphql mutation createFormSubmission": "GraphQL create: a staff account with its second factor (1.17.2; the site submits through submitForm); update: nobody (form-builder); delete: admin",
"graphql mutation createMedia": "GraphQL create: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"graphql mutation createPage": "GraphQL create: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"graphql mutation createPayloadKv": "GraphQL create: nobody (every rule false)",
"graphql mutation createPayloadLockedDocument": "GraphQL create: Payload default: any signed-in account (owner Q3)",
"graphql mutation createPayloadLockedDocument": "GraphQL create: Payload default: any signed-in account (the plugin-wide default is owner's Q3 (a), 2.0; the doctor's visitor-writes lists it)",
"graphql mutation createPayloadPreference": "GraphQL create: own preferences only (Payload)",
"graphql mutation createPost": "GraphQL create: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"graphql mutation createPost": "GraphQL create: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"graphql mutation createUser": "GraphQL create: create/delete/unlock: an admin with the second factor; update: admin or self; roles field: admin",
"graphql mutation deleteCaseStudy": "GraphQL delete: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"graphql mutation deleteCaseStudy": "GraphQL delete: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"graphql mutation deleteConsentRecord": "GraphQL delete: nobody over the API (create/update false); delete: admin; visitors write through POST /api/ipal/consent",
"graphql mutation deleteCookieReview": "GraphQL delete: create/update: editor+; delete: admin",
"graphql mutation deleteForm": "GraphQL delete: editor+ (staffAccess)",
"graphql mutation deleteFormSubmission": "GraphQL delete: create: any signed-in account (owner Q1); update: Payload default; delete: admin",
"graphql mutation deleteMedia": "GraphQL delete: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"graphql mutation deletePage": "GraphQL delete: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"graphql mutation deleteFormSubmission": "GraphQL delete: create: a staff account with its second factor (1.17.2; the site submits through submitForm); update: nobody (form-builder); delete: admin",
"graphql mutation deleteMedia": "GraphQL delete: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"graphql mutation deletePage": "GraphQL delete: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"graphql mutation deletePayloadKv": "GraphQL delete: nobody (every rule false)",
"graphql mutation deletePayloadLockedDocument": "GraphQL delete: Payload default: any signed-in account (owner Q3)",
"graphql mutation deletePayloadLockedDocument": "GraphQL delete: Payload default: any signed-in account (the plugin-wide default is owner's Q3 (a), 2.0; the doctor's visitor-writes lists it)",
"graphql mutation deletePayloadPreference": "GraphQL delete: own preferences only (Payload)",
"graphql mutation deletePost": "GraphQL delete: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"graphql mutation deletePost": "GraphQL delete: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"graphql mutation deleteUser": "GraphQL delete: create/delete/unlock: an admin with the second factor; update: admin or self; roles field: admin",
"graphql mutation duplicateCaseStudy": "GraphQL duplicate: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"graphql mutation duplicateCaseStudy": "GraphQL duplicate: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"graphql mutation duplicateConsentRecord": "GraphQL duplicate: nobody over the API (create/update false); delete: admin; visitors write through POST /api/ipal/consent",
"graphql mutation duplicateCookieReview": "GraphQL duplicate: create/update: editor+; delete: admin",
"graphql mutation duplicateForm": "GraphQL duplicate: editor+ (staffAccess)",
"graphql mutation duplicateFormSubmission": "GraphQL duplicate: create: any signed-in account (owner Q1); update: Payload default; delete: admin",
"graphql mutation duplicateMedia": "GraphQL duplicate: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"graphql mutation duplicatePage": "GraphQL duplicate: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"graphql mutation duplicateFormSubmission": "GraphQL duplicate: create: a staff account with its second factor (1.17.2; the site submits through submitForm); update: nobody (form-builder); delete: admin",
"graphql mutation duplicateMedia": "GraphQL duplicate: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"graphql mutation duplicatePage": "GraphQL duplicate: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"graphql mutation duplicatePayloadKv": "GraphQL duplicate: nobody (every rule false)",
"graphql mutation duplicatePayloadLockedDocument": "GraphQL duplicate: Payload default: any signed-in account (owner Q3)",
"graphql mutation duplicatePayloadLockedDocument": "GraphQL duplicate: Payload default: any signed-in account (the plugin-wide default is owner's Q3 (a), 2.0; the doctor's visitor-writes lists it)",
"graphql mutation duplicatePayloadPreference": "GraphQL duplicate: own preferences only (Payload)",
"graphql mutation duplicatePost": "GraphQL duplicate: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"graphql mutation duplicatePost": "GraphQL duplicate: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"graphql mutation forgotPasswordUser": "public by design: the same answer for a real and an invented address",
"graphql mutation loginUser": "public by design: sign-in (as POST /api/users/login)",
"graphql mutation logoutUser": "public by design: ends the caller's own session",
"graphql mutation refreshTokenUser": "the signed-in account's own token only",
"graphql mutation resetPasswordUser": "public by design: needs the e-mailed reset token",
"graphql mutation unlockUser": "admin with the second factor (accounts.adminOnlyWrite)",
"graphql mutation updateCaseStudy": "GraphQL update: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"graphql mutation updateCompany": "GraphQL update: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"graphql mutation updateCaseStudy": "GraphQL update: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"graphql mutation updateCompany": "GraphQL update: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"graphql mutation updateConsentRecord": "GraphQL update: nobody over the API (create/update false); delete: admin; visitors write through POST /api/ipal/consent",
"graphql mutation updateCookieCrawl": "GraphQL update: admin; the crawl endpoints write it after their own checks",
"graphql mutation updateCookieReview": "GraphQL update: create/update: editor+; delete: admin",
"graphql mutation updateCookieSetting": "GraphQL update: editor+",
"graphql mutation updateFooter": "GraphQL update: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"graphql mutation updateFooter": "GraphQL update: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"graphql mutation updateForm": "GraphQL update: editor+ (staffAccess)",
"graphql mutation updateFormSubmission": "GraphQL update: create: any signed-in account (owner Q1); update: Payload default; delete: admin",
"graphql mutation updateHeader": "GraphQL update: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"graphql mutation updateMedia": "GraphQL update: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"graphql mutation updateFormSubmission": "GraphQL update: create: a staff account with its second factor (1.17.2; the site submits through submitForm); update: nobody (form-builder); delete: admin",
"graphql mutation updateHeader": "GraphQL update: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"graphql mutation updateMedia": "GraphQL update: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"graphql mutation updateNotification": "GraphQL update: editor+",
"graphql mutation updatePage": "GraphQL update: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"graphql mutation updatePage": "GraphQL update: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"graphql mutation updatePayloadKv": "GraphQL update: nobody (every rule false)",
"graphql mutation updatePayloadLockedDocument": "GraphQL update: Payload default: any signed-in account (owner Q3)",
"graphql mutation updatePayloadLockedDocument": "GraphQL update: Payload default: any signed-in account (the plugin-wide default is owner's Q3 (a), 2.0; the doctor's visitor-writes lists it)",
"graphql mutation updatePayloadPreference": "GraphQL update: own preferences only (Payload)",
"graphql mutation updatePost": "GraphQL update: Payload default (any signed-in account; one login collection here, so staff only — a visitor collection would reach it: owner Q3)",
"graphql mutation updatePost": "GraphQL update: editor+ (adminOrEditor, the site's own rule since 1.17.2; Payload's default would let any signed-in account in)",
"graphql mutation updateSiteIntegration": "GraphQL update: admin; secrets write-only",
"graphql mutation updateSiteSetting": "GraphQL update: editor+",
"graphql mutation updateUser": "GraphQL update: create/delete/unlock: an admin with the second factor; update: admin or self; roles field: admin",
@@ -332,8 +332,8 @@
"graphql query Pages": "GraphQL find: anyone (published content, no drafts)",
"graphql query PayloadKv": "GraphQL find: nobody (Payload: every rule false; the plugin keeps 2FA counts and the mail-service token here)",
"graphql query PayloadKvs": "GraphQL find: nobody (Payload: every rule false; the plugin keeps 2FA counts and the mail-service token here)",
"graphql query PayloadLockedDocument": "GraphQL find: Payload default: any signed-in account (owner Q3)",
"graphql query PayloadLockedDocuments": "GraphQL find: Payload default: any signed-in account (owner Q3)",
"graphql query PayloadLockedDocument": "GraphQL find: Payload default: any signed-in account (the plugin-wide default is owner's Q3 (a), 2.0; the doctor's visitor-writes lists it)",
"graphql query PayloadLockedDocuments": "GraphQL find: Payload default: any signed-in account (the plugin-wide default is owner's Q3 (a), 2.0; the doctor's visitor-writes lists it)",
"graphql query PayloadPreference": "GraphQL find: the signed-in account's own preferences only (Payload)",
"graphql query PayloadPreferences": "GraphQL find: the signed-in account's own preferences only (Payload)",
"graphql query Post": "GraphQL find: anyone (published content, no drafts)",
@@ -350,7 +350,7 @@
"graphql query countForms": "GraphQL count: anyone (the form renders from it; the Emails tab is staff-only by field access)",
"graphql query countPages": "GraphQL count: anyone (published content, no drafts)",
"graphql query countPayloadKvs": "GraphQL count: nobody (Payload: every rule false; the plugin keeps 2FA counts and the mail-service token here)",
"graphql query countPayloadLockedDocuments": "GraphQL count: Payload default: any signed-in account (owner Q3)",
"graphql query countPayloadLockedDocuments": "GraphQL count: Payload default: any signed-in account (the plugin-wide default is owner's Q3 (a), 2.0; the doctor's visitor-writes lists it)",
"graphql query countPayloadPreferences": "GraphQL count: the signed-in account's own preferences only (Payload)",
"graphql query countPosts": "GraphQL count: anyone (published content, no drafts)",
"graphql query countUsers": "GraphQL count: an admin, or the account itself (adminOrSelfIn users)",
+62
View File
@@ -0,0 +1,62 @@
import { type APIRequestContext, expect, test } from '@playwright/test'
import { randomUUID } from 'node:crypto'
import { totp } from './totp'
/**
* On the BUILT site (pnpm e2e:built, webpack and Turbopack), what 1.17.2 changed at the sign-in and in the panel:
* - a locked staff account answers its login exactly like a wrong password (accounts.lockedAnswer) — the hook
* recognises Payload's error by the name Payload gives it, which a minified bundle must keep;
* - the plugin's panel actions refuse a request from another origin (adminSameOrigin), the site's own still works.
* Needs the E2E_* test admin (e2e/create-test-admin.ts). The locked account is a fresh one made here, so the test
* admins are never locked.
*/
const { E2E_ADMIN_EMAIL: adminEmail, E2E_ADMIN_PASSWORD: password, E2E_TOTP_SECRET: secret } = process.env
let admin: APIRequestContext
test.beforeAll(async ({ baseURL, playwright }) => {
test.skip(!adminEmail || !password || !secret, 'E2E_ADMIN_* values are not set')
admin = await playwright.request.newContext({ baseURL, extraHTTPHeaders: { origin: baseURL! } })
expect((await admin.post('/api/users/login', { data: { email: adminEmail, password } })).status()).toBe(200)
expect((await (await admin.post('/api/verify-totp', { data: { token: totp(secret!) } })).json()).ok).toBe(true)
})
test.afterAll(async () => {
await admin?.dispose()
})
test('a locked staff account gets the wrong-password answer, REST and GraphQL', async ({ baseURL, playwright }) => {
const email = `locked-${randomUUID().slice(0, 8)}@example.com`
const own = `L-${randomUUID()}`
expect((await admin.post('/api/users', { data: { email, password: own, roles: ['editor'] } })).status()).toBe(201)
const anon = await playwright.request.newContext({ baseURL })
// the site reads the client address from IAPL_IP_HEADER (reference/.env: x-forwarded-for, one proxy)
const login = async (address: string, pass: string, ip = '203.0.113.150') => {
const res = await anon.post('/api/users/login', { data: { email: address, password: pass }, headers: { 'x-forwarded-for': ip } })
return { body: await res.text(), status: res.status() }
}
// 1.18.0 (accounts.signInLimit): one IP fails at most 5 times per address and Payload locks a staff account at 50
// failures — a spray from 50 IPs, one failure each, locks it
for (let i = 0; i < 50; i++) {await login(email, 'a-wrong-password-1', `198.51.100.${i + 1}`)}
const invented = await login(`nobody-${randomUUID().slice(0, 8)}@example.com`, 'a-wrong-password-1')
expect(invented.status).toBe(401)
expect(await login(email, own)).toEqual(invented)
const gql = async (address: string, pass: string) => {
const res = await anon.post('/api/graphql', { data: { query: `mutation { loginUser(email: ${JSON.stringify(address)}, password: ${JSON.stringify(pass)}) { token } }` } })
const error = ((await res.json()) as { errors?: { extensions?: { name?: string }; message: string }[] }).errors?.[0]
return { message: error?.message, name: error?.extensions?.name }
}
expect(await gql(email, own)).toEqual(await gql(`nobody-${randomUUID().slice(0, 8)}@example.com`, 'x-wrong-password-1'))
await anon.dispose()
})
test('panel actions: another origin gets 403 with the admin cookie, the site itself goes through', async ({ baseURL }) => {
const foreign = await admin.fetch('/api/ipal/cookie-approval', {
data: '{"ids":[]}',
headers: { 'content-type': 'text/plain', origin: 'https://blog.example.test', 'sec-fetch-site': 'same-site' },
method: 'POST',
})
expect(foreign.status()).toBe(403)
const own = await admin.fetch('/api/ipal/cookie-approval', { data: '{"ids":[]}', headers: { 'content-type': 'text/plain', origin: baseURL! }, method: 'POST' })
expect(own.status()).toBe(200)
})
+128
View File
@@ -493,6 +493,134 @@ test('consent: withdrawal — reopen, reject: analytics cookies and listed stora
expect((await consentRecord(context))!.state).toMatchObject({ analytics: false, functional: false, marketing: false })
})
// The "cookie settings" button stays in the bottom corner of the window (1.17.2) and never moves: not above the
// footer, not at the end of the page. The footer gets room under its last row while the button is shown, so the
// button covers nothing there (consent.md → "Where the cookie button sits").
const BUTTON_PAGES = ['/pl', '/pl/kontakt', '/en', '/pl/blog', '/pl/regulamin']
const buttonState = () => {
const b = document.querySelector<HTMLElement>('[data-ipal="cookie-button"]')
const footer = [...document.querySelectorAll<HTMLElement>('footer, [role="contentinfo"]')].at(-1)!
if (!b) {return { button: false, room: footer.hasAttribute('data-ipal-cookie-space') }}
const r = b.getBoundingClientRect()
const hits = (q: DOMRect) => q.width > 0 && q.height > 0 && q.right > r.left && q.left < r.right && q.bottom > r.top && q.top < r.bottom
// every piece of footer text and every control of the page that lies under the button
const under: string[] = []
const walker = document.createTreeWalker(footer, NodeFilter.SHOW_TEXT)
const range = document.createRange()
for (let node = walker.nextNode(); node; node = walker.nextNode()) {
if (!/\S/.test(node.nodeValue ?? '')) {continue}
range.selectNodeContents(node)
if ([...range.getClientRects()].some(hits)) {under.push(`text: ${node.nodeValue!.trim().slice(0, 24)}`)}
}
for (const el of document.querySelectorAll('a[href], button, input, select, textarea, summary')) {
if (el !== b && hits(el.getBoundingClientRect())) {under.push(`control: ${(el.textContent ?? '').trim().slice(0, 24)}`)}
}
return {
button: true,
gap: Math.round(window.innerHeight - r.bottom),
inFooter: !!b.closest('footer'),
left: Math.round(r.left),
position: getComputedStyle(b).position,
room: footer.hasAttribute('data-ipal-cookie-space'),
transform: getComputedStyle(b).transform,
under,
}
}
const CORNER = { button: true, gap: 16, inFooter: false, left: 16, position: 'fixed', transform: 'none' }
for (const device of [
{ name: 'desktop', viewport: { height: 800, width: 1280 } },
{ name: 'phone', viewport: { height: 844, width: 390 } },
{ name: 'small phone', viewport: { height: 640, width: 360 } },
]) {
for (const colorScheme of ['light', 'dark'] as const) {
test(`cookie button, ${device.name}, ${colorScheme}: the corner at every scroll position, nothing under it at the end, no layout shift`, async ({ browser }) => {
const context = await browser.newContext({ colorScheme, hasTouch: device.name !== 'desktop', viewport: device.viewport })
const page = await context.newPage()
await page.addInitScript(() => {
const w = window as unknown as { __cls: number }
w.__cls = 0
new PerformanceObserver((list) => {
for (const entry of list.getEntries() as unknown as { hadRecentInput: boolean; value: number }[]) {
if (!entry.hadRecentInput) {w.__cls += entry.value}
}
}).observe({ buffered: true, type: 'layout-shift' })
})
const shifts = () => page.evaluate(() => (window as unknown as { __cls: number }).__cls)
const footerPadding = () => page.evaluate(() => getComputedStyle([...document.querySelectorAll('footer')].at(-1)!).paddingBottom)
// before a decision: no button, the footer as the project made it
await page.goto('/pl')
await expect(page.locator('[data-ipal="banner"]')).toBeVisible()
expect(await page.evaluate(buttonState)).toEqual({ button: false, room: false })
const ownPadding = await footerPadding()
await page.locator('[data-ipal="reject"]').click()
const button = page.locator('[data-ipal="cookie-button"]')
for (const path of BUTTON_PAGES) {
// a returning visitor's page load: the room is there from the first paint, so nothing shifts when the button appears
await page.goto(path)
await expect(button).toBeVisible()
await page.waitForTimeout(400)
const height = await page.evaluate(() => document.documentElement.scrollHeight)
const end = Math.max(0, height - device.viewport.height)
for (const y of [0, end / 2, end - 40, end]) {
await page.evaluate((to) => window.scrollTo(0, to), y)
await page.waitForTimeout(250)
expect(await page.evaluate(buttonState), `${path} at ${Math.round(y)} of ${end}`).toMatchObject(CORNER)
}
// the very end of the page (measured now: a form or its Turnstile widget may have grown the page since)
await page.evaluate(() => window.scrollTo(0, document.documentElement.scrollHeight))
await page.waitForTimeout(250)
expect(await page.evaluate(() => Math.round(window.innerHeight + window.scrollY - document.documentElement.scrollHeight)), `${path}: at the end`).toBe(0)
expect(await page.evaluate(buttonState), `${path} at the very end`).toMatchObject(CORNER)
// no footer text and no control under the button
expect((await page.evaluate(buttonState)).under, `${path}: under the button at the end`).toEqual([])
// and every footer link can be clicked (Playwright refuses a click another element would receive)
const links = page.locator('footer a[href]')
const count = await links.count()
expect(count).toBeGreaterThan(3)
for (let i = 0; i < count; i++) {await links.nth(i).click({ timeout: 3000, trial: true })}
expect(await shifts(), `${path}: layout shift from load to the end of the page`).toBeLessThan(0.001)
}
// keyboard: reachable and it reopens the banner; the room goes with the button
await button.focus()
await expect(button).toBeFocused()
await page.keyboard.press('Enter')
await expect(page.locator('[data-ipal="banner"]')).toBeVisible()
expect(await page.evaluate(buttonState)).toEqual({ button: false, room: false })
await page.goto('/pl') // decided again? no: reopening does not undo the stored decision, the button is back
await expect(button).toBeVisible()
await page.locator('[data-ipal="cookie-button"]').click()
expect(await footerPadding(), 'banner open: the footer as before a decision').toBe(ownPadding)
await context.close()
})
}
}
test('cookie button: for a returning visitor the room is there before the page hydrates (no application script)', async ({ browser }) => {
const context = await browser.newContext({ hasTouch: true, viewport: { height: 844, width: 390 } })
const page = await context.newPage()
const padding = () => page.evaluate(() => parseFloat(getComputedStyle([...document.querySelectorAll('footer')].at(-1)!).paddingBottom))
await page.goto('/pl')
const own = await padding()
await page.locator('[data-ipal="reject"]').click()
await expect(page.locator('[data-ipal="cookie-button"]')).toBeVisible()
const live = await padding()
expect(live).toBeGreaterThan(own)
// the same page with every application script refused: only the inline script can have made the room
await page.route(isAppScript, (route) => route.abort())
await page.goto('/pl')
await expect(page.locator('[data-ipal="cookie-button"]')).toHaveCount(0)
// the same room, to the pixel or one off: here the web font may not have arrived yet, and the row's text box follows the font
expect(Math.abs((await padding()) - live)).toBeLessThanOrEqual(2)
expect(await padding()).toBeGreaterThan(own + 30)
// the server's markup is untouched (React hydrates it without a mismatch): the room is in a style sheet
expect(await page.evaluate(() => [...document.querySelectorAll('footer')].at(-1)!.getAttribute('style'))).toBeNull()
await context.close()
})
test('admin: sign in through 2FA, agency credit, panel link preview', async ({ page, request }) => {
const head = await (await request.get('/admin/login')).text()
expect(head).toMatch(/noindex/)