Merge claude/security-a-1172: a locked staff account answers like a wrong password, IPv6 counted per /64, panel actions only from the site's own origin

plugin.ts import conflict: withVersionReadRules (readPublished fix) and withLockedAnswer both kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-12-01 11:06:15 +01:00
co-authored by Claude Opus 5.5
35 changed files with 882 additions and 31 deletions
+21 -1
View File
@@ -266,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: false, // none of the rules
})
```
@@ -493,10 +494,29 @@ 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) for `lockTime` (10 minutes), 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"`.
## Turn off, override, extend
- **Account rules:** `accounts: false`, or one by one — `panelRole`, `adminOnlyCreate`, `adminOnlyWrite`,
`staffOnlyRead`, `firstUserRoute`, `password` (above).
`staffOnlyRead`, `firstUserRoute`, `password`, `lockedAnswer` (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),