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
+40 -3
View File
@@ -195,10 +195,26 @@ access: { update: requireRole('editor') }
// a collection with drafts: editors (or the role you name) read everything; visitors, plain `user` accounts and a
// session that still owes its second factor read published documents only — by id, in lists, with ?draft=true and
// over GraphQL. Payload's open `read: () => true` answers ?draft=true with the draft itself (1.17.1).
access: { read: readPublished(), readVersions: readPublished() }
access: { read: readPublished('admin') }
// Version history asks for the status at another path: readPublishedVersions() goes on readVersions (1.17.2).
access: { read: readPublished(), readVersions: readPublishedVersions() }
access: { read: readPublished('admin'), readVersions: readPublishedVersions('admin') }
```
**Where each rule may be used.**
| Rule | Where | What a visitor gets |
|---|---|---|
| `readPublished()` | `access.read` of a collection or global with `versions: { drafts: true }` | published documents: by id, lists, `?draft=true`, GraphQL |
| `readPublishedVersions()` | `access.readVersions` of the same collection or global | published versions: the version list, one version by id (a draft one: `403`), the count, GraphQL, the panel's version view |
The two answer with different paths: a document has `_status`, a version has `version._status`. In 1.17.1,
`readVersions: readPublished()` (the form these docs showed) answered every version read with **500** on MongoDB,
Postgres and SQLite. Since 1.17.2, iapl() swaps a `readPublished()` it finds on `readVersions` of a collection or
global for `readPublishedVersions()` with the same role, so that form works too. A collection added by a plugin
listed **after** iapl() is not seen: use `readPublishedVersions()` there, or `withVersionReadRules(collections)`.
Neither rule belongs on a collection without drafts (no `_status`: every read would fail). Check: without a session,
`GET /api/<slug>/versions?limit=10` → `200` with published versions only, never `500`.
A role name the plugin does not know (`requireRole('Admin')`, `readPublished('superadmin')`) throws where the rule
is written; `hasMinimumRole` / `userMeetsRole` answer `false` for it (before 1.17.1 every staff account met it).
`readPublished` with `?draft=true` on a page whose newest version is a draft answers a visitor `404` (Payload applies
@@ -250,6 +266,7 @@ iapl({
// accounts: { firstUserRoute: 'all' }, // Payload's first-user route for every empty auth collection
// accounts: { firstUserRoute: ['users', 'partners'] },
// accounts: { password: { minLength: 16 } }, // or password: false
// accounts: { lockedAnswer: 'payload' }, // a locked staff account is told it is locked (Payload's answer)
// accounts: { signInLimit: { perAddress: 10, windowMinutes: 15 } }, // or signInLimit: false (Payload's lock as before)
// accounts: { signInSameOrigin: { origins: ['https://panel.example.com'] } }, // or signInSameOrigin: false
// accounts: { confirmOwnChanges: false }, // own e-mail / password without the current password (as before)
@@ -480,6 +497,26 @@ characters."; texts `passwordTooShort`, `passwordIsEmail` in `i18n.translations.
`DEFAULT_PASSWORD_MIN_LENGTH`.
- **Check:** create an account with an 11-character password → "The password must have at least 12 characters.".
### A locked staff account answers like a wrong password (`accounts.lockedAnswer`, 1.17.2)
Payload locks an account after `maxLoginAttempts` wrong passwords (5 by default; on staff collections 50 for an hour
since 1.18.0, `signInLimit` below) for `lockTime` (10 minutes by default), and
it checks the lock **before** the password: the locked account then gets `401 "This user is locked due to having too
many failed login attempts."` for any password, while an address with no account always gets `401 "The email or
password provided is incorrect."`. Five wrong guesses told anybody, without a password, whether an address has a
staff account. Now a staff collection's login answers a locked account exactly like a wrong password — the same
status, body and GraphQL `extensions.name` (`AuthenticationError`) — over REST, GraphQL and the panel's sign-in
form. The lock itself is unchanged: the owner's correct password is still refused until it ends, and the owner is
then told "wrong e-mail or password" (an administrator sees `lockUntil` on the account and can unlock it). Visitor
collections (not staff) keep Payload's answer.
- **Turn off:** `accounts: { lockedAnswer: 'payload' }` (Payload's message), or `accounts: false`. Any other value
stops the start.
- **Building blocks:** `lockedLooksWrong` (the config-level `afterError` hook), `withLockedAnswer(config)`,
`graphqlLoginName(collection)` (`login<SingularName>`, as GraphQL names the mutation).
- **Check:** five wrong passwords for an admin's address, then `POST /api/users/login` with the right one → the same
`401` body as for `nobody@example.com`; GraphQL `loginUser` → `extensions.name: "AuthenticationError"`.
### A stranger cannot lock a staff account out (`accounts.signInLimit`, 1.18.0)
Payload locks an account after `maxLoginAttempts` wrong passwords (5) for `lockTime` (10 minutes) — wrong passwords
@@ -548,7 +585,7 @@ current passwords count like failed sign-ins (`signInLimit`). The field is virtu
## Turn off, override, extend
- **Account rules:** `accounts: false`, or one by one — `panelRole`, `adminOnlyCreate`, `adminOnlyWrite`,
`staffOnlyRead`, `firstUserRoute`, `password`, `signInLimit`, `signInSameOrigin`, `confirmOwnChanges` (above).
`staffOnlyRead`, `firstUserRoute`, `password`, `lockedAnswer`, `signInLimit`, `signInSameOrigin`, `confirmOwnChanges` (above).
- **Turn off:** leave out `access` — no `roles` field, the auth collection keeps Payload's rules
(or yours). `access.firstUserAdmin: false` stops giving admin to the first account.
- **Override:** `access.staffCollections` (who is staff), `access.authAccess` (injected collection), your own auth collection (wins whole),