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:
@@ -9,6 +9,98 @@ 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.
|
||||
|
||||
## 1.17.2 — version history with readPublished, sign-in and panel actions, staff-only REST submissions and jobs, the cookie button
|
||||
|
||||
> **Read before upgrading.** No schema change, no migration on any database, no import-map change. What changes for
|
||||
> an existing site, most important first:
|
||||
>
|
||||
> 1. **Fix: `readPublished()` on version history.** The form 1.17.1 documented, `readVersions: readPublished()`,
|
||||
> answered every version read by a visitor or a plain account with **500** (MongoDB, Postgres and SQLite alike).
|
||||
> It now works by itself: iapl() gives that `readVersions` the new `readPublishedVersions()` with the same role.
|
||||
> Visitors see published versions only; a draft version by id is `403`; staff see everything, as before. A
|
||||
> `readVersions` of your own that **wraps** `readPublished()` is not changed: use `readPublishedVersions()` inside it.
|
||||
> 2. **A locked staff account is told "The email or password provided is incorrect."** (REST, GraphQL, the panel),
|
||||
> so five wrong passwords no longer tell a stranger that an address has a staff account. A locked editor with the
|
||||
> right password sees "incorrect" too until the lock ends (10 minutes); an admin can unlock it. Payload's message
|
||||
> back: `accounts: { lockedAnswer: 'payload' }`. Known: the answer's **time** still differs for an existing
|
||||
> account (Payload hashes only then); that is for 1.18.0.
|
||||
> 3. **The plugin's panel actions refuse other origins** (mail service Connect / Disconnect, Send test e-mail, cookie
|
||||
> scan, approval, site check): `403` for a request a browser marks as coming from elsewhere. The panel's buttons
|
||||
> work. **Behind a proxy that rewrites `Host` and sends no `X-Forwarded-Host`, set `serverURL`**, or those buttons
|
||||
> are refused too (the log says so once; `iapl-doctor` warns). Off: `adminSameOrigin: false`.
|
||||
> 4. **A customer account can no longer create form submissions over REST / GraphQL** (staff only). The site's own
|
||||
> forms (`submitForm`, `createSubmitAction`, the file endpoint) are not affected. Way back:
|
||||
> `forms.formSubmissionOverrides.access.create`.
|
||||
> 5. **Payload's job queue over HTTP: only an admin or `Authorization: Bearer <CRON_SECRET>`** (16+ characters), when
|
||||
> the project wrote no `jobs.access.run`. **A cron that calls `/api/payload-jobs/run` must set `CRON_SECRET` and
|
||||
> send the header**, or it gets `401`. In-process runs and a project's own rule are not affected;
|
||||
> `jobsRunAccess: false` keeps Payload's default.
|
||||
> 6. **The cookie button stays in the bottom corner and never moves**; while it is shown the footer gets a little
|
||||
> room under its last row (about 43 px on the reference site) so the button covers nothing. No layout shift.
|
||||
> No room: `<CookieButton reserve={false} />`; the placement before: `<CookieButton avoid={COOKIE_BUTTON_AVOID} />`.
|
||||
> 7. **The consent version only goes up** through the panel, REST and GraphQL (a lower number would make old consent
|
||||
> count again). The Local API with `overrideAccess` may still lower it; `cookieSettings: { allowLowerPolicyVersion: true }`
|
||||
> restores the old freedom.
|
||||
> 8. **IPv6 visitors are counted per /64** by every plugin rate limit (one home network shares a budget, as an
|
||||
> IPv4 home behind one router always did). Per address: `setIpv6Grouping({ prefix: 128 })`.
|
||||
|
||||
### Security
|
||||
- **Version history with `readPublished()`** (point 1): new `readPublishedVersions(minimum)` for `readVersions`;
|
||||
`withVersionReadRules(entities)` swaps a marked `readPublished()` on `readVersions` (iapl() runs it on the
|
||||
collections and globals it sees; a plugin listed after iapl() uses `readPublishedVersions()` itself).
|
||||
- **Locked staff accounts answer like a wrong password** (point 2): `lockedLooksWrong`, `withLockedAnswer`,
|
||||
`graphqlLoginName`; type `LockedAnswerOption`.
|
||||
- **Panel actions from the site's own origin only** (point 3): `requireOwnOrigin`, `guardAdminEndpoints`,
|
||||
`ADMIN_POST_ENDPOINTS`; type `AdminSameOriginOption`; `reportRefusedOrigin(req, origins?, context?)` takes a third
|
||||
argument; `iapl-doctor` warns (`csrf-empty`) without `serverURL` or `csrf`.
|
||||
- **A customer account can no longer create submissions over REST.** `POST /api/form-submissions` (and GraphQL
|
||||
`createFormSubmission`) needed only a signed-in account of any login collection, so a customer of a visitor
|
||||
collection could skip the rate limit, Turnstile, the consent tick and the validation, and the form's e-mails went
|
||||
out. Now: a staff account with its second factor. The site's own forms (`submitForm`, `createSubmitAction`, the file
|
||||
endpoint) are not affected. Way back: `forms.formSubmissionOverrides.access.create`.
|
||||
- **Payload's job queue over HTTP: only an admin or the cron secret.** When the project writes no
|
||||
`jobs.access.run`, `/api/payload-jobs/run` and `/handle-schedules` now answer only an admin signed in with the second
|
||||
factor (an admin's API key counts) or `Authorization: Bearer <CRON_SECRET>` (16+ characters); before, any signed-in
|
||||
account of any login collection. **A site whose cron calls the run route:** set `CRON_SECRET` in the app's
|
||||
environment and send the header; the start log says so when it is missing. In-process runs (`jobs.autoRun`,
|
||||
`payload jobs:run`) and a project's own rule are not affected; `iapl({ jobsRunAccess: false })` keeps Payload's
|
||||
default (security.md "Payload's job queue").
|
||||
- **The consent version only goes up** (point 7): `policyVersionNeverDown`, `buildCookieSettingsFields`,
|
||||
`buildCookieSettings(options)`; type `CookieSettingsFieldOptions`.
|
||||
- **IPv6 per network** (point 8): `setIpv6Grouping`, `ipRateKey`; type `Ipv6Grouping`. A second counter per /48 is
|
||||
available (`wide: 48`), off by default.
|
||||
|
||||
### Added
|
||||
- `iapl-doctor` deep rule **`visitor-writes`** (warning): on a site with a visitor login collection, every collection
|
||||
and global whose write rule lets such an account in, Payload's default included.
|
||||
- `jobsRunAccess`, `withJobsRunAccess`, `jobsRunNotice`, `cronSecretMatches`, `CRON_SECRET_ENV`,
|
||||
`CRON_SECRET_MIN_LENGTH`; option `jobsRunAccess`; env `CRON_SECRET`.
|
||||
- `CookieButton` prop `reserve` (the block that gets the room; `false` = off); `COOKIE_BUTTON_RESERVE`,
|
||||
`COOKIE_BUTTON_SPACE_ATTRIBUTE`, `reserveCookieButtonSpace` (`/client`, type `CookieButtonSpaceOptions`);
|
||||
`consentDecidedScript` (root); the token `--ipal-cookie-button-space`.
|
||||
|
||||
### Changed
|
||||
- **What an existing site's visitors see: the "cookie settings" button stays in the bottom corner of the window and
|
||||
never moves; the footer is a little taller while it is shown**
|
||||
([consent.md → Where the cookie button sits](./consent.md#where-the-cookie-button-sits-1172)). Until now the button
|
||||
moved up by the visible part of the footer: on a phone with a tall footer it ended at the top of the screen (over
|
||||
the header), on a short page in the middle of it. Now it is in the same corner on every page and at every scroll
|
||||
position. So that it covers nothing at the very end of a page, the footer gets bottom padding while the button is
|
||||
shown — just enough for its last row to end above the button (measured: the footer's own padding counts, an empty
|
||||
corner gets nothing; on the reference site 42–43 px on phones and desktop). Not before a decision, not while the
|
||||
banner is open. No layout shift: for a returning visitor the room is made before the first paint. Same look,
|
||||
keyboard and screen-reader access unchanged; the side inset now adds the device's safe-area inset.
|
||||
**Nothing to do; an existing site gets it by updating.** No room: `<CookieButton reserve={false} />`; an amount of
|
||||
your own: `--ipal-cookie-button-space` on the footer (`0` = none, also per breakpoint); the placement before:
|
||||
`<CookieButton avoid={COOKIE_BUTTON_AVOID} />` (on `SiteProviders`: `cookieButton={…}`). A site that passes a
|
||||
selector in `avoid` keeps its behaviour. A project e2e test that expects the button above the footer, or an exact
|
||||
footer height after a decision, needs an update.
|
||||
- The reference site (and every new site from `iapl create`): `Pages`, `Posts`, `CaseStudies`, `Media` and the
|
||||
`Header`, `Footer`, `Company` globals have their own write rules (`adminOrEditor`) instead of Payload's default.
|
||||
Existing sites: nothing changes; the doctor's `visitor-writes` names what to add where it matters.
|
||||
- Not built (owner's Q3 answer (a), planned for 2.0): a plugin-wide default for the project's own entities and for
|
||||
Payload's `payload-locked-documents`.
|
||||
|
||||
## 1.17.1 — security fixes from the IAWL review; the panel's sign-in look; the sending method is chosen
|
||||
|
||||
> **Read before upgrading.** **MongoDB: no migration. Postgres / SQLite: one migration** — a new column for the
|
||||
|
||||
+40
-3
@@ -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),
|
||||
|
||||
+17
-3
@@ -636,12 +636,18 @@ for visitors. Then, all four:
|
||||
`access.staffCollections` is for a second collection of STAFF (access.md → "Who is staff").
|
||||
3. In every auth collection use `adminOrSelfIn('<its slug>')`, not `adminOrSelf`, for "only my own record".
|
||||
4. Payload's default for a collection or global without `access` is "any logged-in account" — a customer too.
|
||||
Give every collection and global explicit `access`. 2FA covers the panel's collection only.
|
||||
Give every collection and global explicit `access` (writes: `adminOrEditor`, as the reference site's collections
|
||||
and globals do since 1.17.2). Verify with `iapl-doctor --url …` (deep): no `visitor-writes` finding. 2FA covers
|
||||
the panel's collection only.
|
||||
5. Never let a sign-up write a field that grants rights (`roles`, `isAdmin`, …): give such a field
|
||||
`access: { create: adminOnlyField, update: adminOnlyField }`.
|
||||
6. Check: log in as such an account (`POST /api/customers/login`), then `GET /api/globals/site-integrations`,
|
||||
`GET /api/form-submissions` and `GET /api/users` with its token must answer `403`, and so must
|
||||
`POST /api/setup-totp`.
|
||||
`POST /api/setup-totp`, `POST /api/form-submissions` and (a site with Payload jobs) `GET /api/payload-jobs/run`
|
||||
(`401`).
|
||||
7. Payload jobs run over HTTP: since 1.17.2 only an admin or `Authorization: Bearer <CRON_SECRET>` (when the project
|
||||
writes no `jobs.access.run`). A Coolify scheduled task that calls `/api/payload-jobs/run` sends that header;
|
||||
`CRON_SECRET` goes into the app's environment (security.md "Payload's job queue").
|
||||
|
||||
**NEVER:** a second `media`, `daneFirmy`/`settings`/
|
||||
`navigation`/`footer` as collections (they are globals), FAQ/hero/features as collections
|
||||
@@ -1103,7 +1109,7 @@ project → **plugin gap**, not a copy.
|
||||
| ISR after save, old slug → 308, images across languages | `buildRevalidateHook`, `trackSlugHistoryHook`, `buildCrossLocaleFieldSync` | hooks.md |
|
||||
| ISR after a global is saved | plugin globals: `iapl({ revalidatePath })`; your own globals: `buildGlobalRevalidateHook({ revalidatePath })` | hooks.md |
|
||||
| Change a plugin global (access, hooks, fields) | `iapl({ globalOverrides })` | access.md |
|
||||
| Roles and access | `adminOnly`, `adminOrEditor`, `adminOrSelf`, `adminOrSelfIn(slug)` (several auth collections), `authenticated`, `requireRole`, `hasMinimumRole` (+ `…Field`); a collection with drafts: `access: { read: readPublished(), readVersions: readPublished() }` (editors read drafts, everybody else published only — Payload's open `read: () => true` answers `?draft=true` with the draft; verify: `GET /api/<slug>/<draft id>?draft=true` without a session → 404); an unknown role name throws where the rule is written; staff checks: `userMeetsRole(req, role)`, `isAdmin(req.user, req.payload)` (roles count only for accounts of a staff collection; in a client component `isAdmin(user, config)` with `useConfig()`, imported from **`@intecion/ipal-kit/client`** (the main entry does not build there with webpack), in middleware `isAdmin(user, { staffCollections: ['users'] })` — without the last argument there it is always `false`), `staffCollectionSlugs(payload)`, `access.staffCollections`; second factor in your own code: `secondFactorPassed(req)`, `requireSecondFactor(access)`; injected `users`: `access.authAccess`, first user = admin (`access.firstUserAdmin`) | access.md, security.md |
|
||||
| Roles and access | `adminOnly`, `adminOrEditor`, `adminOrSelf`, `adminOrSelfIn(slug)` (several auth collections), `authenticated`, `requireRole`, `hasMinimumRole` (+ `…Field`); a collection or global with drafts: `access: { read: readPublished(), readVersions: readPublishedVersions() }` (editors read drafts and every version, everybody else published only — Payload's open `read: () => true` answers `?draft=true` with the draft; `readPublished` is for `read` only, `readPublishedVersions` for `readVersions` only — `readVersions: readPublished()` answered 500 in 1.17.1 and is swapped for you since 1.17.2 on entities iapl() sees, `withVersionReadRules(entities)` for a plugin listed after it, `READ_PUBLISHED` marks the rule; neither on a collection without drafts; verify: without a session `GET /api/<slug>/<draft id>?draft=true` → 404 and `GET /api/<slug>/versions?limit=10` → 200, published only); an unknown role name throws where the rule is written; staff checks: `userMeetsRole(req, role)`, `isAdmin(req.user, req.payload)` (roles count only for accounts of a staff collection; in a client component `isAdmin(user, config)` with `useConfig()`, imported from **`@intecion/ipal-kit/client`** (the main entry does not build there with webpack), in middleware `isAdmin(user, { staffCollections: ['users'] })` — without the last argument there it is always `false`), `staffCollectionSlugs(payload)`, `access.staffCollections`; second factor in your own code: `secondFactorPassed(req)`, `requireSecondFactor(access)`; injected `users`: `access.authAccess`, first user = admin (`access.firstUserAdmin`) | access.md, security.md |
|
||||
| Data from globals | `getGlobal`, `getSiteSettings`, `getSiteIntegrations` | payload-helpers.md |
|
||||
|
||||
**Links and navigation**
|
||||
@@ -1161,6 +1167,7 @@ project → **plugin gap**, not a copy.
|
||||
|---|---|---|
|
||||
| Banner, settings, cookie button | `<SiteProviders banner={<CookieBanner …/>}>`, `CookieButton`, `useConsent` | consent.md |
|
||||
| Compliance defaults (1.17.0): Global Privacy Control honoured (no banner, no tracker request, opt-in from the cookie button wins), "Reject" like "Accept all", consent log on, withdrawal tells Meta / TikTok / Clarity and clears listed storage keys | built in; opt-outs: `SiteProviders gpc="ask"` / `gpc={false}`, `CookieBanner equalChoice={false}`, `iapl({ consentLog: false })` / `logEndpoint={false}`, `maxAgeDays` (re-ask, default 180); building blocks `resolveConsent`, `gpcFromHeaders`, `gpcFromNavigator`, `GPC_CATEGORIES`, `GPC_HEADER`, `CONSENT_LOG_PATH`, `gpcWellKnown` (`/.well-known/gpc.json`), `readEffectiveConsent`, `signalVendors`, `clarityConsent` (`/client`). Check: `iapl-consent-check` (5 runs incl. GPC, equal prominence, withdrawal), `iapl-doctor` (`consent-banner`, `consent-log-migration`) | consent.md → "Compliance defaults", consent-behaviour-spec.md |
|
||||
| Cookie button placement | built in: bottom corner of the window on every page, never moves, never in or above the footer; the footer gets room under its last row while the button is shown, so nothing is covered at the page end. `CookieButton side` / `reserve` (`false` = no room) / `avoid` (`avoid={COOKIE_BUTTON_AVOID}` = above the footer, as before 1.17.2), tokens `--ipal-cookie-button-offset` / `-inset`, amount by hand `--ipal-cookie-button-space` on the footer. Do not render the button inside the footer, write a scroll handler for it, or add bottom padding for it by hand | consent.md → "Where the cookie button sits" |
|
||||
| Banner at first paint (not after hydration; LCP) | built in: `CookieBanner firstPaint` (default on), `SiteProviders nonce` under a nonce CSP; off: `firstPaint={false}`; server-exact HTML on a dynamic site: `SiteProviders consentCookie` / `ConsentProvider cookieValue`; your own banner: `consentBannerScript`. Check: `curl -s <page> \| grep -c 'data-ipal="banner-script"'` → 1 and the response still has `s-maxage` | consent.md → "First paint" |
|
||||
| Settings window: in the bar / small / large with cookie details | `<CookieBanner settings="inline" \| "modal" \| "detailed">` — do not build your own window or cookie list | consent.md → "Large window with details" |
|
||||
| A consent-dependent script | `ConsentScript` | consent.md |
|
||||
@@ -1217,6 +1224,10 @@ add missing hosts with flags / `extra`; (3) change `mode` to `'enforce'` in both
|
||||
| Rich-text links: one rule for every stored URL — `link`, `autolink` (also marked internal) and the Markdown output (`lexicalToMarkdown`) drop `javascript:` / `data:` targets | `safeLinks={false}` (trusted content only) | `sanitizeRichTextLinks`, `safeHref` |
|
||||
| Locales: no stand-in — `resolveRoute` (page route, `/md/…`, MCP `get_page`) answers `null` for a locale the site does not have (`xx`, `all`); a 404 page that is a draft is not shown (built-in view instead) | — | `isSiteLocale(payload, locale)`; verify: `curl -i <site>/md/xx` → 404 |
|
||||
| Site integrations versions (when a project turns them on) are read by admins only (`readVersions`) | — | `globalOverrides: { 'site-integrations': { access: { readVersions } } }` |
|
||||
| Consent version only goes up (1.17.2): a save through access control with a lower Cookies → *Consent version* is refused with a message (old consent would count again); the Local API with `overrideAccess` may still | `iapl({ cookieSettings: { allowLowerPolicyVersion: true } })` | `policyVersionNeverDown`, `buildCookieSettingsFields` (type `CookieSettingsFieldOptions`), `buildCookieSettings(options)`; verify: lower it in the panel → the error under the field |
|
||||
| Drafts as related documents are left out (1.18.0): a block, menu or System pages link pointing at a page never published no longer brings its title, slug or text into the helpers' answers (`null` alone, removed from a list, `value: null` in a polymorphic one) — pages, Site settings, archive entries, the 404 page, Markdown, MCP, llms-full; a preview keeps them | `createContentHelpers({ draftRelations: 'keep' })`; `draftRelations: 'keep'` on `resolveRoute` / `getArchiveEntries` / `resolveNotFoundPage` / `collectSiteIndex` / `buildLlmsTxt` | `withoutDraftRelations`, `applyDraftRelations`, type `DraftRelations`; content.md "Drafts as related documents"; verify: a menu link to an unpublished page is gone on the site |
|
||||
| Integration status written alone (1.18.0): `emailStatus` / `turnstileStatus` go through the database adapter on their own, so a visitor's form submit can no longer put back an admin's SMTP or Turnstile change saved at the same moment; the cookie list is checked again right before the scanner writes it (a row an editor saved in between stays) | — | `writeGlobalFields(payload, slug, data)` for your own bookkeeping fields (no hooks, no version); `addToCookieList` |
|
||||
| Access callbacks (`cookieScanner.access`, the doctor's `access`): any truthy answer still allows in 1.18.0, but an answer that is not a boolean is reported once per option in the server log; **from 1.19.0 only `true` allows** | — | return a boolean (`({ req }) => Boolean(req.user)`); `accessAllowed(option, answer)`; security.md "Access callbacks" |
|
||||
| Consent log on (since 1.17.0; Postgres / SQLite: a migration in the same deploy) | `consentLog: false`; one layout: `logEndpoint={false}` | `consentLog: { retentionDays, collectionOverrides }`; `buildConsentLogCollection` / `buildConsentLogEndpoint`, `CONSENT_LOG_PATH` |
|
||||
| Global Privacy Control honoured: no banner, analytics and marketing off, no Google request also in Consent Mode `advanced`; a grant made without the signal is switched off when it appears | `gpc={false}` (doctor warns) | `gpc="ask"`; `resolveConsent`, `gpcFromHeaders`, `consentBannerScript({ gpc })` |
|
||||
| "Reject" styled like "Accept all" (`equalChoice`) | `equalChoice={false}` (doctor warns) | `classNames.rejectButton` |
|
||||
@@ -1227,11 +1238,13 @@ add missing hosts with flags / `extra`; (3) change `mode` to `'enforce'` in both
|
||||
| 2FA setup required: an account without TOTP reaches only the setup screen; 72 h window from creation / admin reset, then blocked; status and "Reopen setup" on the account page, notice on the dashboard, `POST /api/ipal/two-factor/reset` | `twoFactor.requireSetup: false`; parts: `requireSetup: { dashboardNotice: false, statusField: false, setupNotice: false }` | `requireSetup: { windowHours, exempt }` (`exempt` returns exactly `true`, never `async`; decide it from a field only admins write, e.g. a `serviceAccount` checkbox with `adminOnlyField` — never from the e-mail, which every account may change itself; security.md "Decide `exempt` from a field only an administrator can write"), `twoFactor.resetAccess` (default: an admin who entered its own code; the reset ends the account's sessions), texts `twoFactor*`; `twoFactorSetupState(req)`, `buildSetupFields`, `backfillSetupFrom`, `buildTwoFactorResetEndpoint`. **Postgres/SQLite: migration for `totp_setup_from` applied when the new container starts (`prodMigrations` or `pnpm payload migrate && pnpm start`; never a pre-deployment command — deployment.md §4.3), or every login answers 500** |
|
||||
| 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 <site>/api/ipal/test-email -H 'Origin: https://other.example' -H 'Content-Type: text/plain' -b <admin cookies> -d '{}'` → `403` | `adminSameOrigin: false` | `adminSameOrigin: { origins: [...] }`; `requireOwnOrigin(endpoint, origins?)` for your own endpoints |
|
||||
| 2FA verify and setup attempts only from the site's own origin: a request a browser marks as coming from elsewhere (`Origin`, `Sec-Fetch-Site`) gets `403` and is not counted. The admin's reset `POST /api/ipal/two-factor/reset` follows the same rule (1.17.1). **Verify:** `curl -X POST <site>/api/ipal/two-factor/reset -H 'Origin: https://other.example' -H 'Content-Type: text/plain' -b <admin cookies> -d '{"userId":1}'` → `403`; the panel's button still works. **Set `serverURL`**: behind a proxy that rewrites `Host` and sends no `X-Forwarded-Host` the site's own page is refused without it (logged once per origin: `[iapl] 2FA: a code from origin … was refused`) | `twoFactor.sameOrigin: false` | `sameOrigin: { origins: ['https://app.example.com'] }`; `requestFromOwnOrigin`, `reportRefusedOrigin` |
|
||||
| Stored secrets are write-only: `smtpPassword` and `turnstileSecretKey` come back as `'********'` over REST, GraphQL and in the panel; an empty save keeps the value, `'[[clear]]'` removes it; server code reads the real value with the Local API. A query cannot name a secret (1.17.1): `where` / `sort` on it — REST, GraphQL, versions — is refused (`secretReadAccess`, the field's `read` rule; verify: `GET /api/globals/site-integrations/versions?where[version.smtpPassword][exists]=true` as an admin → 400 `QueryError`, no `totalDocs`). **The panel is the source — never add an env variable for them** (`TURNSTILE_SECRET_KEY` is deprecated) | `secrets: { writeOnly: false }` | `writeOnlySecret(field)` / `writeOnlySecrets(fields, names)` for your own secret fields; with versions on the entity add `hooks.afterRead: [maskSecretsOnRestore]` |
|
||||
| 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` |
|
||||
| A locked staff account (Payload's `maxLoginAttempts`) answers its login exactly like a wrong password — REST body and status, GraphQL `extensions.name: AuthenticationError`, the panel's sign-in (1.17.2); visitor collections keep Payload's answer. **Verify:** 5 wrong passwords for an admin, then the right one → the same `401` body as for an unknown address | `accounts: { lockedAnswer: 'payload' }` | `lockedLooksWrong`, `withLockedAnswer(config)`, `graphqlLoginName` |
|
||||
| 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) |
|
||||
@@ -1243,6 +1256,7 @@ add missing hosts with flags / `extra`; (3) change `mode` to `'enforce'` in both
|
||||
| Roles count only for accounts of a staff collection, in every predicate and access function | — | `access.staffCollections` |
|
||||
| `enabled: false` keeps the schema | — | — (no endpoints, `onInit` or admin components; no DROP TABLE in `migrate:create`) |
|
||||
| No client IP = one shared `unknown-ip` bucket at 20× the limit | `setUnknownIpFactor(0)` (only with a limiter in front) | `setUnknownIpFactor(n)`; `UNKNOWN_IP_FACTOR` |
|
||||
| IPv6 counted per /64 in every plugin limiter (1.17.2): one /64 = one client, `::ffff:a.b.c.d` = its IPv4; no /48 counter by default. **Verify:** 50 requests with `X-Real-IP: 2001:db8:1:1::<n>` → `429` after the limit | `setIpv6Grouping({ prefix: 128 })` (per address, as before) | `setIpv6Grouping({ prefix, wide: 48, wideFactor })`; `ipRateKey(ip)` for your own limiter (forms.md "IPv6 is counted per network") |
|
||||
| Turnstile token domain not checked | (default) | `createSubmitAction({ turnstileHostnames })`, `verifyTurnstile({ hostnames })` — leave empty in dev |
|
||||
| Consent Mode `advanced` | `consentMode: 'basic'` | your own `<Analytics>` props (`SiteProviders analytics={false}`) |
|
||||
| Locale cookie: consent read under its own stored version | — | `createProxy(config, { policyVersion })` / `createLocaleMiddleware({ policyVersion })` |
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<!-- Generated by scripts/reference-index.mjs from reference/ — do not edit by hand (pnpm reference:index). -->
|
||||
|
||||
The reference site is one complete client site on IAPL 1.17.1 ("Example Studio", made up) that uses
|
||||
The reference site is one complete client site on IAPL 1.17.2 ("Example Studio", made up) that uses
|
||||
every convention in AGENT.md. It lives in the plugin repo (`reference/`, not in the npm package). Copy the
|
||||
PATTERN of the file you need; change only the project's content. Files up to
|
||||
40 lines are below in full; open the rest in the repo at the tag of your plugin version:
|
||||
@@ -279,7 +279,7 @@ Rules: AGENT.md §5, iapl-nav, iapl-collection.
|
||||
| `src/collections/Pages.ts` | Pages: slug, blocks layout, AI summary, noindex, slug history, revalidation, system-page delete guard (below) |
|
||||
| `src/collections/Posts.ts` | the blog collection (archive in System pages) (below) |
|
||||
| `src/collections/entryFields.ts` | shared fields of archive collections (names the entry card reads) (below) |
|
||||
| `src/globals/Company.ts` | company data (PL market): footer, contact details, LocalBusiness JSON-LD (below) |
|
||||
| `src/globals/Company.ts` | company data (PL market): footer, contact details, LocalBusiness JSON-LD |
|
||||
| `src/globals/Footer.ts` | footer navigation global (below) |
|
||||
| `src/globals/Header.ts` | header navigation global (below) |
|
||||
|
||||
@@ -288,7 +288,7 @@ Rules: AGENT.md §5, iapl-nav, iapl-collection.
|
||||
```ts
|
||||
import type { CollectionConfig } from 'payload'
|
||||
|
||||
import { buildRevalidateHook } from '@intecion/ipal-kit'
|
||||
import { adminOrEditor, buildRevalidateHook } from '@intecion/ipal-kit'
|
||||
import { revalidatePath } from 'next/cache'
|
||||
|
||||
import { i18nConfig } from '@/i18n.config'
|
||||
@@ -301,7 +301,8 @@ const revalidate = buildRevalidateHook({ config: i18nConfig, revalidatePath })
|
||||
export const CaseStudies: CollectionConfig = {
|
||||
slug: 'caseStudies',
|
||||
admin: { defaultColumns: ['title', 'publishedAt', 'updatedAt'], useAsTitle: 'title' },
|
||||
access: { read: () => true },
|
||||
// write rules of its own: Payload's default is "any signed-in account" — a visitor login collection would reach it (security.md "Visitor accounts")
|
||||
access: { create: adminOrEditor, delete: adminOrEditor, read: () => true, update: adminOrEditor },
|
||||
defaultSort: '-publishedAt',
|
||||
fields: entryFields,
|
||||
hooks: { afterChange: [revalidate.afterChange], afterDelete: [revalidate.afterDelete] },
|
||||
@@ -315,6 +316,7 @@ export const CaseStudies: CollectionConfig = {
|
||||
import type { CollectionConfig } from 'payload'
|
||||
|
||||
import {
|
||||
adminOrEditor,
|
||||
buildMediaPlaceholderField,
|
||||
buildMediaPlaceholderHook,
|
||||
buildOptimizeUploadField,
|
||||
@@ -325,7 +327,8 @@ import {
|
||||
/** media.md "Full collection", 1:1. */
|
||||
export const Media: CollectionConfig = {
|
||||
slug: 'media',
|
||||
access: { read: () => true }, // public files; media are served by the app (/api/media/file/…)
|
||||
// write rules of its own: Payload's default is "any signed-in account" — a visitor login collection would reach it (security.md "Visitor accounts")
|
||||
access: { create: adminOrEditor, delete: adminOrEditor, read: () => true, update: adminOrEditor }, // public files; media are served by the app (/api/media/file/…)
|
||||
upload: { focalPoint: true, mimeTypes: ['image/*', 'application/pdf', 'video/mp4', 'video/webm'] },
|
||||
hooks: {
|
||||
beforeOperation: [normalizeFilenameHook, buildOptimizeUploadHook(), buildMediaPlaceholderHook()],
|
||||
@@ -344,6 +347,7 @@ export const Media: CollectionConfig = {
|
||||
import type { CollectionConfig } from 'payload'
|
||||
|
||||
import {
|
||||
adminOrEditor,
|
||||
buildNoindexField,
|
||||
buildPreventDeleteSystemPage,
|
||||
buildRevalidateHook,
|
||||
@@ -362,7 +366,8 @@ const revalidate = buildRevalidateHook({ config: i18nConfig, revalidatePath })
|
||||
export const Pages: CollectionConfig = {
|
||||
slug: 'pages',
|
||||
admin: { defaultColumns: ['title', 'slug', 'updatedAt'], useAsTitle: 'title' },
|
||||
access: { read: () => true },
|
||||
// write rules of its own: Payload's default is "any signed-in account" — a visitor login collection would reach it (security.md "Visitor accounts")
|
||||
access: { create: adminOrEditor, delete: adminOrEditor, read: () => true, update: adminOrEditor },
|
||||
fields: [
|
||||
{ name: 'title', type: 'text', localized: true, required: true },
|
||||
buildSlugField({ from: 'title' }),
|
||||
@@ -385,7 +390,7 @@ export const Pages: CollectionConfig = {
|
||||
```ts
|
||||
import type { CollectionConfig } from 'payload'
|
||||
|
||||
import { buildRevalidateHook } from '@intecion/ipal-kit'
|
||||
import { adminOrEditor, buildRevalidateHook } from '@intecion/ipal-kit'
|
||||
import { revalidatePath } from 'next/cache'
|
||||
|
||||
import { i18nConfig } from '@/i18n.config'
|
||||
@@ -398,7 +403,8 @@ const revalidate = buildRevalidateHook({ config: i18nConfig, revalidatePath })
|
||||
export const Posts: CollectionConfig = {
|
||||
slug: 'posts',
|
||||
admin: { defaultColumns: ['title', 'publishedAt', 'updatedAt'], useAsTitle: 'title' },
|
||||
access: { read: () => true },
|
||||
// write rules of its own: Payload's default is "any signed-in account" — a visitor login collection would reach it (security.md "Visitor accounts")
|
||||
access: { create: adminOrEditor, delete: adminOrEditor, read: () => true, update: adminOrEditor },
|
||||
defaultSort: '-publishedAt',
|
||||
fields: entryFields,
|
||||
hooks: { afterChange: [revalidate.afterChange], afterDelete: [revalidate.afterDelete] },
|
||||
@@ -431,63 +437,19 @@ export const entryFields: Field[] = [
|
||||
]
|
||||
```
|
||||
|
||||
### `src/globals/Company.ts`
|
||||
|
||||
```ts
|
||||
import type { GlobalConfig } from 'payload'
|
||||
|
||||
import { buildGlobalRevalidateHook, rowLabel } from '@intecion/ipal-kit'
|
||||
import { revalidatePath } from 'next/cache'
|
||||
|
||||
/** Company data for a PL market site: footer, contact block details, LocalBusiness JSON-LD. */
|
||||
export const Company: GlobalConfig = {
|
||||
slug: 'company',
|
||||
access: { read: () => true },
|
||||
fields: [
|
||||
{ name: 'name', type: 'text', required: true },
|
||||
{ name: 'legalName', type: 'text' },
|
||||
{ name: 'taxId', type: 'text', label: 'NIP' },
|
||||
{ name: 'taxIdLabel', type: 'text', admin: { description: 'Shown before the tax ID in the footer.' }, defaultValue: 'NIP', label: 'Tax ID label', localized: true },
|
||||
{
|
||||
name: 'address',
|
||||
type: 'group',
|
||||
fields: [
|
||||
{ name: 'street', type: 'text' },
|
||||
{ name: 'postalCode', type: 'text' },
|
||||
{ name: 'city', type: 'text' },
|
||||
{ name: 'country', type: 'text', defaultValue: 'PL' },
|
||||
],
|
||||
},
|
||||
{ name: 'phone', type: 'text' },
|
||||
{ name: 'email', type: 'email' },
|
||||
{ name: 'hours', type: 'text', localized: true, admin: { description: 'Shown next to the contact form, e.g. "Mon–Fri 9:00–17:00".' } },
|
||||
{
|
||||
name: 'socials',
|
||||
type: 'array',
|
||||
admin: { components: rowLabel('label', 'Profile'), initCollapsed: true },
|
||||
labels: { plural: 'Profiles', singular: 'Profile' },
|
||||
fields: [
|
||||
{ name: 'label', type: 'text', required: true },
|
||||
{ name: 'url', type: 'text', required: true },
|
||||
],
|
||||
},
|
||||
],
|
||||
hooks: { afterChange: [buildGlobalRevalidateHook({ revalidatePath })] },
|
||||
}
|
||||
```
|
||||
|
||||
### `src/globals/Footer.ts`
|
||||
|
||||
```ts
|
||||
import type { GlobalConfig } from 'payload'
|
||||
|
||||
import { buildGlobalRevalidateHook, buildLinkField, rowLabel } from '@intecion/ipal-kit'
|
||||
import { adminOrEditor, buildGlobalRevalidateHook, buildLinkField, rowLabel } from '@intecion/ipal-kit'
|
||||
import { revalidatePath } from 'next/cache'
|
||||
|
||||
/** iapl-nav: link columns and a note. Legal links come from System pages (getSystemLinks), not from here. */
|
||||
export const Footer: GlobalConfig = {
|
||||
slug: 'footer',
|
||||
access: { read: () => true },
|
||||
// write rules of its own: Payload's default is "any signed-in account" — a visitor login collection would reach it (security.md "Visitor accounts")
|
||||
access: { read: () => true, update: adminOrEditor },
|
||||
fields: [
|
||||
{
|
||||
name: 'columns',
|
||||
@@ -517,13 +479,14 @@ export const Footer: GlobalConfig = {
|
||||
```ts
|
||||
import type { GlobalConfig } from 'payload'
|
||||
|
||||
import { buildGlobalRevalidateHook, buildLinkField, buildLinksField, rowLabel } from '@intecion/ipal-kit'
|
||||
import { adminOrEditor, buildGlobalRevalidateHook, buildLinkField, buildLinksField, rowLabel } from '@intecion/ipal-kit'
|
||||
import { revalidatePath } from 'next/cache'
|
||||
|
||||
/** iapl-nav: menu with one submenu level, a CTA button, the mobile menu label. Logo comes from Site settings. */
|
||||
export const Header: GlobalConfig = {
|
||||
slug: 'header',
|
||||
access: { read: () => true },
|
||||
// write rules of its own: Payload's default is "any signed-in account" — a visitor login collection would reach it (security.md "Visitor accounts")
|
||||
access: { read: () => true, update: adminOrEditor },
|
||||
fields: [
|
||||
{
|
||||
name: 'navItems',
|
||||
@@ -1176,6 +1139,7 @@ Rules: AGENT.md §8a.
|
||||
| `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-answers.spec.ts` | built-site test (pnpm e2e:built, 1.17.2): a locked staff account gets the wrong-password answer over REST and GraphQL (accounts.lockedAnswer); the plugin's panel actions refuse another origin and take the site's own (adminSameOrigin) |
|
||||
| `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) |
|
||||
| `e2e/smoke.spec.ts` | the smoke tests every release must pass: pages, showcase, forms (also a file sent by e-mail), sitemap, SEO/GEO, headers, consent, 2FA |
|
||||
| `e2e/smtp-sink.ts` | a local mail sink for the smoke tests: reads what the site really sent (recipients, attachments) |
|
||||
|
||||
@@ -78,7 +78,8 @@ names, env, admin, AGENTS.md, skills, seeds and — with `--url` / `--deep` —
|
||||
|
||||
- **Drafts and locales over the API** (a collection with `versions: { drafts: true }`): without a session,
|
||||
`curl -s "$U/api/<slug>?draft=true&limit=100" | grep -c '"_status":"draft"'` → `0`, else ERROR: give it
|
||||
`access: { read: readPublished(), readVersions: readPublished() }` (access.md). `curl -sI "$U/md/xx"` → `404`
|
||||
`access: { read: readPublished(), readVersions: readPublishedVersions() }` (access.md). `curl -s -o /dev/null -w '%{http_code}' "$U/api/<slug>/versions?limit=10"`
|
||||
→ `200` (a `500` = a rule with the document's `_status` path on `readVersions`: ERROR). `curl -sI "$U/md/xx"` → `404`
|
||||
(no stand-in locale); a 404 page assigned in System pages must be published.
|
||||
- **Secrets out of queries** (as an admin, with versions on for Site integrations or a collection using
|
||||
`writeOnlySecret`): `curl -s -H "Authorization: JWT $T" "$U/api/globals/site-integrations/versions?where[version.smtpPassword][exists]=true"`
|
||||
|
||||
@@ -46,12 +46,16 @@ const DOORS: Door[] = [
|
||||
{ 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 without the schedule\'s token', path: '/api/ipal/cookie-crawl' },
|
||||
{ closedFor: OUTSIDERS, name: 'form submissions', path: '/api/form-submissions' },
|
||||
// IAPL 1.17.2: a staff account only; an open door answers 400 (validation) instead of 403
|
||||
{ body: { form: NO_ID, submissionData: [] }, closedFor: OUTSIDERS, method: 'POST', name: 'a submission past submitForm', path: '/api/form-submissions', closed: status(403) },
|
||||
{ body: { email: '[email protected]', password: 'Door-Password-1234', roles: ['admin'] }, closedFor: ALL, method: 'POST', name: 'nobody creates a staff account', path: '/api/users', closed: status(403) },
|
||||
{ body: { email: '[email protected]', password: 'Door-Password-1234' }, closedFor: ALL, method: 'POST', name: 'the first-user route once an account exists', path: '/api/users/first-register', closed: status(403) },
|
||||
{ body: {}, closedFor: OUTSIDERS, method: 'POST', name: 'Site settings cannot be saved', path: '/api/globals/site-settings', closed: status(403) },
|
||||
{ closedFor: ALL, name: 'the GraphQL playground (production)', path: '/api/graphql-playground', closed: status(404) },
|
||||
{ closedFor: ALL, graphql: '{ __schema { queryType { name } } }', closed: ({ body }) => Boolean((body as { errors?: unknown[] })?.errors?.length), name: 'GraphQL introspection (production)' },
|
||||
{ closedFor: ALL, name: 'Payload\'s job queue (a site without jobs)', path: '/api/payload-jobs/run', closed: status(404) },
|
||||
// a site without jobs: 404. A site WITH jobs (IAPL 1.17.2): refused (401) for everybody but an admin and
|
||||
// `Authorization: Bearer <CRON_SECRET>` — drop `closed: status(404)` there
|
||||
{ closedFor: ALL, name: 'Payload\'s job queue', path: '/api/payload-jobs/run', closed: status(404) },
|
||||
// the project's own doors: add them here
|
||||
// { closedFor: OUTSIDERS, body: {}, method: 'PATCH', name: 'pages cannot be changed', path: `/api/pages/${NO_ID}`, closed: status(403) },
|
||||
]
|
||||
|
||||
@@ -46,9 +46,11 @@ Ask only when the brief leaves a business question open (e.g. "do posts have aut
|
||||
**No URL prefix in code** — the editor assigns the archive page in
|
||||
Site settings (`<slug>Archive`). The plugin handles routing, sitemap,
|
||||
generateStaticParams, hreflang.
|
||||
**With drafts** (`versions: { drafts: true }`): `access: { read: readPublished(), readVersions: readPublished() }`
|
||||
**With drafts** (`versions: { drafts: true }`): `access: { read: readPublished(), readVersions: readPublishedVersions() }`
|
||||
(`readPublished` is for `read`, `readPublishedVersions` for `readVersions` — the version list asks for `version._status`)
|
||||
— Payload's open `read: () => true` answers `?draft=true` with the draft over REST and GraphQL. Check:
|
||||
`curl -i <site>/api/<slug>/<draft id>?draft=true` without a session → `404`; the same with an editor's token → the draft.
|
||||
`curl -i <site>/api/<slug>/<draft id>?draft=true` without a session → `404`; the same with an editor's token → the draft;
|
||||
`curl -s -o /dev/null -w '%{http_code}' <site>/api/<slug>/versions?limit=10` without a session → `200`, never `500`.
|
||||
3. Entry list = a block (EntriesList) with `getEntries`; the entry page uses
|
||||
`resolveRoute` (type `entry`); JSON-LD per seo.md (e.g. Article).
|
||||
4. **An auth collection for visitors** (`auth: true`: customers, members) only when the client requires it
|
||||
|
||||
@@ -55,6 +55,14 @@ before analytics or marketing consent — check the project's choice in "Project
|
||||
`nonce` to `<SiteProviders>`. A visitor who decided must never see the banner on reload; one whose
|
||||
decision is from an older Policy version must see it at once. A click on a button before hydration
|
||||
counts (the checks above click as soon as the button is visible).
|
||||
7. Cookie button (1.17.2, consent.md → "Where the cookie button sits"): after a decision, on a long page, a short
|
||||
page and a page with a form, desktop and phone width (also 360 px) — the button is in the bottom corner of the
|
||||
window at the top, in the middle, with the footer in view and at the very end: it must not move at all. At the
|
||||
very end nothing of the footer is under it and the last footer link can be tapped (the footer has grown a little:
|
||||
`[data-ipal-cookie-space]` on it). Before a decision and while the banner is open the footer has its own padding
|
||||
only. Tab reaches the button and Enter reopens the banner. A project scroll handler, a button rendered inside
|
||||
the footer or hand-made bottom padding for it → remove (AGENT.md §7). Too much or too little room:
|
||||
`--ipal-cookie-button-space` on the footer; none: `reserve={false}`.
|
||||
|
||||
The script needs buttons with `data-ipal="accept"` / `"reject"` — the plugin's
|
||||
`CookieBanner` has them in every `settings` mode (`inline`, `modal`, `detailed`). A custom banner in the project violates AGENT.md §7.
|
||||
|
||||
@@ -34,6 +34,8 @@ through this procedure. Ask only when you are missing something you cannot get y
|
||||
### Build / TypeScript
|
||||
| Symptom | Cause | Fix |
|
||||
|---|---|---|
|
||||
| a panel button (mail service Connect / Disconnect, Send test e-mail, cookie scan / approve / check site) answers `403` "Not allowed from this origin."; log `[iapl] a panel action from origin "…" was refused` | the request's origin is not one the site knows (1.17.2, `adminSameOrigin`): a reverse proxy that rewrites `Host` and sends no `X-Forwarded-Host`, and no `serverURL` | set `serverURL: process.env.NEXT_PUBLIC_SERVER_URL` in the Payload config, or make the proxy send `X-Forwarded-Host`, or `adminSameOrigin: { origins: ['https://…'] }`; `iapl-doctor` `csrf-empty` |
|
||||
| a staff account's correct password gets "The email or password provided is incorrect." | the account is locked by Payload after `maxLoginAttempts` wrong passwords (5, for `lockTime`, 10 min); since 1.17.2 a locked staff account gets the wrong-password answer (`accounts.lockedAnswer`) | wait for the lock to end, or an admin unlocks it (the account in the panel, or `POST /api/users/unlock`); `lockUntil` on the account shows it. Payload's own message back: `accounts: { lockedAnswer: 'payload' }` |
|
||||
| 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` |
|
||||
|
||||
@@ -56,7 +56,8 @@ Existing client sites are not gated on it; run it there as a report only.
|
||||
`GET /api/ipal/doctor` is added by `iapl` and answers 404 until the site has `IAPL_DOCTOR_TOKEN` (≥ 32 characters).
|
||||
Then `Authorization: Bearer <token>`; counts and states only (`usersWithout2fa`, `usersSetupClosed` = of those, blocked because the 2FA setup window has passed, `pendingCookies`, `openSignUp` = slugs of auth collections with open sign-up, `turnstile` = the recorded state of the Turnstile check, `turnstileSecretFromEnv`, `plugin`, `node`) — never a key or a name. With the same
|
||||
`IAPL_DOCTOR_TOKEN` in the doctor's environment, `--url` reads it. Off: `iapl({ doctor: false })`; adapt:
|
||||
`iapl({ doctor: { tokenVar, access } })`.
|
||||
`iapl({ doctor: { tokenVar, access } })`. `access` returns a boolean (`({ req }) => isAdmin(req.user, req.payload)`):
|
||||
since 1.18.0 any other answer is reported once in the server log, and from 1.19.0 only `true` allows.
|
||||
|
||||
## Env the doctor reads
|
||||
|
||||
|
||||
@@ -35,4 +35,6 @@ Requires the UI primitives from `../iapl-block/resources/section-code.md` (like
|
||||
|
||||
## Verification
|
||||
The **iapl-audit** skill. By hand: a menu item added in the panel is visible right after
|
||||
saving; the mobile menu works with the keyboard (Tab, Enter, Esc).
|
||||
saving; the mobile menu works with the keyboard (Tab, Enter, Esc). A menu item that points at a page never
|
||||
published is not shown (since 1.18.0 the helpers leave draft pages out; `createContentHelpers({ draftRelations:
|
||||
'keep' })` shows it as before): publish the page and the item appears.
|
||||
|
||||
@@ -38,6 +38,7 @@ 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.lockedAnswer` | `'wrong'` (1.17.2) | a staff account Payload has locked (too many wrong passwords) gets exactly the wrong-password answer on login (REST, GraphQL, the panel): nobody tells which addresses have an account; the lock itself is unchanged | `'payload'` = Payload's "This user is locked…"; any other value stops the start |
|
||||
| `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` |
|
||||
@@ -45,6 +46,7 @@ description: Complete map of everything @intecion/ipal-kit provides — every ia
|
||||
| "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 |
|
||||
| `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) |
|
||||
| `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 |
|
||||
| `adminRoute` | `'/admin'` | `config.routes.admin`; stats link and views, `IntegrationAlerts` | the project moves `app/(payload)/<route>/` itself and adds the route to the proxy matcher (security.md) |
|
||||
| `twoFactor` | **none = error** | `@clocklimited/payload-2fa` with `forceSetup: true` (TOTP enforced, also checked in the API) | `twoFactor: false` (discouraged); omitting the option throws `[iapl] twoFactor.issuer is required` |
|
||||
| `twoFactor.issuer` | — (required) | name in the authenticator app | — |
|
||||
@@ -96,7 +98,7 @@ description: Complete map of everything @intecion/ipal-kit provides — every ia
|
||||
| `forms.adminGroup` | `'Forms'` | sidebar group | `false` = Payload default; `admin.group` in overrides wins |
|
||||
| `forms.fields.*` | on: `checkbox`, `checkboxGroup`, `country`, `date`, `email`, `message`, `number`, `radio`, `select`, `state`, `step`, `text`, `textarea`, `time`; off: `payment` | block types in the builder (all with "Show only when") | `<type>: false`; a block object replaces it; `payment: true` **does nothing** (filtered out) — pass a block object |
|
||||
| `forms.formOverrides` | Form/Forms labels, `emails` readable by logged-in users only | overrides the `forms` collection (`fields: ({ defaultFields }) => …`, `slug`, `admin`, `access`…) | any `CollectionConfig` |
|
||||
| `forms.formSubmissionOverrides` | create: logged-in, read: editor+, delete: admin | overrides `form-submissions` | `access.create` etc. wins |
|
||||
| `forms.formSubmissionOverrides` | create: a staff account with its second factor (since 1.17.2; before: any signed-in account), read: editor+, delete: admin | overrides `form-submissions` | `access.create` etc. wins |
|
||||
| `forms.redirectRelationships` | none | collections a form can redirect to | `['pages']` |
|
||||
| `forms.emailLayout` | `false` | `beforeEmail` with a layout (logo, colour, footer) + Site settings → **Emails** tab; `{{*:table}}` readable | `true` |
|
||||
| `forms.beforeEmail` | none | your own e-mail changes (after the layout) | form-builder function |
|
||||
@@ -105,6 +107,7 @@ description: Complete map of everything @intecion/ipal-kit provides — every ia
|
||||
| `forms.consentFieldName` | `'consent'` | name of the GDPR consent field `submitForm` requires (read from `config.custom.ipal`) | `createSubmitAction({ consentFieldName })` / `submitForm` argument wins |
|
||||
| `consentLog` | **on** (since 1.17.0) | `consent-records` collection + `POST /api/ipal/consent` (rate limit 20/min); Postgres / SQLite: a table, migration in the same deploy | `false` / `{ retentionDays }` (default 1095) |
|
||||
| `consentLog.collectionOverrides` | none | changes `consent-records`: an object merges `access` / `admin` / `hooks` key by key (your keys win), a function `(collection) => collection` takes over (keep the slug) | e.g. `{ access: { read: ({ req }) => req.user?.email === '[email protected]' } }` — narrows who reads records in a project without roles |
|
||||
| `jobsRunAccess` | on (since 1.17.2), only when the project writes no `jobs.access.run` | Payload's job queue over HTTP (`/api/payload-jobs/run`, `/handle-schedules`): an admin with the second factor (an admin API key counts) or `Authorization: Bearer <CRON_SECRET>` (16+ chars); before: any signed-in account of any auth collection. In-process runs (`jobs.autoRun`, `payload jobs:run`) unaffected | `false` = Payload's default; `{ secretVar }` = another variable; your own `jobs.access.run` wins. Check: `curl -H "Authorization: Bearer $CRON_SECRET" $URL/api/payload-jobs/run` → 200, without it 401 (security.md "Payload's job queue") |
|
||||
| `doctor` | on (404 until `IAPL_DOCTOR_TOKEN` is set) | `GET /api/ipal/doctor` — read-only counts for `iapl-doctor --url` (users without TOTP, cookies waiting for approval, versions); Bearer token ≥ 32 characters, rate-limited, never names or values | `false` = no endpoint; `{ tokenVar, access }` (doctor.md) |
|
||||
| `cookieScanner` | off | `cookie-review` collection, "Scan cookies" box above its list (`CookieScanButton`), `GET`/`POST /api/ipal/cookie-scan`, and (unless `approval: false`) the *Approve cookies* view `/admin/cookie-approval` (`CookieApprovalView`) + `GET`/`POST /api/ipal/cookie-approval` + the dashboard reminder; a scan lists the cookies of the integrations switched on + names looked up in the bundled Open Cookie Database; one **Approve and add** puts the ticked cookies into Cookies → Cookie list (so `<CookieTable>` and the detailed window); never deletes, never overwrites edited text, never duplicates, nothing reaches the banner before approval | `true` / object; after switching on: `pnpm generate:importmap` + `migrate:create`. Check: *Privacy → Cookie review* → **Scan cookies** → "Waiting for approval: N" → **Review and approve** → **Approve and add** → the cookies are in Cookies → Cookie list (cookie-scanner.md) |
|
||||
| `cookieScanner.adminLayout` | `'combined'` | one *Cookies* entry: *Review and approve* and (with `crawl`) *Site check* tabs on the `cookie-settings` global (`ui` fields, `CookieReviewTab` / `CookieSiteCheckTab`); `cookie-review` and `cookie-crawl` get `admin.group: false` (out of the nav, pages and API kept) | `'separate'`; no migration, `generate:importmap` |
|
||||
@@ -280,6 +283,7 @@ The plugin's own variables are `IAPL_<NAME>`; a deploy that sets the spelling fr
|
||||
| `IAPL_IP_HEADER` | `ipHeader: true` + production | rate limit trusts any IP header (spoofing) + warning in prod | env: `cf-connecting-ip` (Cloudflare) / `x-forwarded-for` (Traefik/nginx) |
|
||||
| `IAPL_COOKIE_SCAN_URL`, `IAPL_COOKIE_SCAN_TOKEN` | `cookieScanner.crawl` (`iaplEnvRules({ cookieCrawl: true })` requires both in production; token ≥ 16 chars) | **Check site** disabled, the box names the missing variable | env; the token also goes into the scanner service's `IAPL_CRAWLER_SITES` as `host=token` |
|
||||
| `IAPL_DOCTOR_TOKEN` | no; ≥ 32 characters | `GET /api/ipal/doctor` answers 404; with it the endpoint answers a Bearer token, and `iapl-doctor --url` with the same variable reads the deep counts | env (Coolify) and the doctor's shell; also read by the doctor: `CI`, `NO_COLOR`, `PAYLOAD_CONFIG_PATH` (`--deep`), `IAPL_DOCTOR_IMPORT_MAP` (internal) — doctor.md |
|
||||
| `CRON_SECRET` | no; ≥ 16 characters (name: `jobsRunAccess.secretVar`) | Payload's job queue runs over HTTP only for an admin; the start log says so when the queue is on | env (Coolify); the cron sends `Authorization: Bearer <CRON_SECRET>` to `/api/payload-jobs/run` |
|
||||
| `IAPL_NOINDEX` | no; `1`/`true`/`yes` **staging/preview only** | — (when set: robots Disallow, meta noindex, `X-Robots-Tag`, IndexNow sends nothing) | staging env |
|
||||
| `NEXT_PHASE` | set by Next | only tells `next build` from runtime: during the build an unreachable database gives an empty sitemap; at runtime the sitemap throws (route → 503) | do not set by hand |
|
||||
| `NEXT_RUNTIME` | set by Next | `instrumentation.ts` checks for `nodejs`; missing (scripts, seed) → `buildRevalidateHook` does not revalidate | do not set by hand |
|
||||
|
||||
@@ -85,10 +85,12 @@ 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. |
|
||||
|
||||
| `requireOwnOrigin(endpoint, origins?)`, `guardAdminEndpoints(config, projectEndpoints, option)`, `ADMIN_POST_ENDPOINTS`, type `AdminSameOriginOption` | `@intecion/ipal-kit` | `adminSameOrigin` (1.17.2): wraps an endpoint so a request a browser marks as coming from another origin gets `403` (logged once per origin); applies it to the plugin's panel actions it added; the list of `[method, path]` covered. `reportRefusedOrigin(req, origins?, { what, option, docs }?)` names your option in the log line. |
|
||||
| `lockedLooksWrong`, `withLockedAnswer(config)`, `graphqlLoginName(collection)` | `@intecion/ipal-kit` | `accounts.lockedAnswer` (1.17.2): the config-level `afterError` hook that answers Payload's `LockedAuth` on a staff collection's login (REST, GraphQL) exactly like `AuthenticationError`; adding it to a config (idempotent); the GraphQL login mutation's name of a collection. |
|
||||
| `applySignInRules(collection, accounts?)`, `buildSignInBeforeOperation(slug, rules)`, `releaseSignInPlace`, `settleFailedSignIn`, `buildCurrentPasswordField()`, `resolveSignInRules(accounts?)`, `foldSignInName(value)`, `passwordMatches({ hash, salt }, password)`, `CURRENT_PASSWORD_FIELD`, `SIGN_IN_RULES_MARK` (the mark on the `beforeOperation` hook); 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`).
|
||||
**Types:** `AccountsOptions` (`accounts`: `panelRole`, `adminOnlyCreate`, `adminOnlyWrite`, `staffOnlyRead`, `firstUserRoute`, `password`, `lockedAnswer`, `signInLimit`, `signInSameOrigin`, `confirmOwnChanges`), `LockedAnswerOption`, `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`
|
||||
|
||||
@@ -168,8 +170,10 @@ Fifteen ready blocks and ten page templates. **Use a library block (or a variant
|
||||
|---|---|---|
|
||||
| `ConsentProvider` | `@intecion/ipal-kit/client` | Consent provider: `{ texts, cookieMap?, logEndpoint?, nonce?, cookieValue?, gpc?, maxAgeDays? }` (`gpc`: Global Privacy Control `'honour'` default / `'ask'` / `false`; `maxAgeDays`: re-ask period, default 180; withdrawal also removes the panel's listed storage keys and tells Meta / TikTok / Clarity) (`nonce`: CSP nonce for the banner's first-paint script; `cookieValue`: optional server-read consent cookie → exact HTML, dynamic pages) — consent state, cookie, Consent Mode, deleting cookies after consent is withdrawn, optional POST of the decision to the log (`'/api/ipal/consent'`). Wrap the layout once; required by the banner, `Analytics`, `ConsentScript`. |
|
||||
| `CookieBanner` | `@intecion/ipal-kit/client` | Consent banner + category settings: `settings: 'inline' \| 'modal' \| 'detailed'`, `controls`, `equalChoice` (recommended `true`), `order`, `settingsActions`, `icon`, `classNames`, `firstPaint` (default `true`: in the server HTML, decided before the first paint by an inline script; pages stay static), `nonce`; colours from `--ipal-*` CSS vars. Do not write your own banner. |
|
||||
| `CookieButton` | `@intecion/ipal-kit/client` | Floating button that reopens the cookie settings (withdrawing consent); hidden while the banner is visible. Props `className`, `side` (`'left' \| 'right'`), `avoid` (selector it lifts above, default `COOKIE_BUTTON_AVOID` = footer; `false`). Tokens `--ipal-cookie-button-offset`, `--ipal-cookie-button-inset`. Type `CookieButtonProps`. |
|
||||
| `COOKIE_BUTTON_AVOID`, `bottomOverlap(tops, viewportHeight)` | `@intecion/ipal-kit/client` | Default footer selector; pixels the footer covers at the bottom of the screen (how far the button moves up) |
|
||||
| `CookieButton` | `@intecion/ipal-kit/client` | Floating button that reopens the cookie settings (withdrawing consent); hidden while the banner is visible. Fixed in the bottom corner of the window on every page and never moves (1.17.2: it no longer climbs above the footer). While it is shown the footer gets just enough bottom padding for its last row to end above the button (measured; the footer's own padding counts; nothing where the corner is empty; made before the first paint for a returning visitor). Props `className`, `side` (`'left' \| 'right'`), `reserve` (selector of the block that gets the room, default `COOKIE_BUTTON_RESERVE` = footer; `false` = none), `avoid` (placement before 1.17.2: selector it lifts above — `COOKIE_BUTTON_AVOID`). Amount by hand: `--ipal-cookie-button-space` on the footer (`0` = none). Tokens `--ipal-cookie-button-offset`, `--ipal-cookie-button-inset`. Type `CookieButtonProps`. |
|
||||
| `COOKIE_BUTTON_AVOID`, `bottomOverlap(tops, viewportHeight)` | `@intecion/ipal-kit/client` | Footer selector for the placement before 1.17.2 (`<CookieButton avoid={COOKIE_BUTTON_AVOID} />`); pixels the footer covers at the bottom of the screen (how far the button moves up then) |
|
||||
| `COOKIE_BUTTON_RESERVE`, `COOKIE_BUTTON_SPACE_ATTRIBUTE`, `reserveCookieButtonSpace(options)` | `@intecion/ipal-kit/client` | Default selector of the block that gets room for the cookie button (the footer); the attribute that marks it while the room is there; the function that measures and applies (or, with `release: true`, removes) it — options type `CookieButtonSpaceOptions` (`selector`, `side`, `button?`, `release?`, `sheet?`). For a button of your own |
|
||||
| `consentDecidedScript({ version?, gpc?, cookieName? })` | `@intecion/ipal-kit` | JavaScript statements for an inline script: leave `true` in `d` when the browser holds a current consent decision (as `readConsentRecord` decides). The shared start of the plugin's pre-paint scripts |
|
||||
| `TOTP_TEXTS`, `TOTP_VIEW_TITLE` | `@intecion/ipal-kit` | en/pl texts of the 2FA screens (`totpPlugin:*`, merged by `twoFactor`) and their tab title |
|
||||
| `ConsentScript` | `@intecion/ipal-kit/client` | Loads an external script (`src` or `code`) only after consent for `category` — for vendors without Consent Mode (chat, Plausible etc.). Inside `ConsentProvider`. |
|
||||
| `CookieTable` | `@intecion/ipal-kit/rsc` | Server Component: cookie table for the cookie policy page — `{ rows, labels?, locale?, categories?, caption?, classNames?, storageColumn?, storageTypes? }`; `rows` from `getCookieTable()`; a **Type** column when a row is local / session storage (`storageColumn: 'auto' \| boolean`). |
|
||||
@@ -747,6 +751,7 @@ Most routes and metadata are already ready in `createContentHelpers` (`generateP
|
||||
| `setRateLimitStore(store \| null)` | `@intecion/ipal-kit` | Shared store (e.g. Redis) for all plugin limiters (forms, consents, MCP…); `null` = process memory. Call once at startup when several instances run. |
|
||||
| `setUnknownIpFactor(n)` | `@intecion/ipal-kit` | Requests with no client IP share one `unknown-ip` bucket with `n` × the limit (every plugin limiter). Call once at startup; `0` = unlimited (only with a limiter in front, e.g. Cloudflare). |
|
||||
| `UNKNOWN_IP_FACTOR` | `@intecion/ipal-kit` | `20` — the default factor of the no-IP bucket. |
|
||||
| `setIpv6Grouping({ prefix?, wide?, wideFactor? })`, `ipRateKey(ip)`, type `Ipv6Grouping` | `@intecion/ipal-kit` | 1.17.2: how every plugin limiter counts IPv6 — default one client per /64 (`prefix: 64`), no wide counter; `wide: 48` adds a counter per /48 at `wideFactor` (10) × the limit; `prefix: 128` = per address. Out-of-range values throw. `ipRateKey`: an IPv4 as it is, `::ffff:a.b.c.d` as the IPv4, an IPv6 as its network (`2001:db8:1:2:0:0:0:0/64`), anything else unchanged. |
|
||||
|
||||
**Types:** `ClientIpOptions` — `clientIp` options; `RateLimitStore` — store contract (`hit(id, cost, windowMs)` → `{ count, resetAt }`).
|
||||
|
||||
@@ -875,6 +880,9 @@ Bin: `iapl-doctor` (`pnpm exec iapl-doctor [dir] [--json] [--md] [--strict] [--f
|
||||
| `runDeepProbe(ctx)` | `@intecion/ipal-kit/doctor` | `pnpm exec payload run …/dist/modules/doctor/probe.js` in the project → `DoctorStatus`. |
|
||||
| `collectDoctorStatus(payload)` | `@intecion/ipal-kit/doctor` | Read-only counts: `usersWithout2fa`, `pendingCookies`, `plugin`, `node`. |
|
||||
| `buildDoctorEndpoint({ tokenVar, access })` | `@intecion/ipal-kit/doctor` | `GET /ipal/doctor` (`/api/ipal/doctor`): 404 until the token variable (default `IAPL_DOCTOR_TOKEN`, ≥ 32 chars) is set, Bearer token or `access`, rate-limited. Added by `iapl` unless `doctor: false`. |
|
||||
| `jobsRunAccess({ secretVar? })` | `@intecion/ipal-kit` | The rule iapl puts on `jobs.access.run` when the project writes none: `cronSecretMatches(req, process.env[secretVar])` or an admin with the second factor. Reuse it in your own rule: `run: (a) => jobsRunAccess()(a) \|\| myCheck(a)`. Type `JobsRunAccessOptions`. |
|
||||
| `withJobsRunAccess(config, options \| false)` / `jobsRunNotice(config)` | `@intecion/ipal-kit` | The config with that rule (only when `jobs.access.run` is missing; marks `custom.iapl.jobsRunDefault`); the start-up line when the queue is on and the secret is missing (null otherwise). |
|
||||
| `cronSecretMatches(req, secret)`, `CRON_SECRET_ENV`, `CRON_SECRET_MIN_LENGTH` | `@intecion/ipal-kit` | `Authorization: Bearer <secret>` compared in constant time; an unset or shorter-than-16 secret never matches. Default variable `CRON_SECRET`. |
|
||||
| `runRouteCheck({ config, appDir?, snapshot?, update?, graphql?, cwd?, log? })` | `@intecion/ipal-kit/doctor` | `routes:check`: every public route (REST, GraphQL, Next route files) against the judged snapshot (default `e2e/routes.snapshot.json`); returns 1 on a route nobody judged or an entry without a reason; `update` writes new routes with an empty reason. Template: `iapl-audit/resources/routes.template.ts` (security.md "Routes nobody has judged"). Type `RunRouteCheckOptions`. |
|
||||
| `listPublicRoutes(config, { graphqlSchema?, routeFiles? })` | `@intecion/ipal-kit` | Stable ids of every door a built config opens: `GET /api/users/me`, `graphql mutation loginUser`, `next GET /sitemap.xml`. From the config only (same on every database). Types `RouteInventoryOptions`, `GraphqlSchemaLike` (`getQueryType` / `getMutationType`). |
|
||||
| `listNextRouteFiles(files, read)` | `@intecion/ipal-kit` | Next route handlers of an app directory (`route.ts` with the methods it exports, `robots.ts`, `sitemap.ts`, `manifest.ts`; route groups left out). |
|
||||
|
||||
@@ -39,6 +39,32 @@ no migration, no import-map change; read before deploying:**
|
||||
**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.2, security (CHANGELOG 1.17.2; PROGRAMISTA §6, items 84–87) — nothing required, check:** `readVersions:
|
||||
readPublished()` now works (a wrapper of your own around it: use `readPublishedVersions()` inside); behind a proxy
|
||||
that rewrites `Host` without `X-Forwarded-Host`, set `serverURL` or the panel's mail / cookie buttons answer 403
|
||||
(`iapl-doctor` warns); a locked editor sees "incorrect" until the lock ends (`accounts.lockedAnswer: 'payload'` for
|
||||
Payload's text); saving Cookies with a lower consent version is refused (`cookieSettings.allowLowerPolicyVersion`).
|
||||
**Check:** `curl -s <site>/api/pages/versions` as a visitor → 200 (published only), not 500.
|
||||
|
||||
**→ 1.17.2:** (1) Payload jobs: if the project has tasks or workflows and a cron calls `/api/payload-jobs/run` (or
|
||||
`/handle-schedules`) without its own `jobs.access.run`, set `CRON_SECRET` (16+ characters) in the app's environment
|
||||
and send `Authorization: Bearer <CRON_SECRET>` from the cron; in-process runs (`jobs.autoRun`, `payload jobs:run`)
|
||||
and an admin's API key need nothing (security.md "Payload's job queue"). Verify: the run route answers 401 without
|
||||
the header, 200 with it. (2) A front end that posted to `/api/form-submissions` as a customer account (not through
|
||||
`submitForm`): move it to `submitForm` / `createSubmitAction`, or set `forms.formSubmissionOverrides.access.create`.
|
||||
(3) A site with a visitor login collection: `iapl-doctor --url …` lists `visitor-writes`; give each listed collection
|
||||
and global its own write rule (`adminOrEditor`). (4) If the project has `tests/routes.ts`: `update`, judge, commit.
|
||||
|
||||
**→ 1.17.2, cookie button (CHANGELOG 1.17.2; PROGRAMISTA §6, item 83; consent.md "Where the cookie button sits") — nothing is required:**
|
||||
visitors now see the "cookie settings" button in the bottom corner of the window on every page; it never moves and
|
||||
no longer rides up above the footer. While it is shown the footer is a little taller (about 40 px on the reference
|
||||
site), so its last row ends above the button. Check the end of a page on a phone and on desktop: nothing under the
|
||||
button, the last footer link can be tapped. Bottom padding a project added by hand for the button: remove it (the
|
||||
plugin counts existing padding, so it is not doubled, but it is no longer needed). Amount by hand:
|
||||
`--ipal-cookie-button-space` on the footer (`0` = none); no room: `reserve={false}`. The placement before:
|
||||
`cookieButton={<CookieButton avoid={COOKIE_BUTTON_AVOID} />}` on `SiteProviders`. A project e2e that expects the button
|
||||
above the footer, or an exact footer height after a decision: update it.
|
||||
|
||||
**→ 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`):
|
||||
@@ -266,7 +292,7 @@ and the browser tab shows the same separator.
|
||||
cookie banner only through `--ipal-*-dark`: check the banner in the dark theme.
|
||||
4. Optional: the block library, block by block (block-library.md); after turning blocks on: `pnpm generate:types`,
|
||||
`pnpm payload generate:importmap`, Postgres/SQLite `migrate:create`.
|
||||
5. **CookieButton** lifts above the footer — check a site with its own fixed footer bar; `avoid={false}` keeps it fixed.
|
||||
5. **CookieButton** lifts above the footer — check a site with its own fixed footer bar; `avoid={false}` keeps it fixed. (Since 1.17.2 it stays in the bottom corner by default; the lift is `avoid={COOKIE_BUTTON_AVOID}`.)
|
||||
6. `pnpm exec iapl-skills` (new **iapl-doctor**; updated iapl-reference, iapl-setup, iapl-site, iapl-audit).
|
||||
7. Run `pnpm exec iapl-doctor` (and `--url https://<site>`), fix or silence each finding with a reason in
|
||||
`iapl-doctor.json`. `IAPL_DOCTOR_TOKEN` (≥ 32 characters) only if the deep check runs against production.
|
||||
|
||||
+53
-7
@@ -113,12 +113,51 @@ takes `locale` and optional `labels`; defaults: `COOKIE_TABLE_LABELS` (`@intecio
|
||||
| `controls` | `'checkbox'` | `'checkbox' \| 'switch'` |
|
||||
| `settingsActions` | `['back', 'save']` | buttons under the categories (`'accept' \| 'back' \| 'reject' \| 'save'`) |
|
||||
|
||||
`CookieButton` props: `className` (replaces the default classes; position is then yours too),
|
||||
`side` (`'left'` default or `'right'`), `avoid` (CSS selector, default `COOKIE_BUTTON_AVOID` =
|
||||
`'footer, [role="contentinfo"]'`; `false` = never move). While the footer is on screen the button
|
||||
moves up by its visible part (`bottomOverlap`), so it never covers footer links. Position tokens:
|
||||
`--ipal-cookie-button-offset` (from the bottom, default `1rem`), `--ipal-cookie-button-inset` (from the
|
||||
side, default `1rem`); z-index `--ipal-z-header`. Type `CookieButtonProps`.
|
||||
### Where the cookie button sits (1.17.2)
|
||||
|
||||
`CookieButton` is fixed in the **bottom corner of the window** — on every page, long or short, at every scroll
|
||||
position, on desktop and phone — and it **never moves**. It is a child of `<body>` (never inside the footer) and it
|
||||
no longer climbs above the footer when the footer scrolls into view (1.12.x–1.17.1 did that: on a phone with a tall
|
||||
footer the button ended at the top of the screen, on a short page in the middle of it).
|
||||
|
||||
**Room under the footer.** A fixed button would, at the very end of a page, lie on whatever is in that corner — the
|
||||
first link of the footer's last row — and a visitor could not scroll it free. So while the button is shown, the
|
||||
plugin gives the page's last block (the footer) **bottom padding: just enough for its last row to end above the
|
||||
button** (`reserveCookieButtonSpace`). The footer's background continues through it.
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| How much | measured, not fixed: the button's height + its distance from the bottom + the device's safe area + 8 px, **minus what is already free** under the lowest text or control in the button's column. The footer's own bottom padding counts first — never double space. On the reference site: 42–43 px on phones and desktop |
|
||||
| Where nothing is in the corner | nothing is added (a centred footer on a wide screen, the button on the other side) — so there is no breakpoint to configure |
|
||||
| When | only while the button is shown: not before a decision, not while the banner is open (the footer is as the project made it), gone when the button is turned off (`cookieButton={false}`) |
|
||||
| No layout shift | on a static page the HTML carries a small inline script next to the button's place: for a visitor who already decided it makes the room **before the first paint** (in a style sheet, so React hydrates the server's markup untouched), and the button's own measurement after hydration gives the same size. After a click in the banner the room appears with the button. Later changes (fonts, a form that grows, a resize) are followed |
|
||||
| Which block | the last element matching `reserve` (default `COOKIE_BUTTON_RESERVE` = `'footer, [role="contentinfo"]'`); none on the page → `<body>` |
|
||||
|
||||
| Prop | Default | What it does |
|
||||
|---|---|---|
|
||||
| `side` | `'left'` | corner: `'left'` or `'right'` |
|
||||
| `reserve` | `COOKIE_BUTTON_RESERVE` | CSS selector of the block that gets the room (the last match); `false` = no room — the button then covers what is in the corner at the end of the page |
|
||||
| `avoid` | — | placement before 1.17.2: a CSS selector the button lifts above while it is on screen — `avoid={COOKIE_BUTTON_AVOID}` (`'footer, [role="contentinfo"]'`) is exactly the old default (`bottomOverlap`); no room is reserved then. `false` = the default (kept for sites that set it) |
|
||||
| `className` | — | replaces the default classes; position is then yours too (room is measured from the real button once it is on the page, and only while it is `position: fixed`) |
|
||||
|
||||
**Set the amount yourself:** `--ipal-cookie-button-space` on the footer — any length, added to the footer's own
|
||||
padding instead of the measured amount; `0` = none, also per breakpoint:
|
||||
|
||||
```css
|
||||
footer { --ipal-cookie-button-space: 4rem; }
|
||||
@media (min-width: 64rem) { footer { --ipal-cookie-button-space: 0; } } /* nothing on desktop */
|
||||
```
|
||||
|
||||
Position tokens: `--ipal-cookie-button-offset` (from the bottom, default `1rem`), `--ipal-cookie-button-inset`
|
||||
(from the side, default `1rem`); the device's safe-area insets (bottom and the chosen side) are added. z-index
|
||||
`--ipal-z-header` (default 40): above the page, below the banner, the settings window and the lightbox (50).
|
||||
Hidden while the banner is showing. Keyboard: a `<button>` in the tab order with an `aria-label` from the panel.
|
||||
Type `CookieButtonProps`.
|
||||
|
||||
Nonce CSP: the inline script takes the nonce given to `SiteProviders` / `ConsentProvider`; refused, the room is made
|
||||
when the button appears (a footer pinned to the bottom of a page shorter than the window then moves once).
|
||||
Building blocks: `reserveCookieButtonSpace({ selector, side, button?, release? })`, `COOKIE_BUTTON_SPACE_ATTRIBUTE`
|
||||
(`/client`), `consentDecidedScript` (root).
|
||||
|
||||
## Compliance defaults (1.17.0)
|
||||
|
||||
@@ -449,7 +488,7 @@ New fields in the global = a migration in projects on Postgres/SQLite (`payload
|
||||
|
||||
The elements also have stable `data-ipal` handles for CSS and e2e tests (used by
|
||||
`iapl-consent-check`): `banner` (while it waits for the first-paint script it carries `hidden`; a button clicked before hydration:
|
||||
`data-ipal-pending`; live: `data-ipal-ready`), `banner-script`, `cookie-button` and the buttons `settings`, `reject`,
|
||||
`data-ipal-pending`; live: `data-ipal-ready`), `banner-script`, `cookie-button` (`cookie-button-script`: its inline script in the server HTML; `data-ipal-cookie-space` on the footer while it holds the button's room) and the buttons `settings`, `reject`,
|
||||
`accept`, `back`, `save`; in modal mode also `consent-overlay`, `consent-dialog`, `close`; in detailed mode
|
||||
additionally `category-<category>` (card) and `cookies` (expandable list).
|
||||
|
||||
@@ -542,6 +581,13 @@ to add the hook to a config. Nothing to migrate.
|
||||
- **New consent after a policy change:** Cookies → *Consent version* (sidebar). Raise it by 1
|
||||
after adding a tool or changing the policy — every visitor will see the banner again.
|
||||
`getConsentTexts` passes the version to `<ConsentProvider texts>` automatically.
|
||||
- **The consent version only goes up (1.17.2).** A stored consent counts only under the version it was given for,
|
||||
so a lower number would make consent given under an older policy valid again. Saving Cookies with a lower
|
||||
*Consent version* through the panel, REST or GraphQL is refused: "The consent version cannot go down: it is 3
|
||||
now…" (Polish in a Polish panel). The same number, a higher one, or a save without it pass. A script an admin runs
|
||||
with the Local API and `overrideAccess` may still lower it. Turn the rule off: `iapl({ cookieSettings:
|
||||
{ allowLowerPolicyVersion: true } })`. Building blocks: `policyVersionNeverDown` (the field hook),
|
||||
`buildCookieSettingsFields({ allowLowerPolicyVersion })`, `buildCookieSettings(options)`.
|
||||
- **Withdrawing consent deletes the tools' cookies** (`_ga`, `_ga_*`, `_gid`, `_fbp`, `_gcl_*`, Clarity,
|
||||
LinkedIn, TikTok, Hotjar…) — also on the parent domain (`.client.com`), where GA stores them.
|
||||
The project's own cookies: `<ConsentProvider cookieMap={{ marketing: ['_my*'] }}>` (added to the
|
||||
|
||||
@@ -108,6 +108,33 @@ ambiguous (the same entry under many URLs), so `/a/b/c` → null.
|
||||
**Slug collision:** two collections with an archive with the same slug → the first one
|
||||
in the `collections` list wins. A configuration error; the router does not warn.
|
||||
|
||||
## Drafts as related documents (1.18.0)
|
||||
|
||||
A page is read at depth 2, Site settings and archive entries at depth 1, and Payload fills in every related document
|
||||
whatever its status. Before 1.18.0 a block, a menu or a System pages link that pointed at a page never published
|
||||
brought that page's title, slug and text into what the helpers answered (and llms-full printed it). Now the helpers
|
||||
leave such a related document out, as if it did not exist:
|
||||
|
||||
| Shape | Becomes |
|
||||
|---|---|
|
||||
| a single relationship | `null` — a link resolves to nothing, a menu item drops out |
|
||||
| a list of relationships | the draft is removed from it |
|
||||
| a polymorphic one `{ relationTo, value }` | `value: null` |
|
||||
|
||||
A related document counts as a draft when it carries `_status` other than `'published'` (a never-published or
|
||||
unpublished document of a collection with drafts). Documents without `_status` (collections without drafts, media)
|
||||
are never touched; the document itself is judged as before (only published pages are served). Applies to
|
||||
`createContentHelpers` (`getSettings`, `resolveRoute`, `getEntries`, `getNotFoundPage`, the page route, Markdown,
|
||||
MCP, llms-full), `resolveRoute`, `getArchiveEntries`, `resolveNotFoundPage`, `collectSiteIndex` and
|
||||
`buildLlmsTxt` / `createLlmsTxtRoute`. A preview (`draft: true`) keeps them.
|
||||
|
||||
- **What an existing site sees:** a menu item, a card or a link whose page was never published disappears for
|
||||
visitors instead of showing a title that leads to a 404. Publish the page, or point the link elsewhere.
|
||||
- **Keep the old behaviour:** `createContentHelpers({ draftRelations: 'keep' })`, or `draftRelations: 'keep'` on
|
||||
`resolveRoute` / `getArchiveEntries` / `resolveNotFoundPage` / `collectSiteIndex` / `buildLlmsTxt`.
|
||||
- **Building blocks:** `withoutDraftRelations(value)` (returns the same object when nothing changes, copies only
|
||||
the changed path), `applyDraftRelations(value, { draft, draftRelations })`, type `DraftRelations`.
|
||||
|
||||
## Front-end helpers — createContentHelpers
|
||||
|
||||
Instead of writing cached wrappers in every project:
|
||||
|
||||
@@ -259,7 +259,7 @@ All from `@intecion/ipal-kit` (server-safe), for your own admin view, a CLI or a
|
||||
| `cookieScanContext(payload, plugin, req?)` | the `CookieScanContext` a scan uses |
|
||||
| `parseCookieNames(input)` | the panel's text box → clean names |
|
||||
| `mergeCookieReview(current, previous, next)`, `suggestionFor(finding, locales)` | the "never overwrite an edit" rule, pure |
|
||||
| `addToCookieList({ payload, entry, req? })` | what accepting does: add the row or fill its empty text → `'added' \| 'filled' \| 'unchanged'`; a row with the same name or a covering pattern counts as the same cookie (`sameCookie(a, b)`) |
|
||||
| `addToCookieList({ payload, entry, req? })` | what accepting does: add the row or fill its empty text → `'added' \| 'filled' \| 'unchanged'`; a row with the same name or a covering pattern counts as the same cookie (`sameCookie(a, b)`). The list is written whole: since 1.18.0 it is read again right before writing and, when an editor's save changed it since, the change is worked out again on what is there now (up to 5 times), so a row saved in between is not lost. A Cookies form left open in the panel and saved later still writes the whole list it shows (Payload's document lock warns the second editor) |
|
||||
| `loadCookieApproval({ payload, locale, req? })` | the approval list → `CookieApprovalList` (`pending`, `gone`) |
|
||||
| `approveCookies({ payload, ids?, unknownCategory?, addToList?, req? })` | what **Approve and add** does → `CookieApprovalResult` |
|
||||
| `countPendingCookies(payload)`, `PENDING_WHERE` | how many wait / the query for them (drafts, and accepted cookies marked changed) |
|
||||
|
||||
@@ -690,6 +690,11 @@ Do one item at a time, build, check. Order by importance:
|
||||
| 80 | **1.17.1 — the sign-in look** — after the update the login and 2FA screens show a dark panel with the logo or the site's name; an editor cannot change the logo or name; forgot / reset password look as before | Nothing required. `whiteLabel: { signIn: false }` (old screens), `{ brandAccess: 'editor' }`, `{ signIn: { logoPlate: true } }` (a dark logo), `{ signIn: { svgLogo: false } }`; the other screens: `signIn: { allScreens: true }` + `pnpm payload generate:importmap`. No `serverURL` → no logo in the link preview: set it | `iapl-upgrade` "→ 1.17.1, the sign-in look", white-label.md "The sign-in screens" |
|
||||
| 81 | **1.17.1 — proxy matcher** — `iapl-doctor` warns `proxy-matcher`; pages such as `/administracja` or `/apis` get no locale redirect or proxy CSP | `src/proxy.ts`: `matcher: ['/((?!(?:api|admin|_next)(?:/|$)|.*\\..*).*)']` (i18n.md "Next matcher") | `iapl-upgrade` "→ 1.17.1" |
|
||||
| 82 | **1.17.1 — e-mail: "Sending method" is a choice** — Site integrations → E-mail sending shows "IWSN (built-in)", "Own SMTP server" or "Microsoft Graph (deprecated)" as selected; or, on Postgres / SQLite, the start log says the column for `emailMethod` is missing and the Site integrations page does not open; or mail fails with `smtp-incomplete` / `graph-not-set-up` | MongoDB: nothing. Postgres / SQLite: `pnpm payload migrate:create`, commit, apply at start. Nothing changes until another option is picked and saved; a chosen method that cannot be used fails loudly (no other transport): fill in SMTP, set `GRAPH_*`, or pick another method | `iapl-upgrade` "→ 1.17.1, e-mail", email.md "Which transport a send takes" |
|
||||
| 83 | **1.17.2 — cookie button** — after the update the "cookie settings" button no longer sits above the footer; or the footer is about 40 px taller after a decision | Intended: the button stays in the bottom corner of the window on every page and never moves; while it is shown the footer gets just enough bottom padding for its last row to end above the button (measured; own padding counts; nothing before a decision or while the banner is open). Nothing to run. No room: `<CookieButton reserve={false} />`; amount by hand: `--ipal-cookie-button-space` on the footer; the placement before: `avoid={COOKIE_BUTTON_AVOID}`; other corner: `side="right"`; distance: `--ipal-cookie-button-offset` | consent.md "Where the cookie button sits", `iapl-upgrade` "→ 1.17.2, cookie button" |
|
||||
| 84 | **1.17.2 — version history** — `GET /api/<collection>/versions` as a visitor answered 500 (`Cannot find field for path at _status`, MongoDB `reading 'type'`) with `readVersions: readPublished()` | Update; nothing else. New code: `readVersions: readPublishedVersions()`; a `readVersions` of your own that wraps `readPublished()` must use `readPublishedVersions()` inside | CHANGELOG 1.17.2 point 1, access.md |
|
||||
| 85 | **1.17.2 — sign-in and panel actions** — a locked editor is told "incorrect" with the right password; or a panel button (mail Connect / Disconnect, test e-mail, cookie scan / approval) answers 403 behind a proxy; or rate limits now count an IPv6 home network as one visitor | Locked: wait 10 minutes or an admin unlocks; Payload's text back: `accounts: { lockedAnswer: 'payload' }`. 403 behind a proxy: set `serverURL`; off: `adminSameOrigin: false`. IPv6 per address: `setIpv6Grouping({ prefix: 128 })` | CHANGELOG 1.17.2 points 2, 3, 8; security.md |
|
||||
| 86 | **1.17.2 — REST submissions and jobs** — a customer account gets 403 on `POST /api/form-submissions`; a cron gets 401 on `/api/payload-jobs/run` | Submissions: use `submitForm` / `createSubmitAction`, or `formSubmissionOverrides.access.create`. Jobs: `CRON_SECRET` (16+ characters) in the app's env and `Authorization: Bearer …` from the cron, or an admin's API key; `jobsRunAccess: false` = Payload's default | CHANGELOG 1.17.2 points 4–5, `iapl-upgrade` "→ 1.17.2" |
|
||||
| 87 | **1.17.2 — consent version** — saving Cookies with a lower "Consent version" is refused ("cannot go down") | Raise it or leave it; a script with the Local API and `overrideAccess` may lower it; `cookieSettings: { allowLowerPolicyVersion: true }` restores the old freedom | CHANGELOG 1.17.2 point 7, consent.md |
|
||||
|
||||
After updating the package: `pnpm exec iapl-skills` (new skill versions), `pnpm payload generate:importmap`, `rm -rf .next`, restart dev, grep for the new symbol in
|
||||
`node_modules/@intecion/ipal-kit/dist`.
|
||||
|
||||
+2
-1
@@ -101,12 +101,13 @@ Turn off: `iapl({ doctor: false })`. Adapt: `iapl({ doctor: { tokenVar: 'MY_TOKE
|
||||
| | `env-live` | error | (deep) the project's env rules pass in the real environment |
|
||||
| security | `security-headers` | error | `buildSecurityHeaders`; live: HSTS, nosniff, Referrer-Policy, Permissions-Policy, frame protection |
|
||||
| | `powered-by` | error | `withSecurityConfig`; live: no `X-Powered-By` on `/` and the admin |
|
||||
| | `visitor-writes` | warning | (deep) on a site with a visitor login collection (an auth collection that is not staff): every collection whose `create` / `update` / `delete`, or global whose `update`, lets such an account in — Payload's default "any signed-in account" included. Give it its own rule (`adminOrEditor`, …); asked by behaviour, never by a rule's name (1.17.2) |
|
||||
| | `proxy-matcher` | warning | `src/proxy.ts`: a matcher that skips `api`, `admin` or `_next` without ending them at "/" (`(?!api|admin|…)`) also skips every page whose first segment only starts with them (`/administracja`): no locale redirect, no proxy CSP. Fix: the literal in i18n.md (1.17.1) |
|
||||
| | `client-hints` | info | `withSecurityConfig` is the outer wrapper (`withSecurityConfig(withPayload(…))`), so Payload's colour-scheme client hints go to the admin only; live: `/` sends no `Critical-CH: Sec-CH-Prefers-Color-Scheme`. Not reported with `adminClientHints: false` |
|
||||
| | `csp` | warning / info | CSP on the site and the admin; report-only is info, a warning after 4 weeks (`seen`) |
|
||||
| | `2fa` | error | `twoFactor: { plugin: payloadTotp }` + the package; deep: 0 users without TOTP (the message says how many of them are blocked because their setup window has passed); error: a Postgres / SQLite project whose migrations do not mention the 2FA column `totp_setup_from` (every login would answer 500; a warning when there is no migrations folder — the doctor cannot see a schema that gets there another way); warning: `twoFactor.requireSetup: false`; info: no setup window (`windowHours: false`) |
|
||||
| | `access-missing` | warning | `iapl` has an `access` option — without it there are no roles and every panel account is an admin |
|
||||
| | `csrf-empty` | warning | the config sets `serverURL` or `csrf` — otherwise Payload accepts the login cookie from any origin |
|
||||
| | `csrf-empty` | warning | the config sets `serverURL` or `csrf` — otherwise Payload accepts the login cookie from any origin, and behind a proxy that rewrites `Host` the plugin's own-origin checks (2FA, panel actions) refuse the site's own panel. With `--url` (deep) the running config decides (`originKnown` in the status), not the file |
|
||||
| | `open-signup` | info | (deep) auth collections whose `create` rule lets an anonymous request through: sign-up is open there (intended for a customer zone — silence with a reason) |
|
||||
| | `staff-own-roles` | warning | (deep) a staff collection with role values of its own, neither `editor` nor `admin` among them, that runs on the plugin's default account rules: the plugin cannot rank those roles, so inside the collection every account may create an account with any role and change or delete another. Write the collection's own rules |
|
||||
| | `staff-accounts-open` | error (warning for `read`, `readVersions`) | (deep) a staff collection that an account of another, non-staff auth collection may create in, read (also its versions), update, delete from or unlock — it can make itself staff, change a staff password, list the accounts or lift a login lock. The account rules are off (`accounts: false`, `adminOnlyCreate` / `adminOnlyWrite` / `staffOnlyRead: false`) or the project's own rule is wider. Asked with a made-up outside account; a rule that throws counts as closed |
|
||||
|
||||
+2
-1
@@ -113,7 +113,8 @@ finding the names it was written for. Both accept both spellings in the environm
|
||||
|
||||
The plugin also reads (outside the preset — add your own rules if you want to validate them):
|
||||
`INDEXNOW_KEY` (seo.md), `IAPL_NOINDEX` (`1`/`true`/`yes` — staging, seo.md), `IAPL_DOCTOR_TOKEN` (≥ 32 characters —
|
||||
turns `GET /api/ipal/doctor` on, doctor.md). Full table:
|
||||
turns `GET /api/ipal/doctor` on, doctor.md), `CRON_SECRET` (≥ 16 characters — a cron runs Payload's job queue over
|
||||
HTTP with `Authorization: Bearer <CRON_SECRET>`, security.md "Payload's job queue"). Full table:
|
||||
[deployment.md](./deployment.md).
|
||||
|
||||
Extending with your own variables — spread:
|
||||
|
||||
+14
-2
@@ -436,6 +436,18 @@ A missing IP (the proxy strips the header, a wrong `IAPL_IP_HEADER`) does **not*
|
||||
share one `unknown-ip` bucket with a ×20 limit (`UNKNOWN_IP_FACTOR`) — real
|
||||
visitors get through, a flood without the header does not. `setUnknownIpFactor(n)` (root, once at startup)
|
||||
changes the multiplier; `setUnknownIpFactor(0)` = the old behaviour (no limit), when a limiter sits in front.
|
||||
|
||||
**IPv6 is counted per network (1.17.2).** A host with IPv6 holds a whole /64 — 2^64 addresses, every home
|
||||
connection and every server — so counting per address gave one visitor as many budgets as it had addresses. Every
|
||||
limiter of the plugin (forms, the file upload endpoint, search, MCP, the consent log, stats, the doctor status, the
|
||||
mail service's confirm route and account-mail limit) counts a **/64 as one client**; an IPv4-mapped address
|
||||
(`::ffff:1.2.3.4`) counts as its IPv4. One home network shares the budget, as an IPv4 home behind one router always
|
||||
did. Change it once at start (root export): `setIpv6Grouping({ prefix: 128 })` = per address (as before);
|
||||
`setIpv6Grouping({ prefix: 56 })` another network size; `setIpv6Grouping({ wide: 48, wideFactor: 10 })` adds a
|
||||
second counter per /48 at 10× the limit (a hosting customer often holds a /48 — off by default, because a mobile
|
||||
carrier can put many phones in one /48). A value out of range throws. `ipRateKey(ip)` gives the key a limiter of
|
||||
your own should count by (`consumeRateLimit` already applies it to a key that is an IP address).
|
||||
**Check:** fifty requests to a limited route with `X-Real-IP: 2001:db8:1:1::1` … `::32` → `429` after the limit.
|
||||
Without a pinned header the order
|
||||
`cf-connecting-ip` → `x-real-ip` → XFF stays (switching to XFF-only, from the right, would put every visitor
|
||||
behind Cloudflare into the bucket of the edge node) — that is why `IAPL_IP_HEADER` is mandatory in production
|
||||
@@ -547,7 +559,7 @@ then does it store. A flood dies before it touches the network or the database.
|
||||
|
||||
**REST is closed.** By default the form-builder lets anyone create submissions through
|
||||
`POST /api/form-submissions` — skipping all the gates below. IAPL
|
||||
sets `access.create` of the `form-submissions` collection to "logged-in users only"; the front end
|
||||
sets `access.create` of the `form-submissions` collection to "a staff account with its second factor" (since 1.17.2; before: any signed-in account, a customer of a visitor login collection included); the front end
|
||||
submits through `submitForm` (server action → Local API), so this does not affect it.
|
||||
A deliberately public REST (e.g. an external app) →
|
||||
`forms: { formSubmissionOverrides: { access: { create: () => true } } }` — then
|
||||
@@ -861,7 +873,7 @@ filter it out on the client.
|
||||
- **Turn off:** without the `forms` option the plugin does not wire the form-builder (no Forms / Form Submissions collections).
|
||||
Single field types: `forms.fields.<type>: false`. Files: `forms.attachments` is off unless you set it ("Files").
|
||||
- **Override the collections:** `formOverrides` / `formSubmissionOverrides` — fields (the `fields` function), `labels`,
|
||||
`admin`, `access`, `hooks`. The default submissions access (`create`: logged-in users, `read`: editor+, `delete`: admin)
|
||||
`admin`, `access`, `hooks`. The default submissions access (`create`: a staff account with its second factor since 1.17.2, `read`: editor+, `delete`: admin)
|
||||
is overridden by keys in `formSubmissionOverrides.access`; forms access (`create`/`update`/`delete`:
|
||||
editor+, `read`: public) — in `formOverrides.access`. The Emails tab protection (`read`: editor+) is
|
||||
applied to the default fields **before** `formOverrides.fields`, so you change it there.
|
||||
|
||||
@@ -38,6 +38,7 @@ and shared by the helpers (generateMetadata and the page share queries).
|
||||
| `mcp` | — | `{ serverName, serverVersion, rateLimit, maxBatch, clientIp, isPathVisible }` for `mcpGET`/`mcpPOST` (mcp.md) |
|
||||
| `pageJsonLd` | — | default `getPageJsonLd` options: `breadcrumbs`, `entryType`, `entries`, `faq`, `pageType` |
|
||||
| `robots` | — | `RobotsOptions` for `robots` and `getRobots` (seo.md); `aiBotRules: [{ userAgent, access }]` = per-bot exceptions from code (the panel's rules come after them) |
|
||||
| `draftRelations` | `'hide'` | related documents that are drafts are left out of what the helpers answer (1.18.0); `'keep'` as before (content.md "Drafts as related documents") |
|
||||
| `settingsDepth` | `1` | depth of `getSettings`: Site settings relations arrive as documents, theirs as ids (the archive page is read separately at depth 2); `2` = every request pays for more |
|
||||
| `siteJsonLd` | WebSite + Organization from Site settings | a function replaces it, `false` = none |
|
||||
| `sitemapEntries` | — | `(entries) => entries` — final sitemap list: add URLs of your own routes, remove some, set `priority` |
|
||||
|
||||
@@ -37,6 +37,11 @@ The state block above it reads `GET /api/iapl/mail-relay/status` and acts throug
|
||||
or at most every 10 min while an error lasts; it never throws. The same change already being written (many sends
|
||||
failing at once) is written once; while every transaction place of a Postgres pool is taken
|
||||
([deployment.md](./deployment.md) §4.3a) the write goes on in the background instead of holding the caller.
|
||||
- **The status is written alone (1.18.0).** `updateGlobal` reads the whole document, merges and writes it whole: a
|
||||
status written after a visitor's form submit put back an admin's SMTP or Turnstile change saved in the same
|
||||
moment. The status field is now written through the database adapter on its own (`writeGlobalFields(payload,
|
||||
slug, data)`, exported): no read of the rest, no hooks, no new version (fit for bookkeeping fields only). A global
|
||||
that does not exist yet is created the usual way.
|
||||
- **Changing keys in the admin panel** (Turnstile, the sending method / `smtp*`) clears that integration's old status.
|
||||
- **`emailStatus.code`** of a send through the Intecion mail service is one of the `relay-…` codes (`relay-pending`,
|
||||
`relay-quota`, `relay-unreachable`, …), each with a text in the editor's language — the list and what to do:
|
||||
|
||||
@@ -421,6 +421,40 @@ Real panel protection:
|
||||
`/admin → /its` is a layer (it filters out dumb bots), not a lock. Treat it as an
|
||||
addition to real safeguards, not a replacement for them.
|
||||
|
||||
## Panel actions only from the site's own origin (`adminSameOrigin`, 1.17.2)
|
||||
|
||||
The plugin's panel actions act with the panel's login cookie and read their body whatever its `Content-Type`
|
||||
says: `POST /api/iapl/mail-relay/connect` and `/disconnect` (the mail service), `/api/ipal/test-email`,
|
||||
`/api/ipal/cookie-scan`, `/api/ipal/cookie-approval`, `/api/ipal/cookie-crawl`. A `text/plain` POST needs no CORS
|
||||
preflight, a page on a sibling subdomain is "same site" (the browser sends the `SameSite=Lax` cookie), and
|
||||
Payload's own CSRF list is empty unless `serverURL` or `csrf` is set. So before 1.17.2 such a page could make a
|
||||
signed-in administrator disconnect the mail service, send test mails, run scans and crawls, or approve every
|
||||
waiting cookie. Now each of them refuses (`403`, before anything is read) a request a browser marks as coming
|
||||
from elsewhere — the same rule as the 2FA endpoints: the `Origin` header, else `Sec-Fetch-Site`. Own origins: the
|
||||
host the request came in on (`Host`, `X-Forwarded-Host`), `serverURL`, Payload's `csrf` and `cors` lists, and
|
||||
`adminSameOrigin.origins`. A request with neither header (a script, `curl`, a server) passes: it rides on nobody's
|
||||
cookie. The panel's own buttons are on the site's origin and are not affected. A project's own endpoint on one of
|
||||
these paths is left as it is. The 2FA endpoints keep their own switch (`twoFactor.sameOrigin`).
|
||||
|
||||
```ts
|
||||
iapl({
|
||||
// adminSameOrigin: { origins: ['https://panel.example.com'] }, // the panel served from another origin
|
||||
// adminSameOrigin: false, // no check (as before 1.17.2)
|
||||
})
|
||||
```
|
||||
|
||||
- **Behind a proxy that rewrites `Host`** and sends no `X-Forwarded-Host`, without `serverURL`, the site's own
|
||||
panel buttons are refused. It is not silent: the first refusal of each origin is logged
|
||||
(`[iapl] a panel action from origin "…" was refused … pass iapl({ adminSameOrigin: { origins: [...] } })`), and
|
||||
`iapl-doctor` warns when the running config has neither `serverURL` nor `csrf` (`csrf-empty`). Set
|
||||
`serverURL: process.env.NEXT_PUBLIC_SERVER_URL`.
|
||||
- **Any other value** than `true`, `false` or an object with `origins` (a list of strings) stops the start.
|
||||
- **Building blocks:** `requireOwnOrigin(endpoint, origins?)` for an endpoint of your own,
|
||||
`guardAdminEndpoints(config, projectEndpoints, option)`, `ADMIN_POST_ENDPOINTS` (the list), and the 2FA ones:
|
||||
`requestFromOwnOrigin`, `ownOrigins`, `reportRefusedOrigin(req, origins?, { what, option, docs }?)`.
|
||||
- **Check:** `curl -X POST <site>/api/ipal/test-email -H 'Origin: https://other.example' -H 'Content-Type: text/plain'
|
||||
-b <admin cookies> -d '{"to":"a@example.com"}'` → `403`; "Send test e-mail" in the panel still works.
|
||||
|
||||
## 2FA (TOTP) — ENFORCED for every user
|
||||
|
||||
The plugin enforces two-factor authentication (TOTP) for ALL panel users —
|
||||
@@ -1199,6 +1233,51 @@ a root endpoint to the config and the check names it as "not judged".
|
||||
**In the plugin repository:** `pnpm routes:check` (`--update` after a Payload upgrade) on the reference site, also
|
||||
the first step of `pnpm e2e:built`; the test fixtures are switched off for it.
|
||||
|
||||
## Payload's job queue (`jobsRunAccess`, 1.17.2)
|
||||
|
||||
Payload runs its queue over HTTP at `GET /api/payload-jobs/run` and `/api/payload-jobs/handle-schedules`, checked by
|
||||
`jobs.access.run`. Payload's default is **any signed-in account of any auth collection** — a shop's customer could
|
||||
run the queue whenever they like. Since 1.17.2, when the project writes **no** `jobs.access.run`, iapl sets: an
|
||||
**admin signed in with the second factor** (an admin's API key counts), or **`Authorization: Bearer <CRON_SECRET>`**
|
||||
(16+ characters, compared in constant time). It is set even when the config has no `jobs` (Payload turns the queue on
|
||||
by itself for scheduled publishing). A route that does not exist (no tasks, no workflows) stays 404.
|
||||
|
||||
**A project with jobs keeps its cron working** — check which of these it uses:
|
||||
- jobs run **in-process** (`jobs.autoRun`, `pnpm payload jobs:run`, `payload.jobs.run()` in code): nothing changes;
|
||||
- a **Coolify scheduled task** (or any cron) that calls the run route: set `CRON_SECRET` in the app's environment and
|
||||
in the task, and send the header —
|
||||
`curl -fsS -H "Authorization: Bearer $CRON_SECRET" "$NEXT_PUBLIC_SERVER_URL/api/payload-jobs/run"`;
|
||||
- a cron that signs in with an **admin's API key**: works as before; with a **non-admin** account's key: switch to
|
||||
`CRON_SECRET`, or write your own rule;
|
||||
- the project's **own** `jobs.access.run`: always wins, nothing changes.
|
||||
At start, when the queue is on, the rule is iapl's and `CRON_SECRET` is missing or short, the log says so in one
|
||||
line. Overrides: `iapl({ jobsRunAccess: false })` keeps Payload's default; `{ secretVar: 'MY_VAR' }` reads another
|
||||
variable; `jobsRunAccess()` is exported to reuse in a rule of your own. Verify: without the header
|
||||
`/api/payload-jobs/run` answers 401, with it 200 (the closed-doors spec does both on the built reference site).
|
||||
|
||||
## Visitor accounts (customers, members) and Payload's default write rules
|
||||
|
||||
Payload fills every missing access rule with **"any signed-in account"** — an account of a visitor login collection
|
||||
included. The plugin narrows its own collections and globals and the staff accounts; **your** collections and
|
||||
globals are yours to rule. On a site that has (or may get) a visitor login collection, give every collection
|
||||
`create` / `update` / `delete` and every global `update` a rule of its own — the reference site and every new site
|
||||
from `iapl create` do (`adminOrEditor`, since 1.17.2). `iapl-doctor --url` (deep) lists what such an account may
|
||||
write (`visitor-writes`, warning), checked by behaviour: it asks every rule with a stand-in visitor account. Payload's
|
||||
own `payload-locked-documents` (who edits which document) also runs on Payload's default and is listed there; a
|
||||
plugin-wide default for it is planned for 2.0. Verify: the doctor shows no `visitor-writes` finding, and the
|
||||
closed-doors spec's customer gets 403 on every write door.
|
||||
|
||||
## Access callbacks (`cookieScanner.access`, the doctor's `access`)
|
||||
|
||||
A project's callback says who may use the cookie scanner's endpoints or read the doctor's status. Today any truthy
|
||||
answer lets the request in: `({ req }) => req.user` returns an account object and passes, and so does a function
|
||||
that returns `'no'` or `{}`. **From the next minor version (1.19.0) only `true` allows** — like
|
||||
`twoFactor.requireSetup.resetAccess` already does. Since 1.18.0 the first answer that is not a boolean is reported
|
||||
once per option in the server log:
|
||||
`[iapl] cookieScanner.access returned an object, not true or false. It is still read as allowed; …`.
|
||||
Return a boolean: `({ req }) => Boolean(req.user)`, `({ req }) => isAdmin(req.user, req.payload)`. One function reads
|
||||
every answer: `accessAllowed(option, answer)` (exported). The second factor is checked before the callback, as before.
|
||||
|
||||
## Turn off, override, extend
|
||||
|
||||
- **Stored secrets:** `secrets: { writeOnly: false }`, `secrets: { reenterOnChange: false }`; `writeOnlySecret` /
|
||||
|
||||
Reference in New Issue
Block a user