diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 6c51a57..f30ee08 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -9,7 +9,12 @@ versions at once, go through every "Requires project changes" section in order, version you have. A new release = a new section at the top; we remove the oldest ones only once there are more than 20. -## Unreleased (for 1.18.0) — two-step verification: the first set-up is confirmed by e-mail +## Unreleased (for 1.18.0) — two-step set-up confirmed by e-mail, speed and growth, security audit fixes + +This heading and the 1.17.2 section below (never released on its own) become one 1.18.0 entry at release. Read every +"what changes for an existing site" list: the one here and the one in each subsection. + +### Two-step verification: the first set-up is confirmed by e-mail (docs/security.md) > **Read before upgrading — what changes for an existing site, most important first:** > @@ -101,7 +106,8 @@ once there are more than 20. > 1. **Public lists are capped at 100** (`listLimit`, finding F4). A REST / GraphQL list (`find`, versions, distinct > values) asked by a caller that is not staff gets at most 100 documents; `pagination=false` and `limit=0` become one > page of 100. Before, one anonymous `GET /api/posts?limit=100000` read a whole collection with its relations. -> Staff accounts, the panel and the Local API (the frontend, seeds) are not capped. **A client-side script that reads +> Staff accounts, the panel, the Local API (the frontend, seeds) and server code that reads with +> `overrideAccess: true` while passing a request on (the cookie scanner's scheduled crawl) are not capped. **A client-side script that reads > more than 100 documents anonymously now gets the first 100 and `hasNextPage: true`** — page through, or adapt: > `listLimit: { max: 500 }`, `{ exclude: ['products'] }`, `{ staff: true }`; off: `listLimit: false`. > 2. **An operator name in `?sort=` answers 400** (`refuseOperatorSort`, F5): `$where`, `-$natural`, `title.$ne` — diff --git a/docs/agent/AGENT.md b/docs/agent/AGENT.md index c5358a4..260d32a 100644 --- a/docs/agent/AGENT.md +++ b/docs/agent/AGENT.md @@ -1256,7 +1256,7 @@ add missing hosts with flags / `extra`; (3) change `mode` to `'enforce'` in both | The second factor on every collection and global, whichever plugin added it, and on the plugin's endpoints; an unrecognised 2FA package = startup error | per entity: `custom.ipal.secondFactor: false` or `{ read: false }` (or the package's `custom.totp.disableAccessWrapper`); everywhere: `twoFactor.guard: false` (not recommended) | `requireSecondFactor` / `secondFactorPassed` in your own access functions and endpoints | | At most 5 **wrong** verify codes per account in 10 minutes (`POST /api/verify-totp` → `429`); a right code gives its place back (1.17.1), so correct logins are never refused; an attempt held out only by others still being checked gets `429` + `Retry-After: 2` ("try again in a moment"); the count is kept in memory and in the database (`payload.kv`), so a restart or a second instance does not reset it. **Verify:** log in correctly 7 times in a row → all in; 5 wrong codes → the next gets `429` with a long `Retry-After` | `twoFactor.verifyLimit: false` | `verifyLimit: { max, windowMinutes, store: 'memory' }`; own wiring: `buildVerifyLimit(...)` + `limit.settle(req, correct)` | | The plugin's panel actions (`POST` mail service connect / disconnect, test e-mail, cookie scan / approval / crawl) refuse a request a browser marks as coming from another origin (`403`, before anything is read; 1.17.2). The panel's buttons are not affected; set `serverURL` (doctor `csrf-empty` warns without it). **Verify:** `curl -X POST /api/ipal/test-email -H 'Origin: https://other.example' -H 'Content-Type: text/plain' -b -d '{}'` → `403` | `adminSameOrigin: false` | `adminSameOrigin: { origins: [...] }`; `requireOwnOrigin(endpoint, origins?)` for your own endpoints | -| Public lists capped (1.18.0, audit F4): a REST / GraphQL list from a caller that is not staff gets at most 100 documents; `pagination=false` / `limit=0` become one page of 100; staff and the Local API untouched. **Verify:** `curl -s '/api/pages?limit=100000' \| jq .limit` → `100` | `listLimit: false` | `listLimit: { max, staff, exclude }`; `buildQueryGuardHook` for a collection a plugin adds after iapl; `capListLimit` | +| Public lists capped (1.18.0, audit F4): a REST / GraphQL list from a caller that is not staff gets at most 100 documents; `pagination=false` / `limit=0` become one page of 100; staff, the Local API and server reads with `overrideAccess: true` that pass a request on untouched. **Verify:** `curl -s '/api/pages?limit=100000' \| jq .limit` → `100` | `listLimit: false` | `listLimit: { max, staff, exclude }`; `buildQueryGuardHook` for a collection a plugin adds after iapl; `capListLimit` | | Operator names in `sort` refused (1.18.0, audit F5): `?sort=$where`, `-$natural`, `a.$ne` → `400` for everyone (logged as one `info` line, `RefusedSortError`) instead of a database error. **Verify:** `curl -s -o /dev/null -w '%{http_code}' '/api/pages?sort=%24where'` → `400` | `refuseOperatorSort: false` | `loggingLevels: { RefusedSortError: false }`; `isOperatorSort` | | Payload's document locks (`payload-locked-documents`) for staff accounts only, with the second factor (1.18.0); Payload's default was any signed-in account, a customer too. **Verify:** a visitor account gets `403` on `/api/payload-locked-documents`; the panel still shows who edits a document | `lockedDocuments: false` | `lockedDocuments: { access: { read, create, update, delete } }`; `staffOnlyLocks`, `applyLockedDocumentsAccess` | | CSP report log lines normalised (1.18.0, audit F1): origin of the blocked resource, path of the page, no control characters, every value ≤ 128 characters; at most 10 violations per request, 60 requests per client a minute (answer stays `204`) | `rateLimit: false`; your own `onReport` (gets the raw values) | `createCspReportRoute({ maxReports, rateLimit: { max, windowMs }, onReport })`, `cspLogLine` | diff --git a/docs/agent/skills/iapl-reference/SKILL.md b/docs/agent/skills/iapl-reference/SKILL.md index f05933f..d85fd5b 100644 --- a/docs/agent/skills/iapl-reference/SKILL.md +++ b/docs/agent/skills/iapl-reference/SKILL.md @@ -47,7 +47,7 @@ description: Complete map of everything @intecion/ipal-kit provides — every ia | `secrets.reenterOnChange` | on | a save through access control that changes `smtpHost`, `smtpPort` or `smtpUser` while a password is stored must send the password again or remove it (`400` on the field otherwise), whatever `emailTransport` says — so an admin session cannot send the stored password to a server of its own. A change of the transport alone, and the Local API with access control off, are not asked | `false` = the stored password follows the new server | | `dashboardAlerts` | `{ integrations: 'admin', cookies: 'editor' }` | who sees the plugin's dashboard alerts: integration details (error text, link) for `integrations` and above, a neutral "ask an administrator" for editors below it, nothing for others; the cookie crawl / approval alert for `cookies` and above. With a role, a session that owes its second factor sees none | `integrations: 'editor' | 'all'`, `cookies: 'all'` (`'all'` = as before: no role and no second factor is checked) | | `strictAccessAnswers` | `true` (1.18.0) | a project's access callback (`cookieScanner.access`, the doctor's `access`) allows only on a literal `true`; `req.user`, `1`, a string, an un-awaited Promise refuse; a non-boolean answer is reported once per option | `false` = any truthy answer allows (as before 1.18.0) | -| `listLimit` | `{ max: 100, staff: false }` (1.18.0, audit F4) | a REST / GraphQL list (`find`, versions, distinct) from a caller that is not staff gets at most `max` documents; `pagination=false` / `limit=0` become one page; staff and the Local API untouched | `false` (Payload's behaviour); `{ max, staff: true, exclude: ['slug'] }`; `buildQueryGuardHook` for a collection added after iapl | +| `listLimit` | `{ max: 100, staff: false }` (1.18.0, audit F4) | a REST / GraphQL list (`find`, versions, distinct) from a caller that is not staff gets at most `max` documents; `pagination=false` / `limit=0` become one page; staff, the Local API and server reads with `overrideAccess: true` that pass a request on untouched | `false` (Payload's behaviour); `{ max, staff: true, exclude: ['slug'] }`; `buildQueryGuardHook` for a collection added after iapl | | `refuseOperatorSort` | `true` (1.18.0, audit F5) | a `sort` naming a database operator (`$where`, `-$natural`, `a.$ne`) → `400` for everyone, logged as one `info` line (`RefusedSortError`) | `false`; `loggingLevels: { RefusedSortError: false }` hides the log line | | `lockedDocuments` | staff only (1.18.0) | Payload's document locks (`payload-locked-documents`) for staff accounts with the second factor; Payload's default was any signed-in account | `false` (Payload's default); `{ access: { read, create, update, delete } }` | | `adminSameOrigin` | on (1.17.2) | `POST` mail service connect / disconnect, test e-mail, cookie scan / approval / crawl refuse (`403`) a request a browser marks as coming from another origin; own origins: the request's host, `serverURL`, `csrf`, `cors`, `origins` | `{ origins: [...] }` adds origins; `false` = no check; any other value stops the start | diff --git a/docs/security.md b/docs/security.md index d9e1527..6ef204e 100644 --- a/docs/security.md +++ b/docs/security.md @@ -1354,7 +1354,10 @@ gets 403 on every write door. ## Lists and sorting (`listLimit`, `refuseOperatorSort`, `lockedDocuments`, 1.18.0) Three defaults for what a caller from outside (REST, GraphQL) may ask of a collection. The Local API — the frontend, -seeds, the project's own code (`req.payloadAPI === 'local'`) — is never touched. +seeds, the project's own code (`req.payloadAPI === 'local'`) — is never touched, and neither is a read with +`overrideAccess: true` that server code makes while it passes an outside request on (`payload.find({ req, +overrideAccess: true })`, e.g. the cookie scanner's scheduled crawl, which has no account): it is the server's own read, +not the caller's. A read with `overrideAccess: false` and the caller's `req` is the caller's and is capped. - **`listLimit` (security audit F4).** A list (`find`, versions, distinct values) asked by a caller that is not staff gets at most **100** documents per request; `pagination=false` and `limit=0` become one page of 100. Before, one diff --git a/reference/.agents/skills/iapl-reference/SKILL.md b/reference/.agents/skills/iapl-reference/SKILL.md index f05933f..d85fd5b 100644 --- a/reference/.agents/skills/iapl-reference/SKILL.md +++ b/reference/.agents/skills/iapl-reference/SKILL.md @@ -47,7 +47,7 @@ description: Complete map of everything @intecion/ipal-kit provides — every ia | `secrets.reenterOnChange` | on | a save through access control that changes `smtpHost`, `smtpPort` or `smtpUser` while a password is stored must send the password again or remove it (`400` on the field otherwise), whatever `emailTransport` says — so an admin session cannot send the stored password to a server of its own. A change of the transport alone, and the Local API with access control off, are not asked | `false` = the stored password follows the new server | | `dashboardAlerts` | `{ integrations: 'admin', cookies: 'editor' }` | who sees the plugin's dashboard alerts: integration details (error text, link) for `integrations` and above, a neutral "ask an administrator" for editors below it, nothing for others; the cookie crawl / approval alert for `cookies` and above. With a role, a session that owes its second factor sees none | `integrations: 'editor' | 'all'`, `cookies: 'all'` (`'all'` = as before: no role and no second factor is checked) | | `strictAccessAnswers` | `true` (1.18.0) | a project's access callback (`cookieScanner.access`, the doctor's `access`) allows only on a literal `true`; `req.user`, `1`, a string, an un-awaited Promise refuse; a non-boolean answer is reported once per option | `false` = any truthy answer allows (as before 1.18.0) | -| `listLimit` | `{ max: 100, staff: false }` (1.18.0, audit F4) | a REST / GraphQL list (`find`, versions, distinct) from a caller that is not staff gets at most `max` documents; `pagination=false` / `limit=0` become one page; staff and the Local API untouched | `false` (Payload's behaviour); `{ max, staff: true, exclude: ['slug'] }`; `buildQueryGuardHook` for a collection added after iapl | +| `listLimit` | `{ max: 100, staff: false }` (1.18.0, audit F4) | a REST / GraphQL list (`find`, versions, distinct) from a caller that is not staff gets at most `max` documents; `pagination=false` / `limit=0` become one page; staff, the Local API and server reads with `overrideAccess: true` that pass a request on untouched | `false` (Payload's behaviour); `{ max, staff: true, exclude: ['slug'] }`; `buildQueryGuardHook` for a collection added after iapl | | `refuseOperatorSort` | `true` (1.18.0, audit F5) | a `sort` naming a database operator (`$where`, `-$natural`, `a.$ne`) → `400` for everyone, logged as one `info` line (`RefusedSortError`) | `false`; `loggingLevels: { RefusedSortError: false }` hides the log line | | `lockedDocuments` | staff only (1.18.0) | Payload's document locks (`payload-locked-documents`) for staff accounts with the second factor; Payload's default was any signed-in account | `false` (Payload's default); `{ access: { read, create, update, delete } }` | | `adminSameOrigin` | on (1.17.2) | `POST` mail service connect / disconnect, test e-mail, cookie scan / approval / crawl refuse (`403`) a request a browser marks as coming from another origin; own origins: the request's host, `serverURL`, `csrf`, `cors`, `origins` | `{ origins: [...] }` adds origins; `false` = no check; any other value stops the start | diff --git a/reference/src/payload-types.ts b/reference/src/payload-types.ts index c554251..59f3bf0 100644 --- a/reference/src/payload-types.ts +++ b/reference/src/payload-types.ts @@ -63,20 +63,7 @@ export type SupportedTimezones = export interface Config { auth: { - 'e2e-crew': E2ECrewAuthOperations; - 'e2e-staff': E2EStaffAuthOperations; - 'e2e-team': E2ETeamAuthOperations; users: UserAuthOperations; - 'e2e-copy': E2ECopyAuthOperations; - 'e2e-copy-own-rules': E2ECopyOwnRuleAuthOperations; - 'e2e-copy-cross-op': E2ECopyCrossOpAuthOperations; - 'e2e-copy-values': E2ECopyValueAuthOperations; - 'e2e-copy-team-admin': E2ECopyTeamAdminAuthOperations; - 'e2e-copy-opt-out': E2ECopyOptOutAuthOperations; - 'e2e-copy-not-staff': E2ECopyNotStaffAuthOperations; - 'late-staff': LateStaffAuthOperations; - 'e2e-late-text': E2ELateTextAuthOperations; - 'e2e-visitors': E2EVisitorAuthOperations; }; blocks: {}; collections: { @@ -84,26 +71,12 @@ export interface Config { posts: Post; caseStudies: CaseStudy; media: Media; - 'e2e-crew': E2ECrew; - 'e2e-staff': E2EStaff; - 'e2e-team': E2ETeam; users: User; forms: Form; 'form-submissions': FormSubmission; 'consent-records': ConsentRecord; 'cookie-review': CookieReview; - 'e2e-copy': E2ECopy; - 'e2e-copy-own-rules': E2ECopyOwnRule; - 'e2e-copy-cross-op': E2ECopyCrossOp; - 'e2e-copy-values': E2ECopyValue; - 'e2e-copy-team-admin': E2ECopyTeamAdmin; - 'e2e-copy-opt-out': E2ECopyOptOut; - 'e2e-copy-not-staff': E2ECopyNotStaff; - 'late-staff': LateStaff; - 'e2e-late-text': E2ELateText; - 'e2e-visitors': E2EVisitor; 'payload-kv': PayloadKv; - 'payload-jobs': PayloadJob; 'payload-locked-documents': PayloadLockedDocument; 'payload-preferences': PayloadPreference; 'payload-migrations': PayloadMigration; @@ -114,26 +87,12 @@ export interface Config { posts: PostsSelect | PostsSelect; caseStudies: CaseStudiesSelect | CaseStudiesSelect; media: MediaSelect | MediaSelect; - 'e2e-crew': E2ECrewSelect | E2ECrewSelect; - 'e2e-staff': E2EStaffSelect | E2EStaffSelect; - 'e2e-team': E2ETeamSelect | E2ETeamSelect; users: UsersSelect | UsersSelect; forms: FormsSelect | FormsSelect; 'form-submissions': FormSubmissionsSelect | FormSubmissionsSelect; 'consent-records': ConsentRecordsSelect | ConsentRecordsSelect; 'cookie-review': CookieReviewSelect | CookieReviewSelect; - 'e2e-copy': E2ECopySelect | E2ECopySelect; - 'e2e-copy-own-rules': E2ECopyOwnRulesSelect | E2ECopyOwnRulesSelect; - 'e2e-copy-cross-op': E2ECopyCrossOpSelect | E2ECopyCrossOpSelect; - 'e2e-copy-values': E2ECopyValuesSelect | E2ECopyValuesSelect; - 'e2e-copy-team-admin': E2ECopyTeamAdminSelect | E2ECopyTeamAdminSelect; - 'e2e-copy-opt-out': E2ECopyOptOutSelect | E2ECopyOptOutSelect; - 'e2e-copy-not-staff': E2ECopyNotStaffSelect | E2ECopyNotStaffSelect; - 'late-staff': LateStaffSelect | LateStaffSelect; - 'e2e-late-text': E2ELateTextSelect | E2ELateTextSelect; - 'e2e-visitors': E2EVisitorsSelect | E2EVisitorsSelect; 'payload-kv': PayloadKvSelect | PayloadKvSelect; - 'payload-jobs': PayloadJobsSelect | PayloadJobsSelect; 'payload-locked-documents': PayloadLockedDocumentsSelect | PayloadLockedDocumentsSelect; 'payload-preferences': PayloadPreferencesSelect | PayloadPreferencesSelect; 'payload-migrations': PayloadMigrationsSelect | PayloadMigrationsSelect; @@ -166,86 +125,12 @@ export interface Config { widgets: { collections: CollectionsWidget; }; - user: - | E2ECrew - | E2EStaff - | E2ETeam - | User - | E2ECopy - | E2ECopyOwnRule - | E2ECopyCrossOp - | E2ECopyValue - | E2ECopyTeamAdmin - | E2ECopyOptOut - | E2ECopyNotStaff - | LateStaff - | E2ELateText - | E2EVisitor; + user: User; jobs: { - tasks: { - e2eNoop: TaskE2ENoop; - inline: { - input: unknown; - output: unknown; - }; - }; + tasks: unknown; workflows: unknown; }; } -export interface E2ECrewAuthOperations { - forgotPassword: { - email: string; - password: string; - }; - login: { - email: string; - password: string; - }; - registerFirstUser: { - email: string; - password: string; - }; - unlock: { - email: string; - password: string; - }; -} -export interface E2EStaffAuthOperations { - forgotPassword: { - email: string; - password: string; - }; - login: { - email: string; - password: string; - }; - registerFirstUser: { - email: string; - password: string; - }; - unlock: { - email: string; - password: string; - }; -} -export interface E2ETeamAuthOperations { - forgotPassword: { - email: string; - password: string; - }; - login: { - email: string; - password: string; - }; - registerFirstUser: { - email: string; - password: string; - }; - unlock: { - email: string; - password: string; - }; -} export interface UserAuthOperations { forgotPassword: { email: string; @@ -264,186 +149,6 @@ export interface UserAuthOperations { password: string; }; } -export interface E2ECopyAuthOperations { - forgotPassword: { - email: string; - password: string; - }; - login: { - email: string; - password: string; - }; - registerFirstUser: { - email: string; - password: string; - }; - unlock: { - email: string; - password: string; - }; -} -export interface E2ECopyOwnRuleAuthOperations { - forgotPassword: { - email: string; - password: string; - }; - login: { - email: string; - password: string; - }; - registerFirstUser: { - email: string; - password: string; - }; - unlock: { - email: string; - password: string; - }; -} -export interface E2ECopyCrossOpAuthOperations { - forgotPassword: { - email: string; - password: string; - }; - login: { - email: string; - password: string; - }; - registerFirstUser: { - email: string; - password: string; - }; - unlock: { - email: string; - password: string; - }; -} -export interface E2ECopyValueAuthOperations { - forgotPassword: { - email: string; - password: string; - }; - login: { - email: string; - password: string; - }; - registerFirstUser: { - email: string; - password: string; - }; - unlock: { - email: string; - password: string; - }; -} -export interface E2ECopyTeamAdminAuthOperations { - forgotPassword: { - email: string; - password: string; - }; - login: { - email: string; - password: string; - }; - registerFirstUser: { - email: string; - password: string; - }; - unlock: { - email: string; - password: string; - }; -} -export interface E2ECopyOptOutAuthOperations { - forgotPassword: { - email: string; - password: string; - }; - login: { - email: string; - password: string; - }; - registerFirstUser: { - email: string; - password: string; - }; - unlock: { - email: string; - password: string; - }; -} -export interface E2ECopyNotStaffAuthOperations { - forgotPassword: { - email: string; - password: string; - }; - login: { - email: string; - password: string; - }; - registerFirstUser: { - email: string; - password: string; - }; - unlock: { - email: string; - password: string; - }; -} -export interface LateStaffAuthOperations { - forgotPassword: { - email: string; - password: string; - }; - login: { - email: string; - password: string; - }; - registerFirstUser: { - email: string; - password: string; - }; - unlock: { - email: string; - password: string; - }; -} -export interface E2ELateTextAuthOperations { - forgotPassword: { - email: string; - password: string; - }; - login: { - email: string; - password: string; - }; - registerFirstUser: { - email: string; - password: string; - }; - unlock: { - email: string; - password: string; - }; -} -export interface E2EVisitorAuthOperations { - forgotPassword: { - email: string; - password: string; - }; - login: { - email: string; - password: string; - }; - registerFirstUser: { - email: string; - password: string; - }; - unlock: { - email: string; - password: string; - }; -} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "pages". @@ -1579,99 +1284,6 @@ export interface CaseStudy { updatedAt: string; createdAt: string; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "e2e-crew". - */ -export interface E2ECrew { - id: string; - roles?: ('user' | 'editor' | 'admin' | 'boss')[] | null; - /** - * Needed only to change your own e-mail address or password. - */ - currentPassword?: string | null; - updatedAt: string; - createdAt: string; - email: string; - resetPasswordToken?: string | null; - resetPasswordExpiration?: string | null; - salt?: string | null; - hash?: string | null; - resetPasswordRequestedAt?: string | null; - loginAttempts?: number | null; - lockUntil?: string | null; - sessions?: - | { - id: string; - createdAt?: string | null; - expiresAt: string; - }[] - | null; - password?: string | null; - collection: 'e2e-crew'; -} -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "e2e-staff". - */ -export interface E2EStaff { - id: string; - roles?: ('user' | 'editor' | 'admin')[] | null; - /** - * Needed only to change your own e-mail address or password. - */ - currentPassword?: string | null; - updatedAt: string; - createdAt: string; - email: string; - resetPasswordToken?: string | null; - resetPasswordExpiration?: string | null; - salt?: string | null; - hash?: string | null; - resetPasswordRequestedAt?: string | null; - loginAttempts?: number | null; - lockUntil?: string | null; - sessions?: - | { - id: string; - createdAt?: string | null; - expiresAt: string; - }[] - | null; - password?: string | null; - collection: 'e2e-staff'; -} -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "e2e-team". - */ -export interface E2ETeam { - id: string; - roles?: ('lead' | 'member')[] | null; - /** - * Needed only to change your own e-mail address or password. - */ - currentPassword?: string | null; - updatedAt: string; - createdAt: string; - email: string; - resetPasswordToken?: string | null; - resetPasswordExpiration?: string | null; - salt?: string | null; - hash?: string | null; - resetPasswordRequestedAt?: string | null; - loginAttempts?: number | null; - lockUntil?: string | null; - sessions?: - | { - id: string; - createdAt?: string | null; - expiresAt: string; - }[] - | null; - password?: string | null; - collection: 'e2e-team'; -} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "users". @@ -1821,291 +1433,6 @@ export interface CookieReview { updatedAt: string; createdAt: string; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "e2e-copy". - */ -export interface E2ECopy { - id: string; - roles?: ('user' | 'editor' | 'admin')[] | null; - /** - * Needed only to change your own e-mail address or password. - */ - currentPassword?: string | null; - updatedAt: string; - createdAt: string; - email: string; - resetPasswordToken?: string | null; - resetPasswordExpiration?: string | null; - salt?: string | null; - hash?: string | null; - resetPasswordRequestedAt?: string | null; - loginAttempts?: number | null; - lockUntil?: string | null; - sessions?: - | { - id: string; - createdAt?: string | null; - expiresAt: string; - }[] - | null; - password?: string | null; - collection: 'e2e-copy'; -} -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "e2e-copy-own-rules". - */ -export interface E2ECopyOwnRule { - id: string; - roles?: ('user' | 'editor' | 'admin')[] | null; - /** - * Needed only to change your own e-mail address or password. - */ - currentPassword?: string | null; - updatedAt: string; - createdAt: string; - email: string; - resetPasswordToken?: string | null; - resetPasswordExpiration?: string | null; - salt?: string | null; - hash?: string | null; - resetPasswordRequestedAt?: string | null; - loginAttempts?: number | null; - lockUntil?: string | null; - sessions?: - | { - id: string; - createdAt?: string | null; - expiresAt: string; - }[] - | null; - password?: string | null; - collection: 'e2e-copy-own-rules'; -} -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "e2e-copy-cross-op". - */ -export interface E2ECopyCrossOp { - id: string; - roles?: ('user' | 'editor' | 'admin')[] | null; - /** - * Needed only to change your own e-mail address or password. - */ - currentPassword?: string | null; - updatedAt: string; - createdAt: string; - email: string; - resetPasswordToken?: string | null; - resetPasswordExpiration?: string | null; - salt?: string | null; - hash?: string | null; - resetPasswordRequestedAt?: string | null; - loginAttempts?: number | null; - lockUntil?: string | null; - sessions?: - | { - id: string; - createdAt?: string | null; - expiresAt: string; - }[] - | null; - password?: string | null; - collection: 'e2e-copy-cross-op'; -} -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "e2e-copy-values". - */ -export interface E2ECopyValue { - id: string; - roles?: ('user' | 'editor' | 'admin' | 'boss')[] | null; - updatedAt: string; - createdAt: string; - email: string; - resetPasswordToken?: string | null; - resetPasswordExpiration?: string | null; - salt?: string | null; - hash?: string | null; - resetPasswordRequestedAt?: string | null; - loginAttempts?: number | null; - lockUntil?: string | null; - sessions?: - | { - id: string; - createdAt?: string | null; - expiresAt: string; - }[] - | null; - password?: string | null; - collection: 'e2e-copy-values'; -} -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "e2e-copy-team-admin". - */ -export interface E2ECopyTeamAdmin { - id: string; - roles?: ('user' | 'editor' | 'admin')[] | null; - updatedAt: string; - createdAt: string; - email: string; - resetPasswordToken?: string | null; - resetPasswordExpiration?: string | null; - salt?: string | null; - hash?: string | null; - resetPasswordRequestedAt?: string | null; - loginAttempts?: number | null; - lockUntil?: string | null; - sessions?: - | { - id: string; - createdAt?: string | null; - expiresAt: string; - }[] - | null; - password?: string | null; - collection: 'e2e-copy-team-admin'; -} -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "e2e-copy-opt-out". - */ -export interface E2ECopyOptOut { - id: string; - roles?: ('user' | 'editor' | 'admin')[] | null; - updatedAt: string; - createdAt: string; - email: string; - resetPasswordToken?: string | null; - resetPasswordExpiration?: string | null; - salt?: string | null; - hash?: string | null; - resetPasswordRequestedAt?: string | null; - loginAttempts?: number | null; - lockUntil?: string | null; - sessions?: - | { - id: string; - createdAt?: string | null; - expiresAt: string; - }[] - | null; - password?: string | null; - collection: 'e2e-copy-opt-out'; -} -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "e2e-copy-not-staff". - */ -export interface E2ECopyNotStaff { - id: string; - roles?: ('user' | 'editor' | 'admin')[] | null; - /** - * Needed only to change your own e-mail address or password. - */ - currentPassword?: string | null; - updatedAt: string; - createdAt: string; - email: string; - resetPasswordToken?: string | null; - resetPasswordExpiration?: string | null; - salt?: string | null; - hash?: string | null; - resetPasswordRequestedAt?: string | null; - loginAttempts?: number | null; - lockUntil?: string | null; - sessions?: - | { - id: string; - createdAt?: string | null; - expiresAt: string; - }[] - | null; - password?: string | null; - collection: 'e2e-copy-not-staff'; -} -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "late-staff". - */ -export interface LateStaff { - id: string; - roles?: ('user' | 'editor' | 'admin')[] | null; - updatedAt: string; - createdAt: string; - email: string; - resetPasswordToken?: string | null; - resetPasswordExpiration?: string | null; - salt?: string | null; - hash?: string | null; - resetPasswordRequestedAt?: string | null; - loginAttempts?: number | null; - lockUntil?: string | null; - sessions?: - | { - id: string; - createdAt?: string | null; - expiresAt: string; - }[] - | null; - password?: string | null; - collection: 'late-staff'; -} -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "e2e-late-text". - */ -export interface E2ELateText { - id: string; - roles?: string[] | null; - updatedAt: string; - createdAt: string; - email: string; - resetPasswordToken?: string | null; - resetPasswordExpiration?: string | null; - salt?: string | null; - hash?: string | null; - resetPasswordRequestedAt?: string | null; - loginAttempts?: number | null; - lockUntil?: string | null; - sessions?: - | { - id: string; - createdAt?: string | null; - expiresAt: string; - }[] - | null; - password?: string | null; - collection: 'e2e-late-text'; -} -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "e2e-visitors". - */ -export interface E2EVisitor { - id: string; - updatedAt: string; - createdAt: string; - email: string; - resetPasswordToken?: string | null; - resetPasswordExpiration?: string | null; - salt?: string | null; - hash?: string | null; - resetPasswordRequestedAt?: string | null; - loginAttempts?: number | null; - lockUntil?: string | null; - sessions?: - | { - id: string; - createdAt?: string | null; - expiresAt: string; - }[] - | null; - password?: string | null; - collection: 'e2e-visitors'; -} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "payload-kv". @@ -2123,98 +1450,6 @@ export interface PayloadKv { | boolean | null; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "payload-jobs". - */ -export interface PayloadJob { - id: string; - /** - * Input data provided to the job - */ - input?: - | { - [k: string]: unknown; - } - | unknown[] - | string - | number - | boolean - | null; - taskStatus?: - | { - [k: string]: unknown; - } - | unknown[] - | string - | number - | boolean - | null; - completedAt?: string | null; - totalTried?: number | null; - /** - * If hasError is true this job will not be retried - */ - hasError?: boolean | null; - /** - * If hasError is true, this is the error that caused it - */ - error?: - | { - [k: string]: unknown; - } - | unknown[] - | string - | number - | boolean - | null; - /** - * Task execution log - */ - log?: - | { - executedAt: string; - completedAt: string; - taskSlug: 'inline' | 'e2eNoop'; - taskID: string; - input?: - | { - [k: string]: unknown; - } - | unknown[] - | string - | number - | boolean - | null; - output?: - | { - [k: string]: unknown; - } - | unknown[] - | string - | number - | boolean - | null; - state: 'failed' | 'succeeded'; - error?: - | { - [k: string]: unknown; - } - | unknown[] - | string - | number - | boolean - | null; - id?: string | null; - }[] - | null; - taskSlug?: ('inline' | 'e2eNoop') | null; - queue?: string | null; - waitUntil?: string | null; - processing?: boolean | null; - updatedAt: string; - createdAt: string; -} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "payload-locked-documents". @@ -2238,18 +1473,6 @@ export interface PayloadLockedDocument { relationTo: 'media'; value: string | Media; } | null) - | ({ - relationTo: 'e2e-crew'; - value: string | E2ECrew; - } | null) - | ({ - relationTo: 'e2e-staff'; - value: string | E2EStaff; - } | null) - | ({ - relationTo: 'e2e-team'; - value: string | E2ETeam; - } | null) | ({ relationTo: 'users'; value: string | User; @@ -2269,105 +1492,12 @@ export interface PayloadLockedDocument { | ({ relationTo: 'cookie-review'; value: string | CookieReview; - } | null) - | ({ - relationTo: 'e2e-copy'; - value: string | E2ECopy; - } | null) - | ({ - relationTo: 'e2e-copy-own-rules'; - value: string | E2ECopyOwnRule; - } | null) - | ({ - relationTo: 'e2e-copy-cross-op'; - value: string | E2ECopyCrossOp; - } | null) - | ({ - relationTo: 'e2e-copy-values'; - value: string | E2ECopyValue; - } | null) - | ({ - relationTo: 'e2e-copy-team-admin'; - value: string | E2ECopyTeamAdmin; - } | null) - | ({ - relationTo: 'e2e-copy-opt-out'; - value: string | E2ECopyOptOut; - } | null) - | ({ - relationTo: 'e2e-copy-not-staff'; - value: string | E2ECopyNotStaff; - } | null) - | ({ - relationTo: 'late-staff'; - value: string | LateStaff; - } | null) - | ({ - relationTo: 'e2e-late-text'; - value: string | E2ELateText; - } | null) - | ({ - relationTo: 'e2e-visitors'; - value: string | E2EVisitor; } | null); globalSlug?: string | null; - user: - | { - relationTo: 'e2e-crew'; - value: string | E2ECrew; - } - | { - relationTo: 'e2e-staff'; - value: string | E2EStaff; - } - | { - relationTo: 'e2e-team'; - value: string | E2ETeam; - } - | { - relationTo: 'users'; - value: string | User; - } - | { - relationTo: 'e2e-copy'; - value: string | E2ECopy; - } - | { - relationTo: 'e2e-copy-own-rules'; - value: string | E2ECopyOwnRule; - } - | { - relationTo: 'e2e-copy-cross-op'; - value: string | E2ECopyCrossOp; - } - | { - relationTo: 'e2e-copy-values'; - value: string | E2ECopyValue; - } - | { - relationTo: 'e2e-copy-team-admin'; - value: string | E2ECopyTeamAdmin; - } - | { - relationTo: 'e2e-copy-opt-out'; - value: string | E2ECopyOptOut; - } - | { - relationTo: 'e2e-copy-not-staff'; - value: string | E2ECopyNotStaff; - } - | { - relationTo: 'late-staff'; - value: string | LateStaff; - } - | { - relationTo: 'e2e-late-text'; - value: string | E2ELateText; - } - | { - relationTo: 'e2e-visitors'; - value: string | E2EVisitor; - }; + user: { + relationTo: 'users'; + value: string | User; + }; updatedAt: string; createdAt: string; } @@ -2377,63 +1507,10 @@ export interface PayloadLockedDocument { */ export interface PayloadPreference { id: string; - user: - | { - relationTo: 'e2e-crew'; - value: string | E2ECrew; - } - | { - relationTo: 'e2e-staff'; - value: string | E2EStaff; - } - | { - relationTo: 'e2e-team'; - value: string | E2ETeam; - } - | { - relationTo: 'users'; - value: string | User; - } - | { - relationTo: 'e2e-copy'; - value: string | E2ECopy; - } - | { - relationTo: 'e2e-copy-own-rules'; - value: string | E2ECopyOwnRule; - } - | { - relationTo: 'e2e-copy-cross-op'; - value: string | E2ECopyCrossOp; - } - | { - relationTo: 'e2e-copy-values'; - value: string | E2ECopyValue; - } - | { - relationTo: 'e2e-copy-team-admin'; - value: string | E2ECopyTeamAdmin; - } - | { - relationTo: 'e2e-copy-opt-out'; - value: string | E2ECopyOptOut; - } - | { - relationTo: 'e2e-copy-not-staff'; - value: string | E2ECopyNotStaff; - } - | { - relationTo: 'late-staff'; - value: string | LateStaff; - } - | { - relationTo: 'e2e-late-text'; - value: string | E2ELateText; - } - | { - relationTo: 'e2e-visitors'; - value: string | E2EVisitor; - }; + user: { + relationTo: 'users'; + value: string | User; + }; key?: string | null; value?: | { @@ -2998,81 +2075,6 @@ export interface MediaSelect { focalX?: T; focalY?: T; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "e2e-crew_select". - */ -export interface E2ECrewSelect { - roles?: T; - currentPassword?: T; - updatedAt?: T; - createdAt?: T; - email?: T; - resetPasswordToken?: T; - resetPasswordExpiration?: T; - salt?: T; - hash?: T; - resetPasswordRequestedAt?: T; - loginAttempts?: T; - lockUntil?: T; - sessions?: - | T - | { - id?: T; - createdAt?: T; - expiresAt?: T; - }; -} -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "e2e-staff_select". - */ -export interface E2EStaffSelect { - roles?: T; - currentPassword?: T; - updatedAt?: T; - createdAt?: T; - email?: T; - resetPasswordToken?: T; - resetPasswordExpiration?: T; - salt?: T; - hash?: T; - resetPasswordRequestedAt?: T; - loginAttempts?: T; - lockUntil?: T; - sessions?: - | T - | { - id?: T; - createdAt?: T; - expiresAt?: T; - }; -} -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "e2e-team_select". - */ -export interface E2ETeamSelect { - roles?: T; - currentPassword?: T; - updatedAt?: T; - createdAt?: T; - email?: T; - resetPasswordToken?: T; - resetPasswordExpiration?: T; - salt?: T; - hash?: T; - resetPasswordRequestedAt?: T; - loginAttempts?: T; - lockUntil?: T; - sessions?: - | T - | { - id?: T; - createdAt?: T; - expiresAt?: T; - }; -} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "users_select". @@ -3473,249 +2475,6 @@ export interface CookieReviewSelect { updatedAt?: T; createdAt?: T; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "e2e-copy_select". - */ -export interface E2ECopySelect { - roles?: T; - currentPassword?: T; - updatedAt?: T; - createdAt?: T; - email?: T; - resetPasswordToken?: T; - resetPasswordExpiration?: T; - salt?: T; - hash?: T; - resetPasswordRequestedAt?: T; - loginAttempts?: T; - lockUntil?: T; - sessions?: - | T - | { - id?: T; - createdAt?: T; - expiresAt?: T; - }; -} -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "e2e-copy-own-rules_select". - */ -export interface E2ECopyOwnRulesSelect { - roles?: T; - currentPassword?: T; - updatedAt?: T; - createdAt?: T; - email?: T; - resetPasswordToken?: T; - resetPasswordExpiration?: T; - salt?: T; - hash?: T; - resetPasswordRequestedAt?: T; - loginAttempts?: T; - lockUntil?: T; - sessions?: - | T - | { - id?: T; - createdAt?: T; - expiresAt?: T; - }; -} -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "e2e-copy-cross-op_select". - */ -export interface E2ECopyCrossOpSelect { - roles?: T; - currentPassword?: T; - updatedAt?: T; - createdAt?: T; - email?: T; - resetPasswordToken?: T; - resetPasswordExpiration?: T; - salt?: T; - hash?: T; - resetPasswordRequestedAt?: T; - loginAttempts?: T; - lockUntil?: T; - sessions?: - | T - | { - id?: T; - createdAt?: T; - expiresAt?: T; - }; -} -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "e2e-copy-values_select". - */ -export interface E2ECopyValuesSelect { - roles?: T; - updatedAt?: T; - createdAt?: T; - email?: T; - resetPasswordToken?: T; - resetPasswordExpiration?: T; - salt?: T; - hash?: T; - resetPasswordRequestedAt?: T; - loginAttempts?: T; - lockUntil?: T; - sessions?: - | T - | { - id?: T; - createdAt?: T; - expiresAt?: T; - }; -} -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "e2e-copy-team-admin_select". - */ -export interface E2ECopyTeamAdminSelect { - roles?: T; - updatedAt?: T; - createdAt?: T; - email?: T; - resetPasswordToken?: T; - resetPasswordExpiration?: T; - salt?: T; - hash?: T; - resetPasswordRequestedAt?: T; - loginAttempts?: T; - lockUntil?: T; - sessions?: - | T - | { - id?: T; - createdAt?: T; - expiresAt?: T; - }; -} -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "e2e-copy-opt-out_select". - */ -export interface E2ECopyOptOutSelect { - roles?: T; - updatedAt?: T; - createdAt?: T; - email?: T; - resetPasswordToken?: T; - resetPasswordExpiration?: T; - salt?: T; - hash?: T; - resetPasswordRequestedAt?: T; - loginAttempts?: T; - lockUntil?: T; - sessions?: - | T - | { - id?: T; - createdAt?: T; - expiresAt?: T; - }; -} -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "e2e-copy-not-staff_select". - */ -export interface E2ECopyNotStaffSelect { - roles?: T; - currentPassword?: T; - updatedAt?: T; - createdAt?: T; - email?: T; - resetPasswordToken?: T; - resetPasswordExpiration?: T; - salt?: T; - hash?: T; - resetPasswordRequestedAt?: T; - loginAttempts?: T; - lockUntil?: T; - sessions?: - | T - | { - id?: T; - createdAt?: T; - expiresAt?: T; - }; -} -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "late-staff_select". - */ -export interface LateStaffSelect { - roles?: T; - updatedAt?: T; - createdAt?: T; - email?: T; - resetPasswordToken?: T; - resetPasswordExpiration?: T; - salt?: T; - hash?: T; - resetPasswordRequestedAt?: T; - loginAttempts?: T; - lockUntil?: T; - sessions?: - | T - | { - id?: T; - createdAt?: T; - expiresAt?: T; - }; -} -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "e2e-late-text_select". - */ -export interface E2ELateTextSelect { - roles?: T; - updatedAt?: T; - createdAt?: T; - email?: T; - resetPasswordToken?: T; - resetPasswordExpiration?: T; - salt?: T; - hash?: T; - resetPasswordRequestedAt?: T; - loginAttempts?: T; - lockUntil?: T; - sessions?: - | T - | { - id?: T; - createdAt?: T; - expiresAt?: T; - }; -} -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "e2e-visitors_select". - */ -export interface E2EVisitorsSelect { - updatedAt?: T; - createdAt?: T; - email?: T; - resetPasswordToken?: T; - resetPasswordExpiration?: T; - salt?: T; - hash?: T; - resetPasswordRequestedAt?: T; - loginAttempts?: T; - lockUntil?: T; - sessions?: - | T - | { - id?: T; - createdAt?: T; - expiresAt?: T; - }; -} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "payload-kv_select". @@ -3724,37 +2483,6 @@ export interface PayloadKvSelect { key?: T; data?: T; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "payload-jobs_select". - */ -export interface PayloadJobsSelect { - input?: T; - taskStatus?: T; - completedAt?: T; - totalTried?: T; - hasError?: T; - error?: T; - log?: - | T - | { - executedAt?: T; - completedAt?: T; - taskSlug?: T; - taskID?: T; - input?: T; - output?: T; - state?: T; - error?: T; - id?: T; - }; - taskSlug?: T; - queue?: T; - waitUntil?: T; - processing?: T; - updatedAt?: T; - createdAt?: T; -} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "payload-locked-documents_select". @@ -4653,14 +3381,6 @@ export interface CollectionsWidget { }; width: 'full'; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "TaskE2eNoop". - */ -export interface TaskE2ENoop { - input?: unknown; - output?: unknown; -} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "auth". diff --git a/src/modules/security/queryGuard.ts b/src/modules/security/queryGuard.ts index d54235a..098694d 100644 --- a/src/modules/security/queryGuard.ts +++ b/src/modules/security/queryGuard.ts @@ -10,7 +10,8 @@ import { secondFactorPassed } from './totp/secondFactor.js' * Payload's document locks closed to visitor accounts (the "document locks" door). Each is on by default, each can be * turned off or adapted, and every piece is exported for a project's own use (docs/security.md "Lists and sorting"). * - * Local API calls (`req.payloadAPI === 'local'`: the frontend, seeds, the project's own code) are never touched. + * Local API calls (`req.payloadAPI === 'local'`: the frontend, seeds, the project's own code) are never touched, nor + * is a read with `overrideAccess: true` that server code makes while passing an outside request on. */ export type ListLimitOptions = { @@ -92,6 +93,9 @@ export function buildQueryGuardHook(options: { throw new RefusedSortError() } if (!limit || list.id != null || limit.exclude?.includes(collection.slug)) {return args} + // A read that bypasses access is the server's own (the plugin's or the project's code passing the request on, e.g. + // the cookie scanner's scheduled crawl, which has no account): never capped. REST and GraphQL never set it. + if ((args as { overrideAccess?: unknown }).overrideAccess === true) {return args} if (!limit.staff && isStaffRequest(req)) {return args} return capListLimit(list, limit.max) }) as CollectionBeforeOperationHook diff --git a/test/queryGuardHttp.test.ts b/test/queryGuardHttp.test.ts index 16e38ce..6642b68 100644 --- a/test/queryGuardHttp.test.ts +++ b/test/queryGuardHttp.test.ts @@ -45,6 +45,18 @@ beforeAll(async () => { { slug: 'media', fields: [], upload: { staticDir: path.join(os.tmpdir(), 'ipal-test-media') } }, ], db: testDatabase('query_guard'), + // the server's own read on behalf of a request without an account (the cookie scanner's scheduled crawl does this) + endpoints: [ + { + handler: async (req) => { + const all = await req.payload.find({ collection: 'notes' as never, depth: 0, limit: 0, overrideAccess: true, pagination: false, req }) + const asCaller = await req.payload.find({ collection: 'notes' as never, depth: 0, limit: 0, overrideAccess: false, pagination: false, req }) + return Response.json({ all: all.docs.length, asCaller: asCaller.docs.length }) + }, + method: 'get', + path: '/own-read', + }, + ], editor: lexicalEditor(), plugins: [iapl({ access: { authCollection: 'users' }, i18n: { defaultLocale: 'pl', locales: [{ code: 'pl', label: 'Polski' }] }, twoFactor: false })], secret: 'integration-test-secret-0123456789', @@ -81,6 +93,11 @@ describe('F4: public lists are capped for callers that are not staff', () => { expect((await payload.find({ collection: 'notes' as never, limit: 1000 })).docs).toHaveLength(130) }) + test('a read that bypasses access, inside a request without an account, is the server\'s own: not capped', async () => { + const res = await fetch(`${base}/api/own-read`, { headers: { origin: base } }) + expect(await res.json()).toEqual({ all: 130, asCaller: 100 }) + }) + test('GraphQL lists from outside are capped as well', async () => { const res = await fetch(`${base}/api/graphql`, { body: JSON.stringify({ query: '{ Notes(limit: 100000) { docs { id } } }' }), headers: { 'content-type': 'application/json', origin: base }, method: 'POST' }) const body = (await res.json()) as { data?: { Notes?: { docs: unknown[] } } } diff --git a/test/securityClasses.test.ts b/test/securityClasses.test.ts index 40843d2..b986dfc 100644 --- a/test/securityClasses.test.ts +++ b/test/securityClasses.test.ts @@ -249,6 +249,7 @@ describe('denial of service and injection — lists from outside (F4, F5)', () = it('F4: staff, the Local API, one document by id and listLimit: false are left alone; max / exclude / staff adapt it', () => { expect(run({ limit: 5000 }, staff)).toEqual({ limit: 5000 }) expect(run({ limit: 5000 }, { ...visitor, payloadAPI: 'local' })).toEqual({ limit: 5000 }) + expect(run({ limit: 0, overrideAccess: true, pagination: false }, visitor)).toEqual({ limit: 0, overrideAccess: true, pagination: false }) expect(run({ id: 'a', limit: 5000 }, visitor)).toEqual({ id: 'a', limit: 5000 }) expect(run({ limit: 5000 }, visitor, 'read', buildQueryGuardHook({ listLimit: false }))).toEqual({ limit: 5000 }) expect(run({ limit: 5000 }, visitor, 'read', buildQueryGuardHook({ listLimit: { max: 20 } }))).toMatchObject({ limit: 20 })