Staff sign-in rules: failures per IP and address, own origin, current password for own changes (1.18.0)

Q2 (IAWL idea 16): Payload locks a staff account after 5 wrong passwords
from anybody, so a stranger kept the owner out without a password. Failed
sign-ins are now counted per client IP and typed address (folded: NFKC,
lower case, trim): 5 in 15 min, then 429 for that IP and address only;
only failures count (a place taken before the compare, given back on
success or refusal; "try again in a moment" while others are being
checked). Payload's own lock stays as the net at 50 failures for an hour
where the project set none. The mail service's account-mail limit now
counts per address per visitor (5) with 20 per address in all, so one
stranger no longer blocks the owner's own reset mail.
Q3 (idea 7): staff login, forgot and reset password refuse a request a
browser marks as coming from another origin (403 before anything is
counted or sent); visitor collections untouched.
Q5 (idea 29): an account that changes its own e-mail, username or password
must send its current password (panel field on the account page via the
plugin's MaskedField, no import-map change; REST and GraphQL). Admins
changing others, server code and API keys are not asked; wrong ones count
like failed sign-ins.
Options accounts.signInLimit / signInSameOrigin / confirmOwnChanges, all
validated at start. Tests: 15 HTTP tests (2FA on/off, all off), fail
before on 1.17.1; built-site spec own-account.spec.ts in e2e:built.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-12-01 11:12:40 +01:00
co-authored by Claude Opus 5.5
parent fc70a34f3e
commit 52710021ef
28 changed files with 839 additions and 21 deletions
+69 -1
View File
@@ -250,6 +250,9 @@ 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: { 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)
// accounts: false, // none of the rules
})
```
@@ -477,10 +480,75 @@ 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 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
from **anybody**: five posts with no password at all kept the owner out, again and again. Now failed sign-ins to a
staff collection are counted **per client IP and typed address**: after **5 failures in 15 minutes** from one IP for
one address, that IP gets `429` ("Too many failed sign-ins to this address from here. Try again in N min.") for that
address; the owner, from anywhere else, signs in. Payload's own per-account lock stays as the net against a spray
from many IPs, at **50 failures, locked for an hour** — set only where the project did not set
`auth.maxLoginAttempts` / `auth.lockTime` itself (a value you wrote stays; no schema change).
- **Only failures count.** A sign-in takes its place before the password is compared (a burst cannot slip under the
limit) and gives it back when it worked, or when it was refused without a compare. Several correct sign-ins at once
from one place may hear "try again in a moment" — nothing is locked.
- **One count for every spelling** of an address: the typed address is folded like the database that folds the most
(case, full-width and compatibility forms — NFKC — and spaces), so `OWNER@…`, `owner@…` and `owner@…` share it.
The "too many" answer is the same for a real and an invented address.
- **The client IP** is `clientIp()` — pin `IAPL_IP_HEADER` in production ([forms.md](./forms.md)). Requests without
an address share one bucket at 20× the limit (`setUnknownIpFactor`). Server code (the Local API) is never limited.
- **Options:** `signInLimit: { perAddress, windowMinutes, accountLock: { maxLoginAttempts, lockTime } }`;
`accountLock: false` = Payload's lock (5, 10 min) beside the per-IP count; `signInLimit: false` = no per-IP count
and Payload's lock as before. Values that make no sense (`0`, `'false'`) stop the start.
- **Check:** five wrong passwords for an editor with `X-Forwarded-For: 198.51.100.1` (behind one proxy, with
`IAPL_IP_HEADER=x-forwarded-for`), then the right one from there → `429`; from `203.0.113.1` → `200`.
- A staff collection a plugin listed after `iapl` adds is not covered (its config is built after these rules).
### Staff sign-in only from the site's own origin (`accounts.signInSameOrigin`, 1.18.0)
Login, "forgot password" and "reset password" of a staff collection refuse (`403`, before anything is counted or sent)
a request a browser marks as coming from another origin (`Origin`, else `Sec-Fetch-Site`) — over REST and GraphQL.
A foreign page could otherwise sign a visitor's browser into an account of the attacker's choosing (login CSRF), or
make visitors' browsers ask for reset mails. Own origins: the request's host (`Host`, `X-Forwarded-Host`),
`serverURL`, Payload's `csrf` and `cors` lists, and `signInSameOrigin.origins`. A request with neither header (a
script, `curl`, a server) passes. Visitor collections (not staff) are not touched — a shop front end on another
domain keeps signing its customers in. The first refusal of each origin is logged with the ways to allow it.
- **A panel or front end that signs staff in from another origin:** `signInSameOrigin: { origins: ['https://…'] }`.
**Behind a proxy that rewrites `Host`** without `serverURL`: set `serverURL` (or the site's own sign-in is refused).
- **Off:** `signInSameOrigin: false`.
- **Check:** `curl -X POST <site>/api/users/login -H 'Origin: https://other.example' -H 'Content-Type: application/json'
-d '{"email":"a@b.c","password":"x"}'` → `403`.
### Changing one's own e-mail or password asks for the current password (`accounts.confirmOwnChanges`, 1.18.0)
A stolen session alone could take an account over: change the e-mail, then "forgot password". Now an account that
changes its **own** e-mail address, username or password must send its current password — in the panel a
**Current password** field on the account's own page (the plugin's `MaskedField`, already in every site's import
map: no `generate:importmap`), over REST / GraphQL `currentPassword` in the body / `data`. Without it: `400` on the
`currentPassword` field ("Enter your current password…"); wrong: `400` ("The current password is not right."). Wrong
current passwords count like failed sign-ins (`signInLimit`). The field is virtual: never stored, never read back.
- **Not asked:** an administrator changing **another** account; other fields of one's own account; server code
(`overrideAccess`); a request with an API key; "forgot password" / "reset password" (the token is the proof).
- **Scripts that change their own password** add `"currentPassword": "<the old one>"` to the body.
- **Off:** `confirmOwnChanges: false`. A project with its own `currentPassword` field keeps its field and its value (the
rule reads the value from it and does not take it out of the save).
- The check uses Payload's stored hash formats (PBKDF2-SHA256 at 600,000 / 100,000 iterations, and the older
25,000-iteration hashes); a hash format a later Payload adds is refused until IAPL knows it (fail closed — the
user then changes the password through "forgot password").
- **Check:** as an editor, `PATCH /api/users/<own id>` with `{ "email": "new@…" }` → `400`; with `"currentPassword"`
→ `200`. In the panel: Account → the new e-mail and "Current password" → saved.
- **Building blocks** of the three rules: `applySignInRules(collection, accounts)`, `buildSignInBeforeOperation`,
`releaseSignInPlace` (`afterLogin`), `settleFailedSignIn` (config `afterError`), `buildCurrentPasswordField`,
`resolveSignInRules`, `foldSignInName`, `passwordMatches`, `CURRENT_PASSWORD_FIELD`; `releaseRateLimit` (gives a
place of `consumeRateLimit` back — for limiters that count failures only).
## Turn off, override, extend
- **Account rules:** `accounts: false`, or one by one — `panelRole`, `adminOnlyCreate`, `adminOnlyWrite`,
`staffOnlyRead`, `firstUserRoute`, `password` (above).
`staffOnlyRead`, `firstUserRoute`, `password`, `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),
+3
View File
@@ -1232,6 +1232,9 @@ add missing hosts with flags / `extra`; (3) change `mode` to `'enforce'` in both
| The SMTP password stays with its server: a save in the panel or over the API that changes the server, port or user name without the password is refused (`400` "Enter the password again…"), whatever the transport says — otherwise an admin session points the server at its own machine and a test e-mail hands the password over. A change of the transport alone asks for nothing. Seeds and scripts (Local API, access control off) are not asked | `secrets: { reenterOnChange: false }` | `writeOnlySecret(field, { boundTo: [...] })`, `buildKeepSecret`, `SMTP_PASSWORD_BOUND_TO` |
| The admin panel opens for `editor` and above; an account with only `user` sees "Unauthorized" (the API is not touched). First start logs how many accounts are below the role | `accounts: { panelRole: 'user' }` (or `false`) | `panelRole: 'admin'`; your own `access.admin`; `panelAccess(role)` |
| Nobody creates an account for themselves, or takes one over. A staff collection (also the project's own, also one a later plugin adds) without a `create` / `update` / `delete` / `unlock` / `read` / `readVersions` rule gets one (on a collection a later plugin adds the plugin's rule is put in front of its own and both must allow; `custom: { ipal: { accountRules: false } }` on it keeps its own): with the plugin's roles, or wherever an account of it can hold `editor` or `admin` (`user, editor, admin, boss`; `viewer, editor`; a `roles` field that is text, json or a relationship holding a list — the value in the account's `roles` array makes a plugin admin or editor; a single-valued `roles` field is not affected: its value never counts) — create, delete, unlock: an admin; update: an admin or the account itself; the `roles` field: only an admin. With roles of its own that hold neither `editor` nor `admin`, or none: an account of that same collection, or a plugin admin, and an account never changes its own roles — **the plugin cannot rank a project's own roles: write that collection's rules** (`iapl-doctor` → `staff-own-roles`). `read`: a staff account. Payload's first-user route answers only for the panel's login collection (the first account, which becomes admin), in any spelling of the URL. `access.firstUserAdmin: false` with a default role below the panel role: the default panel role is not applied (logged), an explicit one is refused at start. With a slug in `access.staffCollections` that is not an auth collection Payload does not start (`/api/health` 503) | `accounts: { adminOnlyCreate: false, adminOnlyWrite: false, staffOnlyRead: false, firstUserRoute: 'all' }` | your own rule wins; `firstUserRoute: ['users', 'partners']`; a collection with open sign-up keeps its routes; `staffCreateAccess`, `staffUpdateAccess(slug)`, `staffReadAccess`, `sameStaffCollectionAccess(slug)`, `rolesByAdminOnly`, `rolesNotOwn(slug)`, `hasPluginRoles`, `applyStaffAccountAccess`, `adoptLateAuthCollections`, `buildFirstUserEndpoint` |
| Failed staff sign-ins counted per client IP and typed address (folded: case, width, NFKC): 5 in 15 min, then `429` for that IP and address; only failures count; Payload's per-account lock raised to 50 failures / 1 hour where the project did not set `maxLoginAttempts` / `lockTime` (1.18.0). Pin `IAPL_IP_HEADER`. **Verify:** 5 wrong passwords with `X-Forwarded-For: 198.51.100.1`, then the right one from there → `429`, from another address → `200` | `accounts: { signInLimit: false }` | `signInLimit: { perAddress, windowMinutes, accountLock: { maxLoginAttempts, lockTime } \| false }`; `applySignInRules`, `releaseRateLimit` |
| Staff login, forgot password and reset password refuse a request a browser marks as coming from another origin (`403`, REST and GraphQL; 1.18.0); visitor collections untouched. **Verify:** `curl -X POST <site>/api/users/login -H 'Origin: https://other.example' …` → `403` | `accounts: { signInSameOrigin: false }` | `signInSameOrigin: { origins: [...] }` |
| Changing one's OWN e-mail, username or password needs the current password: panel field "Current password" on the account page (`MaskedField`, no import-map change), `currentPassword` over REST / GraphQL; admins changing others, server code and API keys are not asked; wrong ones count like failed sign-ins (1.18.0). **Verify:** `PATCH /api/users/<own id> {"email":"…"}` → `400`, with `"currentPassword"` → `200` | `accounts: { confirmOwnChanges: false }` | `buildCurrentPasswordField`, `passwordMatches`, `CURRENT_PASSWORD_FIELD` (access.md) |
| A password set on a staff account has at least 12 characters and is not the e-mail address; existing passwords are not checked | `accounts: { password: false }` | `password: { minLength }`; `checkPassword`, `buildPasswordRuleHook` |
| While Turnstile cannot check (wrong secret, Cloudflare down): a text form is accepted, a form with files is refused | `forms: { turnstileOnConfigError: 'allow' }` | `'reject'`, `{ text, files }`; `turnstileOnConfigError` at a call site wins |
| Dashboard alerts by role: integration details for admins, a neutral line for editors, nothing for others; cookie alerts for editors and above. `'all'` checks nothing — no role, no second factor | `dashboardAlerts: { integrations: 'all', cookies: 'all' }` | `integrations: 'editor'`; the components' `details` / `audience` props |
+1
View File
@@ -1173,6 +1173,7 @@ Rules: AGENT.md §8a.
| `e2e/mail-relay-fixture.ts` | test fixture, on only with E2E_MAIL_RELAY_URL: points the mail service's client at the stand-in the spec starts; never in a real site (a real site names no address) (below) |
| `e2e/mail-relay-setup.ts` | for the mail-service spec: empties the SMTP fields and the stored token, so the next e-mail enrols and goes through the mail service (local database only) (below) |
| `e2e/mail-relay.spec.ts` | the mail service on a built site: the state block in the panel, the first e-mail through the public confirm route, no token in anything the browser receives |
| `e2e/own-account.spec.ts` | built-site test (pnpm e2e:built, 1.18.0): the account page asks for the current password before a new e-mail is saved (accounts.confirmOwnChanges); five failed staff sign-ins from one place answer 429 there, not elsewhere (accounts.signInLimit); a staff sign-in from another origin gets 403 (accounts.signInSameOrigin) |
| `e2e/routes.snapshot.json` | every public route of the site (REST, GraphQL, Next route files) with one line saying who may use it and why — the judged list `routes:check` compares with |
| `e2e/routes.ts` | `routes:check`: the site's public routes against e2e/routes.snapshot.json (`pnpm payload run e2e/routes.ts [update]`; from the repository `pnpm routes:check`) (below) |
| `e2e/sign-in-look.spec.ts` | browser test of the sign-in look (whiteLabel.signIn): the panel comes with the form, sits above it on a phone in both themes, is on forgot / reset / logout too, the language links work, the 2FA code screen keeps its boxes (now named) |
+3
View File
@@ -34,6 +34,9 @@ through this procedure. Ask only when you are missing something you cannot get y
### Build / TypeScript
| Symptom | Cause | Fix |
|---|---|---|
| a sign-in answers `429` "Too many failed sign-ins to this address from here" | 5 failed sign-ins for that address from that client IP in 15 minutes (`accounts.signInLimit`, 1.18.0); everybody behind one IP shares it (an office NAT); without `IAPL_IP_HEADER` everybody may share the no-IP bucket | wait the minutes it names, or sign in from elsewhere; pin `IAPL_IP_HEADER`; more room: `signInLimit: { perAddress: 10 }` |
| staff login / "forgot password" answers `403` and the log says `[iapl] a staff sign-in from origin "…" was refused` | the request came from another origin (`accounts.signInSameOrigin`, 1.18.0): a front end on another domain, or a proxy that rewrites `Host` without `serverURL` | set `serverURL`, or `signInSameOrigin: { origins: ['https://…'] }` |
| saving one's own account answers "Enter your current password to change your e-mail address or password." | `accounts.confirmOwnChanges` (1.18.0): own e-mail / username / password changes need the current password | type it in "Current password" on the account page; scripts send `currentPassword`; off: `confirmOwnChanges: false` |
| the 2FA code screen answers "Too many codes were tried…" (`429` from `/api/verify-totp`) | more than 5 wrong codes for that account in 10 minutes (`twoFactor.verifyLimit`; right codes do not count since 1.17.1). "…being checked right now. Try again in a moment." (`Retry-After: 2`) = several attempts of one account at the same moment, nothing is locked; repeated lines `[iapl] 2FA: too many verify attempts` in the log without the owner trying = someone has the password | wait for the window, enter the current code once; unexplained attempts: change that account's password. Tests that log in often: `verifyLimit: { max: … }` for that environment |
| `isAdmin(req.user)` says `false` for a real administrator on the server, in a process that loads two Payload configs (tests, a multi-site script) | a call without a source counts only collections that are staff in **every** config of the process | pass the source: `isAdmin(req.user, req.payload)` — with it each config gets its own answer |
| `isAdmin(user)` / `isEditor(user)` is always `false` in a client component or in `proxy.ts` | the staff collections are not known there (no config in the browser bundle / middleware), and the predicates fail closed | `isAdmin(user, config)` with `useConfig()`, imported from `@intecion/ipal-kit/client`; in middleware `isAdmin(user, { staffCollections: ['users'] })` |
@@ -38,6 +38,9 @@ description: Complete map of everything @intecion/ipal-kit provides — every ia
| `accounts.staffOnlyRead` | on | `read` and `readVersions` on a staff collection without those rules: a fully signed-in account of a staff collection (Payload's default let a visitor account list the staff accounts) | `false` = Payload's default; a `read` rule you wrote wins |
| `accounts.firstUserRoute` | `'panel'` | which auth collections `POST /api/<slug>/first-register` answers for while they are empty: only the one the panel logs in with (the first account of a site → admin). Others get `403`, a second staff collection included, in any spelling of the URL (the plugin's own endpoint sits in front of Payload's); a collection whose own `create` allows an anonymous request keeps its route. With `access.firstUserAdmin: false` and a default role below the panel role, the default `panelRole` is not applied (logged) and an explicit one is refused at start | a list of slugs; `'all'` = Payload's behaviour |
| `accounts.password` | `{ minLength: 12 }` | when a password is SET on a staff collection (create, first-user screen, change, reset by e-mail; panel, API and Local API): at least `minLength` characters, not the account's e-mail address. Existing passwords are never checked — a shorter one keeps logging in | `{ minLength }`; `false` = Payload's rule (3 characters) |
| `accounts.signInLimit` | `{ perAddress: 5, windowMinutes: 15, accountLock: { maxLoginAttempts: 50, lockTime: 3_600_000 } }` (1.18.0) | failed staff sign-ins per client IP + typed address (folded): over the limit `429` for that IP and address only; only failures count; Payload's per-account lock raised where the project set none | `{ perAddress, windowMinutes, accountLock }`; `accountLock: false` = Payload's lock; `false` = as before 1.18 |
| `accounts.signInSameOrigin` | on (1.18.0) | staff login / forgot / reset password: `403` for a request a browser marks as coming from another origin | `{ origins: [...] }`; `false` |
| `accounts.confirmOwnChanges` | on (1.18.0) | own e-mail / username / password change needs `currentPassword` (panel field, REST, GraphQL) | `false` |
| `secrets.writeOnly` | on | `smtpPassword` and `turnstileSecretKey` (Site integrations) are never returned: REST, GraphQL and the panel get `'********'` when a value is stored; a save with nothing / empty / the mask keeps it, a new value replaces it, `'[[clear]]'` removes it; the Local API with access control off reads the real value. The panel is the source of these secrets — no env variable. A restore of a version is masked too | `false` = returned to whoever may read the global, as before |
| "Sending method" (`emailMethod`; `getMailMethod` / `setMailMethod`) | nobody has chosen: the order of 1.17.0, shown as selected | `relay` (IWSN), `smtp`, `graph` (deprecated): what is chosen is what is used, no fallback; a stored field (Postgres / SQLite: one migration) |
| `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 |
@@ -85,7 +85,10 @@ Admin panel components from `@intecion/ipal-kit/admin` — the project does NOT
| `buildRolesField(defaultRole?, { firstUserAdmin? })` | `@intecion/ipal-kit` | The `roles` select field the plugin injects (only admins set roles; `firstUserAdmin` default `true` = the account made on "Create first user" gets `admin`). The plugin wires it itself — use it only for an auth collection the plugin does not manage. |
| `injectRoles(config, accessOption)` | `@intecion/ipal-kit` | Adds `roles` to `accessOption.authCollection` in a config. The plugin calls it itself with `access` — do not call. |
**Types:** `AccountsOptions` (`accounts`: `panelRole`, `adminOnlyCreate`, `adminOnlyWrite`, `staffOnlyRead`, `firstUserRoute`, `password`), `StaffAccountAccessOptions` (`{ create?, write?, read?, pluginRoles? }`), `StaffRuleMark` (`{ slug, self }`), `AccountsMarker` (`{ slug, staff, own? }`, in `custom.ipalAccounts`; `own`: the operations that had a rule of the project's at config time, kept when the collection becomes staff later), `LateAdoption` (`{ slug, applied, kept, known, password, firstUser }`; `known`: in the config when iapl ran and staff only afterwards, `kept`: its operations whose own rule was left as written), `StaffAccountRules` (what the plugin put on a staff collection, in `custom.ipalAccountRules`: `{ applied, ownRoles }`), `WriteOnlySecretOptions` (`{ boundTo?, appliesWhen? }`), `PasswordRuleOptions` (`{ minLength? }`), `FirstUserRouteOption` (`'panel' \| 'all' \| string[]`), `TurnstileOnConfigError` / `TurnstileOnConfigErrorOption` / `TurnstileFormKind` (`@intecion/ipal-kit/server`), `VerifyLimitOptions` (`twoFactor.verifyLimit`: `{ max?, windowMinutes?, store? }`), `RequireSetupOptions` (`twoFactor.requireSetup`), `TwoFactorResetOptions`, `TwoFactorSetupState`, `SafeBackRule` / `SafeBackContext` (`twoFactor.safeBack` as a function: `(back, { adminRoute, origin? }) => string`), `TotpViewComponent` (a view component as registered: a path or `{ path, exportName?, clientProps?, serverProps? }`), `SafeTotpViewProps` (`@intecion/ipal-kit/admin`), `Role` (`'user' \| 'editor' \| 'admin'`), `AccessOption` (the plugin's `access` option: `authCollection`, `defaultRole`, `authAccess`, `firstUserAdmin`, `staffCollections`).
| `applySignInRules(collection, accounts?)`, `buildSignInBeforeOperation(slug, rules)`, `releaseSignInPlace`, `settleFailedSignIn`, `buildCurrentPasswordField()`, `resolveSignInRules(accounts?)`, `foldSignInName(value)`, `passwordMatches({ hash, salt }, password)`, `CURRENT_PASSWORD_FIELD`; types `SignInRulesOptions`, `SignInLimitOptions`, `SignInSameOriginOptions` | `@intecion/ipal-kit` | 1.18.0, `accounts.signInLimit` / `signInSameOrigin` / `confirmOwnChanges`: the three rules on one staff collection (hooks, field, Payload lock defaults); the `beforeOperation` hook; the `afterLogin` hook that gives a sign-in's place back; the config `afterError` hook that ends a failed one; the virtual "Current password" field; the options with defaults; the address folding (NFKC, lower case, trim); Payload's stored-hash check (unknown formats refused). |
| `releaseRateLimit({ key, scope, max?, windowMs?, cost? })` | `@intecion/ipal-kit` | Gives back a place `consumeRateLimit` took (memory: never below 0; a store: `hit(id, -cost)`) — for a limiter that counts failures only. |
**Types:** `AccountsOptions` (`accounts`: `panelRole`, `adminOnlyCreate`, `adminOnlyWrite`, `staffOnlyRead`, `firstUserRoute`, `password`, `signInLimit`, `signInSameOrigin`, `confirmOwnChanges`), `StaffAccountAccessOptions` (`{ create?, write?, read?, pluginRoles? }`), `StaffRuleMark` (`{ slug, self }`), `AccountsMarker` (`{ slug, staff, own? }`, in `custom.ipalAccounts`; `own`: the operations that had a rule of the project's at config time, kept when the collection becomes staff later), `LateAdoption` (`{ slug, applied, kept, known, password, firstUser }`; `known`: in the config when iapl ran and staff only afterwards, `kept`: its operations whose own rule was left as written), `StaffAccountRules` (what the plugin put on a staff collection, in `custom.ipalAccountRules`: `{ applied, ownRoles }`), `WriteOnlySecretOptions` (`{ boundTo?, appliesWhen? }`), `PasswordRuleOptions` (`{ minLength? }`), `FirstUserRouteOption` (`'panel' \| 'all' \| string[]`), `TurnstileOnConfigError` / `TurnstileOnConfigErrorOption` / `TurnstileFormKind` (`@intecion/ipal-kit/server`), `VerifyLimitOptions` (`twoFactor.verifyLimit`: `{ max?, windowMinutes?, store? }`), `RequireSetupOptions` (`twoFactor.requireSetup`), `TwoFactorResetOptions`, `TwoFactorSetupState`, `SafeBackRule` / `SafeBackContext` (`twoFactor.safeBack` as a function: `(back, { adminRoute, origin? }) => string`), `TotpViewComponent` (a view component as registered: a path or `{ path, exportName?, clientProps?, serverProps? }`), `SafeTotpViewProps` (`@intecion/ipal-kit/admin`), `Role` (`'user' \| 'editor' \| 'admin'`), `AccessOption` (the plugin's `access` option: `authCollection`, `defaultRole`, `authAccess`, `firstUserAdmin`, `staffCollections`).
## Accessibility — widget (`accessibility`) — details: `node_modules/@intecion/ipal-kit/docs/accessibility.md`
+14
View File
@@ -25,6 +25,20 @@ the MANDATORY SET (GEO: llms-full, Markdown, MCP; R2; Turnstile through
`getTurnstileConfig`…). Wire each one according to PROGRAMISTA §2 — it is part of the update,
not an extra. Skip one only with a client decision in `AGENTS.md` (`iapl-audit-skip:`).
**→ 1.18.0, sign-in (CHANGELOG 1.18.0; access.md "A stranger cannot lock a staff account out", "Staff sign-in only
from the site's own origin", "Changing one's own e-mail or password asks for the current password") — no schema change,
no migration, no import-map change; read before deploying:**
1. `IAPL_IP_HEADER` must be pinned in production (`x-forwarded-for` behind Coolify/Traefik): failed staff sign-ins are
counted per client IP and address. Without it every visitor shares one bucket (20× the limit).
2. A staff collection with its own `auth.maxLoginAttempts` / `lockTime` keeps them; otherwise Payload's lock is now 50
failures for an hour (beside 5 per IP and address in 15 minutes). Payload's behaviour back: `accounts: { signInLimit: false }`.
3. A panel or front end that signs **staff** in from another domain: `accounts: { signInSameOrigin: { origins: ['https://…'] } }`
(or `false`). A proxy that rewrites `Host`: set `serverURL`. Customer / visitor logins are not affected.
4. Scripts or integrations that change their OWN e-mail or password over the API send `currentPassword`; editors
see "Current password" on their account page. Off: `accounts: { confirmOwnChanges: false }`.
**Check:** five wrong passwords for an editor from one address → `429` there, `200` from another; the account page
shows "Current password"; `curl -X POST <site>/api/users/login -H 'Origin: https://other.example' …` → `403`.
**→ 1.17.1:** (1) `src/proxy.ts`: replace the matcher literal with
`['/((?!(?:api|admin|_next)(?:/|$)|.*\\..*).*)']` (i18n.md "Next matcher"; `iapl-doctor` rule `proxy-matcher`).
The old one skipped every page whose first segment only starts with `api`, `admin` or `_next` (`/administracja`):
+6 -4
View File
@@ -191,9 +191,11 @@ is read — and is renewed after a send, once an hour; until the site has enroll
plugin has no number of its own).
**Account mail is limited by the site itself.** "Forgot password" is a visitor's lever like a form, and the
service lets account mail use the whole hour. So the relay transport holds back more than **5 account e-mails to
one address** and more than **10 asked for by one visitor** within an hour (`mail.relay.accountMail`:
`{ perAddress, perVisitor, windowMinutes }`, or `false`). A held-back message is reported as `relay-quota` in the
service lets account mail use the whole hour. So the relay transport holds back, within an hour, more than **5 account
e-mails to one address asked for by one visitor**, more than **20 to one address from everybody** and more than **10
asked for by one visitor** (`mail.relay.accountMail`: `{ perAddress, perAddressTotal, perVisitor, windowMinutes }`, or
`false`). Since 1.18.0 `perAddress` counts per visitor (the requesting IP): before, five requests from anybody used
the address's hour up, and its owner's own reset mail was held back too. A held-back message is reported as `relay-quota` in the
log and the panel; the visitor is told nothing. Pin the address header for it: `IAPL_IP_HEADER`
([security.md](./security.md)).
@@ -466,7 +468,7 @@ message); "Connect again" asks at once. Other causes: `host-not-allowed` (not a
| `token` | — | a token from elsewhere (`string` or a function): the stored token is not used and the site does not enrol |
| `senderName` | panel, then site name | a fixed name, or a function |
| `kind` | — | the kind of a message nobody marked |
| `accountMail` | `{ perAddress: 5, perVisitor: 10, windowMinutes: 60 }` | the site's own limit on account mail; `false` = none |
| `accountMail` | `{ perAddress: 5, perAddressTotal: 20, perVisitor: 10, windowMinutes: 60 }` | the site's own limit on account mail: per address and visitor, per address from everybody (1.18.0), per visitor; `false` = none |
| `confirmRateLimit` | `{ max: 10, windowMs: 60000 }` | calls to the public confirm route per address |
| `totalTimeoutMs` | `10000`; `30000` with files | everything one message may take — enrolment, attempts and waits together. Somebody waits for the request that sends the mail; after it the message is reported ("not confirmed" when an attempt was cut off). A number, or `{ plain, files }` |
| `timeoutMs` | `30000` | one attempt of a send; never more than what is left of `totalTimeoutMs` |
+3 -1
View File
@@ -412,7 +412,9 @@ Changing the path makes automated scans harder, but it is NOT a safeguard.
Real panel protection:
- **2FA** for every user (enforced by the plugin — section below)
- Strong passwords
- Rate limiting on login
- Rate limiting on login — failed staff sign-ins per IP and address (`accounts.signInLimit`, 1.18.0), staff sign-in
only from the site's own origin (`accounts.signInSameOrigin`), the current password for one's own e-mail / password
change (`accounts.confirmOwnChanges`) — [access.md](./access.md)
- IP allowlist (if the panel is for the team only)
- buildSecurityHeaders (headers)