diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 5d8b4ce..76cbc28 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -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 `** (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: ``; the placement before: ``. +> 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 ` (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: ``; an amount of + your own: `--ipal-cookie-button-space` on the footer (`0` = none, also per breakpoint); the placement before: + `` (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 diff --git a/docs/access.md b/docs/access.md index dcfa4a2..e4943c2 100644 --- a/docs/access.md +++ b/docs/access.md @@ -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//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`, 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), diff --git a/docs/agent/AGENT.md b/docs/agent/AGENT.md index a8a2a9d..460c449 100644 --- a/docs/agent/AGENT.md +++ b/docs/agent/AGENT.md @@ -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('')`, 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 ` (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//?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//?draft=true` → 404 and `GET /api//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 | `}>`, `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 \| 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 | `` — 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 /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 /api/ipal/test-email -H 'Origin: https://other.example' -H 'Content-Type: text/plain' -b -d '{}'` → `403` | `adminSameOrigin: false` | `adminSameOrigin: { origins: [...] }`; `requireOwnOrigin(endpoint, origins?)` for your own endpoints | | 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 /api/ipal/two-factor/reset -H 'Origin: https://other.example' -H 'Content-Type: text/plain' -b -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 /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/ {"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::` → `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 `` props (`SiteProviders analytics={false}`) | | Locale cookie: consent read under its own stored version | — | `createProxy(config, { policyVersion })` / `createLocaleMiddleware({ policyVersion })` | diff --git a/docs/agent/reference-site/INDEX.md b/docs/agent/reference-site/INDEX.md index a3207f4..aab9ce0 100644 --- a/docs/agent/reference-site/INDEX.md +++ b/docs/agent/reference-site/INDEX.md @@ -2,7 +2,7 @@ -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) | diff --git a/docs/agent/skills/iapl-audit/SKILL.md b/docs/agent/skills/iapl-audit/SKILL.md index 00bd783..67aaf0d 100644 --- a/docs/agent/skills/iapl-audit/SKILL.md +++ b/docs/agent/skills/iapl-audit/SKILL.md @@ -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/?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//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"` diff --git a/docs/agent/skills/iapl-audit/resources/closed-doors.spec.template.ts b/docs/agent/skills/iapl-audit/resources/closed-doors.spec.template.ts index 816abbf..f2e8d4c 100644 --- a/docs/agent/skills/iapl-audit/resources/closed-doors.spec.template.ts +++ b/docs/agent/skills/iapl-audit/resources/closed-doors.spec.template.ts @@ -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: 'door@example.com', password: 'Door-Password-1234', roles: ['admin'] }, closedFor: ALL, method: 'POST', name: 'nobody creates a staff account', path: '/api/users', closed: status(403) }, { body: { email: 'first@example.com', 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 ` — 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) }, ] diff --git a/docs/agent/skills/iapl-collection/SKILL.md b/docs/agent/skills/iapl-collection/SKILL.md index 98a5b87..2dc1712 100644 --- a/docs/agent/skills/iapl-collection/SKILL.md +++ b/docs/agent/skills/iapl-collection/SKILL.md @@ -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 (`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 /api//?draft=true` without a session → `404`; the same with an editor's token → the draft. + `curl -i /api//?draft=true` without a session → `404`; the same with an editor's token → the draft; + `curl -s -o /dev/null -w '%{http_code}' /api//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 diff --git a/docs/agent/skills/iapl-consent-check/SKILL.md b/docs/agent/skills/iapl-consent-check/SKILL.md index ee351d6..71dcc81 100644 --- a/docs/agent/skills/iapl-consent-check/SKILL.md +++ b/docs/agent/skills/iapl-consent-check/SKILL.md @@ -55,6 +55,14 @@ before analytics or marketing consent — check the project's choice in "Project `nonce` to ``. 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. diff --git a/docs/agent/skills/iapl-debug/SKILL.md b/docs/agent/skills/iapl-debug/SKILL.md index ca59cba..08ef901 100644 --- a/docs/agent/skills/iapl-debug/SKILL.md +++ b/docs/agent/skills/iapl-debug/SKILL.md @@ -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` | diff --git a/docs/agent/skills/iapl-doctor/SKILL.md b/docs/agent/skills/iapl-doctor/SKILL.md index 7a1fb57..f0d4c87 100644 --- a/docs/agent/skills/iapl-doctor/SKILL.md +++ b/docs/agent/skills/iapl-doctor/SKILL.md @@ -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 `; 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 diff --git a/docs/agent/skills/iapl-nav/SKILL.md b/docs/agent/skills/iapl-nav/SKILL.md index 8632608..70a4619 100644 --- a/docs/agent/skills/iapl-nav/SKILL.md +++ b/docs/agent/skills/iapl-nav/SKILL.md @@ -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. diff --git a/docs/agent/skills/iapl-reference/SKILL.md b/docs/agent/skills/iapl-reference/SKILL.md index 88fc780..33a4b5b 100644 --- a/docs/agent/skills/iapl-reference/SKILL.md +++ b/docs/agent/skills/iapl-reference/SKILL.md @@ -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//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)//` 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") | `: 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 === 'dpo@acme.pl' } }` — 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 ` (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 `` 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_`; 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 ` 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 | diff --git a/docs/agent/skills/iapl-reference/resources/api.md b/docs/agent/skills/iapl-reference/resources/api.md index 90cf595..76842dd 100644 --- a/docs/agent/skills/iapl-reference/resources/api.md +++ b/docs/agent/skills/iapl-reference/resources/api.md @@ -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 (``); 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 ` 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). | diff --git a/docs/agent/skills/iapl-upgrade/SKILL.md b/docs/agent/skills/iapl-upgrade/SKILL.md index b3fd674..5dbb7a0 100644 --- a/docs/agent/skills/iapl-upgrade/SKILL.md +++ b/docs/agent/skills/iapl-upgrade/SKILL.md @@ -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 /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 /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 ` 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={}` 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://`), 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. diff --git a/docs/consent.md b/docs/consent.md index 1734208..4f4f4e6 100644 --- a/docs/consent.md +++ b/docs/consent.md @@ -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 `` (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 → `` | + +| 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 `