M1 review: docs, agent guide, skills and changelog follow the fixes
Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
1141c749de
commit
fd203de326
@@ -101,13 +101,18 @@ through this procedure. Ask only when you are missing something you cannot get y
|
||||
| old email sender | mail client cache | check the raw headers |
|
||||
| form: `unknown_fields` | field outside the definition (honeypot not removed) | `ipal-form` → actions.ts |
|
||||
| an account logs in to `/admin` and sees "Unauthorized" (its API calls still work) | `accounts.panelRole`: the panel opens for `editor` and above; the account has only `user`, or no role | give it `editor` (an admin edits the account), or `accounts: { panelRole: 'user' }`; nobody can get in: a script with the Local API sets `roles: ['admin']`, or `accounts: { panelRole: false }` + redeploy |
|
||||
| `POST /api/<slug>/first-register` answers `403` on an empty collection | `accounts.firstUserRoute`: only the panel's login collection may register its first account that way | an admin creates the account; or the collection's own `create: () => true` (sign-up); or `accounts: { firstUserRoute: ['<slug>'] }` |
|
||||
| an editor (or a script with its token) gets `403` creating an account in the project's own `users` | `accounts.adminOnlyCreate`: only admins create staff accounts | create as an admin; or write the collection's `create` rule; or `adminOnlyCreate: false` |
|
||||
| `POST /api/<slug>/first-register` answers `403` on an empty collection | `accounts.firstUserRoute`: only the panel's login collection may register its first account that way (the plugin's own endpoint sits in front of Payload's) | an admin creates the account; or the collection's own `create: () => true` (sign-up); or `accounts: { firstUserRoute: ['<slug>'] }` |
|
||||
| an editor (or a script with its token) gets `403` creating an account in the project's own `users` | `accounts.adminOnlyCreate`: only admins create staff accounts where the roles are the plugin's | create as an admin; or write the collection's `create` rule; or `adminOnlyCreate: false` |
|
||||
| an account gets `403` changing or deleting ANOTHER account of a staff collection (it worked before) | `accounts.adminOnlyWrite`: an admin, or the account itself (update only); on a collection with roles of its own: accounts of that collection | do it as an admin; or write the collection's `update` / `delete` rule; or `adminOnlyWrite: false` |
|
||||
| a fresh site with `access.firstUserAdmin: false`: the first account sees "Unauthorized", or the start fails with `leaves a fresh site with nobody who can open the panel` | the first account gets the default role, below the panel role | `access.defaultRole: 'editor'`, or `accounts: { panelRole: false }`, or drop `firstUserAdmin: false` |
|
||||
| saving Site integrations fails on the password field: "Enter the password again…" | the server, port, user name or "Require encryption" changed (or the transport switched to SMTP) and the stored SMTP password is kept only for the settings it was saved with | type the password again; or "Remove the stored value" for a server without one; a seed with the Local API is not asked; `secrets: { reenterOnChange: false }` |
|
||||
| e-mail fails with `Error upgrading connection with STARTTLS` | "Require encryption" is ticked and the server offers no STARTTLS on that port | the right port (587, or 465); or untick it (the password then travels unencrypted) |
|
||||
| SQL site after the upgrade: Site integrations cannot be read, `column "smtp_require_tls" does not exist` | the new checkbox needs a migration | `pnpm payload migrate:create`, commit, deploy (deployment.md §4.3) |
|
||||
| creating an account / changing a password fails with "The password must have at least 12 characters." | `accounts.password` (applies to new passwords of staff accounts, in scripts too) | a longer password; `accounts: { password: { minLength } }` or `false` |
|
||||
| the API returns `"smtpPassword":"********"` / own code "lost" the SMTP password or Turnstile secret | write-only secrets: reads through access control never get the value | read on the server: `payload.findGlobal({ slug: 'site-integrations' })` (access control off); `secrets: { writeOnly: false }` restores the old behaviour |
|
||||
| the SMTP password "disappears" after saving Site integrations | it does not: the field shows "A value is set"; an empty save keeps it | to change it type a new one; to remove it press "Remove the stored value" (API: `'[[clear]]'`) |
|
||||
| a form with a File field answers "verification failed" while text forms work | Turnstile is degraded (wrong / missing secret, Cloudflare down) and forms with files fail closed | fix the keys (Site integrations → Spam protection; dashboard alert; `ipal-doctor --url` → `turnstile-degraded`); or `forms: { turnstileOnConfigError: { files: 'allow' } }` |
|
||||
| `POST /api/verify-totp` (or `setup-totp`) answers `403` "Not allowed from this origin." | the request's `Origin` is not the site's own (a panel or front end on another domain, a proxy that drops `Host` / `X-Forwarded-Host`) | `twoFactor: { …, sameOrigin: { origins: ['https://<that origin>'] } }`, or set `serverURL` / `csrf`; `sameOrigin: false` turns the check off |
|
||||
| `POST /api/verify-totp` (or `setup-totp`) answers `403` "Not allowed from this origin." — **nobody can enter a code** | the request's `Origin` is not one the server knows as its own: a panel or front end on another domain, or a proxy that rewrites `Host` and sends no `X-Forwarded-Host` while `serverURL` is not set. The log names the origin once: `[ipal] 2FA: a code from origin "…" was refused` | set `serverURL` (best); or `twoFactor: { …, sameOrigin: { origins: ['https://<that origin>'] } }`; or make the proxy send `X-Forwarded-Host`; `sameOrigin: false` turns the check off |
|
||||
| log: `[ipal] Deprecated: the Turnstile secret key comes from the TURNSTILE_SECRET_KEY environment variable` | the panel field is empty and the env variable is used | with the owner: copy the key into Site integrations → Spam protection, test a form, remove the variable; it keeps working meanwhile |
|
||||
| an editor no longer sees why an integration fails on the dashboard | dashboard alerts by role: details are for admins | an admin looks; or `dashboardAlerts: { integrations: 'editor' }` |
|
||||
| Turnstile always rejects | the `[ipal] Turnstile …` log says why: no secret, `invalid-input-secret`, `timeout-or-duplicate` | turnstile.md → table; secret in the panel or `TURNSTILE_SECRET_KEY`; **do not** write the secret in code |
|
||||
|
||||
@@ -33,11 +33,13 @@ description: Complete map of everything @intecion/ipal-kit provides — every ip
|
||||
| `access.staffCollections` | `[]` | more auth collections whose accounts are staff, besides the panel's login collection (`admin.user`) and `access.authCollection`; roles count **only** for accounts of a staff collection (every predicate and access function); such accounts are **not** covered by 2FA (one collection only — warning in the log at start); without a `roles` field there, every such account passes every staff check | add `buildRolesField()` to that collection to tell roles apart; a visitor collection (`customers`) is never listed here |
|
||||
| `accounts` | on (all rules) | rules for the accounts of the staff collection; each key below | `false` = none of them |
|
||||
| `accounts.panelRole` | `'editor'` | the lowest role that may open the admin panel (Payload's `access.admin` on the collection with the roles): an account with only `user` sees "Unauthorized"; the API is not touched; the role decides, not the second factor. First start logs `N account(s) … cannot open the admin panel` (an error when it is everyone). Needs `access` | `'user'` / `false` = everyone, as before; `'admin'`; your own `access.admin` / `access.authAccess.admin` wins |
|
||||
| `accounts.adminOnlyCreate` | on | a staff collection (panel login collection, `access.authCollection`, `access.staffCollections`) without a `create` rule gets "an admin, fully signed in" instead of Payload's "any logged-in user" — also the project's own collection | `false` = Payload's default; a `create` rule you wrote always wins |
|
||||
| `accounts.firstUserRoute` | `'panel'` | which auth collections `POST /api/<slug>/first-register` answers for while they are empty: only the one the panel logs in with (the first account of a site → admin). Others get `403`, a second staff collection included; a collection whose own `create` allows an anonymous request keeps its route | a list of slugs; `'all'` = Payload's behaviour |
|
||||
| `accounts.adminOnlyCreate` | on | a staff collection (panel login collection, `access.authCollection`, `access.staffCollections`) without a `create` rule gets one instead of Payload's "any logged-in user" — also the project's own collection. With the plugin's roles (`access.authCollection`, or a `roles` select with only `user` / `editor` / `admin`): an admin, fully signed in. With roles of its own, or none: an account of that same collection, or a plugin admin of another staff collection | `false` = Payload's default; a `create` rule you wrote always wins |
|
||||
| `accounts.adminOnlyWrite` | on | the same for `update` and `delete`: with the plugin's roles — update: an admin or the account itself, delete: an admin; otherwise an account of that same collection, or a plugin admin. Closes Payload's default, under which a visitor account could change a staff account's password. `read` is not touched | `false` = Payload's default; rules you wrote always win |
|
||||
| `accounts.firstUserRoute` | `'panel'` | which auth collections `POST /api/<slug>/first-register` answers for while they are empty: only the one the panel logs in with (the first account of a site → admin). Others get `403`, a second staff collection included, in any spelling of the URL (the plugin's own endpoint sits in front of Payload's); a collection whose own `create` allows an anonymous request keeps its route. With `access.firstUserAdmin: false` and a default role below the panel role, the default `panelRole` is not applied (logged) and an explicit one is refused at start | a list of slugs; `'all'` = Payload's behaviour |
|
||||
| `accounts.password` | `{ minLength: 12 }` | when a password is SET on a staff collection (create, first-user screen, change, reset by e-mail; panel, API and Local API): at least `minLength` characters, not the account's e-mail address. Existing passwords are never checked — a shorter one keeps logging in | `{ minLength }`; `false` = Payload's rule (3 characters) |
|
||||
| `secrets.writeOnly` | on | `smtpPassword` and `turnstileSecretKey` (Site integrations) are never returned: REST, GraphQL and the panel get `'********'` when a value is stored; a save with nothing / empty / the mask keeps it, a new value replaces it, `'[[clear]]'` removes it; the Local API with access control off reads the real value. The panel is the source of these secrets — no env variable | `false` = returned to whoever may read the global, as before |
|
||||
| `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. A session that owes its second factor sees none | `integrations: 'editor' | 'all'`, `cookies: 'all'` (`'all'` = as before) |
|
||||
| `secrets.writeOnly` | on | `smtpPassword` and `turnstileSecretKey` (Site integrations) are never returned: REST, GraphQL and the panel get `'********'` when a value is stored; a save with nothing / empty / the mask keeps it, a new value replaces it, `'[[clear]]'` removes it; the Local API with access control off reads the real value. The panel is the source of these secrets — no env variable. A restore of a version is masked too | `false` = returned to whoever may read the global, as before |
|
||||
| `secrets.reenterOnChange` | on | a save through access control that changes `smtpHost`, `smtpPort`, `smtpUser`, `smtpRequireTls`, or switches `emailTransport` to SMTP, while a password is stored, must send the password again or remove it (`400` on the field otherwise) — so an admin session cannot send the stored password to a server of its own. The Local API with access control off is 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) |
|
||||
| `adminRoute` | `'/admin'` | `config.routes.admin`; stats link and views, `IntegrationAlerts` | the project moves `app/(payload)/<route>/` itself and adds the route to the proxy matcher (security.md) |
|
||||
| `twoFactor` | **none = error** | `@clocklimited/payload-2fa` with `forceSetup: true` (TOTP enforced, also checked in the API) | `twoFactor: false` (discouraged); omitting the option throws `[ipal] twoFactor.issuer is required` |
|
||||
| `twoFactor.issuer` | — (required) | name in the authenticator app | — |
|
||||
@@ -49,7 +51,7 @@ description: Complete map of everything @intecion/ipal-kit provides — every ip
|
||||
| `twoFactor.texts` | ipal-kit's en/pl texts (`TOTP_TEXTS`) over the package's; 2FA screens titled "Two-step verification" / "Weryfikacja dwuetapowa" (site's language) | `false` = the package's texts; one text: `i18n.translations.<lang>.totpPlugin.<key>` (security.md) |
|
||||
| `twoFactor.guard` | on | ipal-kit's own second-factor check on every collection and global (also the plugin's own and those of plugins listed after ipalKit) and in `userMeetsRole`; startup fails with `[ipal] twoFactor: the injected 2FA plugin did not add …` when the 2FA package lacks the `totp` strategy / `hasTotp` / `totpSecret` | per entity: `custom.ipal.secondFactor: false` / `{ read: false }` or the package's `custom.totp.disableAccessWrapper.<op>`; `false` = the package's wrapper only (the plugin's own data then opens to a password without the code; not recommended). The package's endpoints stay limited to accounts of the 2FA collection either way |
|
||||
| `twoFactor.verifyLimit` | `{ max: 5, windowMinutes: 10, store: 'database' }` | attempts per account on `POST /api/verify-totp` (the 2FA package counts none): the sixth in the window, right or wrong, gets `429` + `Retry-After`. Counted in memory and in the database (`payload.kv`, the `payload-kv` collection Payload adds), so a restart or a second instance does not reset it; a failing store never opens the gate | `{ max, windowMinutes }`; `{ store: 'memory' }` = this instance only; `false` = no limit |
|
||||
| `twoFactor.sameOrigin` | on | `POST /api/verify-totp` and `/api/setup-totp` refuse (`403`, not counted) a request a browser marks as coming from another origin (`Origin`, else `Sec-Fetch-Site`). Own origins: the request's host (`Host`, `X-Forwarded-Host`), `serverURL`, Payload's `csrf` / `cors`. Requests without those headers pass | `{ origins: ['https://app.example.com'] }` adds origins; `false` = off |
|
||||
| `twoFactor.sameOrigin` | on | `POST /api/verify-totp` and `/api/setup-totp` refuse (`403`, not counted) a request a browser marks as coming from another origin (`Origin`, else `Sec-Fetch-Site`). Own origins: the request's host (`Host`, `X-Forwarded-Host`, a default port written out is ignored), `serverURL`, Payload's `csrf` / `cors`. Requests without those headers pass. A refusal is logged once per origin with how to allow it — behind a proxy that hides the address set `serverURL` | `{ origins: ['https://app.example.com'] }` adds origins; `false` = off |
|
||||
| `twoFactor.requireSetup` | on, `{ windowHours: 72 }` | an account without TOTP reaches nothing but the setup screen and `/api/setup-totp` (REST, GraphQL and the panel's data answer 403); it has `windowHours` from its creation or from an admin's reset, then it is blocked until an admin reopens setup. Adds the field `totpSetupStatus` (panel) to the 2FA collection, a dashboard notice and `POST /api/ipal/two-factor/reset`; the date field `totpSetupFrom` is there whenever 2FA is on (also with `requireSetup: false` / `guard: false`). Existing accounts get their window at the first start after the upgrade, written once. **Postgres/SQLite: the migration must be applied when the new container starts — `prodMigrations` or `pnpm payload migrate && pnpm start`, not a pre-deployment command (deployment.md §4.3) — or every login answers 500**; `generate:importmap`. `exempt` must return exactly `true` at once (an `async` one, or a `windowHours` that is not a number / `false`, stops the start) | `false` = the package's rule (API open until setup); `{ windowHours: 24 }`, `{ windowHours: false }` (no limit), `{ exempt: ({ user }) => … }` (a service account) |
|
||||
| `twoFactor.requireSetup.dashboardNotice` / `.statusField` / `.setupNotice` | on | the administrators' notice on the dashboard; the status and reset control on the account page; the notice on the setup screen | `false` each (the lock and the reset endpoint stay) |
|
||||
| `twoFactor.resetAccess` (the endpoint exists with `twoFactor.guard` on; `guard: false` = no endpoint, 404) | a staff admin whose session entered its own TOTP code (not an API key, not an `exempt` account) | who may reset another account's TOTP / reopen its setup (the button on the account page, `POST /api/ipal/two-factor/reset`). The reset clears the secret and the account's sessions. A session that still owes its code is always refused | `({ req }) => boolean` — replaces the rule, so keep `req.user?._strategy === 'totp' &&` in it unless API-key / exempt admins should reset; only `true` allows; `req.user._strategy` tells `'totp'`, `'api-key'`, `'local-jwt'` apart |
|
||||
|
||||
@@ -67,10 +67,12 @@ Admin panel components from `@intecion/ipal-kit/admin` — the project does NOT
|
||||
| `isAdmin(user, source?)` | `@intecion/ipal-kit`; in client components `@intecion/ipal-kit/client` | Predicate → `boolean`: staff account with the `admin` role (see `hasMinimumRole`). In hooks and endpoints: `isAdmin(req.user, req.payload)`; in a client component: `isAdmin(user, config)` from `/client` — the main entry does not build there with webpack (`'server-only' cannot be imported…`). |
|
||||
| `isEditor(user, source?)` | `@intecion/ipal-kit`; in client components `@intecion/ipal-kit/client` | Predicate → `boolean`: staff account with `editor` or higher. |
|
||||
| `panelAccess(minimum?)`, `applyPanelRole(config, slug, role)`, `resolvePanelRole(option)`, `countBelowPanelRole(payload, slug, role)`, `DEFAULT_PANEL_ROLE` | `@intecion/ipal-kit` | `accounts.panelRole`: an `access.admin` function ("holds at least `minimum`", default `'editor'`; role only, not the second factor); the applier (skips a collection that has its own `access.admin`); the option → role or `null` when off; `{ all, below }` counts for the start-up line; `'editor'`. |
|
||||
| `staffCreateAccess`, `applyAdminOnlyCreate(config, staffSlugs)`, `buildFirstUserGuard(option?)`, `applyFirstUserRoute(config, option?)`, `openSignUpCollections(payload)` | `@intecion/ipal-kit` | `accounts.adminOnlyCreate` / `firstUserRoute`: the `create` rule "an admin, fully signed in" and its applier (staff auth collections without a `create` rule); the `beforeOperation` hook that refuses `POST /api/<slug>/first-register` unless the collection is the panel's login collection (`'panel'`), is in the list, or its own `create` lets an anonymous request through; the applier (`'all'` adds nothing); the slugs of auth collections with open sign-up (for the doctor). |
|
||||
| `checkPassword(password, { email?, minLength? })`, `buildPasswordRuleHook({ minLength? })`, `applyPasswordRule(config, slugs, rule)`, `resolvePasswordRule(option)`, `DEFAULT_PASSWORD_MIN_LENGTH` | `@intecion/ipal-kit` | `accounts.password`: `'short' \| 'email' \| null` for a new password (length in characters); the `beforeOperation` hook for `create` / `update` / `resetPassword` (throws Payload's `ValidationError` on `password`, text in the panel's language; login is never checked); the applier; the option → `{ minLength }` or `null`; `12`. |
|
||||
| `writeOnlySecret(field)`, `writeOnlySecrets(fields, names)`, `maskSecretAfterRead`, `keepSecretBeforeValidate`, `SECRET_MASK`, `SECRET_CLEAR`, `isSecretMask(value)`, `INTEGRATION_SECRET_FIELDS` | `@intecion/ipal-kit` | Write-only secret fields (`secrets.writeOnly`): the wrapper for one field and for named fields anywhere in a tree (tabs, rows, groups); the two field hooks (reads through access control get `'********'`, the Local API with access control off gets the value; a save with nothing / empty / the mask keeps the stored value, `'[[clear]]'` removes it); the two constants; the plugin's own secret field names (`smtpPassword`, `turnstileSecretKey`). |
|
||||
| `requestFromOwnOrigin(req, extraOrigins?)`, `ownOrigins(req, extraOrigins?)` | `@intecion/ipal-kit` | `twoFactor.sameOrigin`: `false` when a browser marks the request as coming from another origin (`Origin` not among the request's host, `serverURL`, `csrf`, `cors`, the extras; else `Sec-Fetch-Site` not `same-origin` / `none`); `true` without those headers. `ownOrigins` → `{ hosts, origins }`. For your own state-changing endpoint. |
|
||||
| `staffCreateAccess`, `staffUpdateAccess(slug)`, `sameStaffCollectionAccess(slug)`, `hasPluginRoles(collection)`, `applyStaffAccountAccess(config, staffSlugs, { create?, write?, pluginRoles? })` | `@intecion/ipal-kit` | `accounts.adminOnlyCreate` / `adminOnlyWrite`: the access functions — "an admin, fully signed in" (create, delete); "an admin, or the account itself" (update; self = an account of THAT collection); "an account of this staff collection, or a plugin admin of another" (a collection whose roles are not the plugin's); whether a collection carries the plugin's roles (a top-level `roles` select with only `user` / `editor` / `admin`); the applier — puts the rules on the named staff collections for the operations that have none, `pluginRoles` = slugs whose roles field is injected later. Run it before any plugin that wraps access (the 2FA package). |
|
||||
| `buildFirstUserEndpoint(option?)`, `applyFirstUserRoute(config, option?)`, `openSignUpCollections(payload)`, `staffCollectionsOpenToOthers(payload)` | `@intecion/ipal-kit` | `accounts.firstUserRoute`: the plugin's own `POST /first-register` collection endpoint, matched before Payload's — `403` unless the collection is the panel's login collection (`'panel'`), is in the list, or its own `create` lets an anonymous request through; otherwise it calls Payload's handler (and sets `req.context.ipalFirstRegister`); the applier (every auth collection; `'all'` adds nothing; `endpoints: false` is left alone). For the doctor: slugs of auth collections with open sign-up; `'<slug>:<operation>'` for every staff collection an account of a non-staff collection may create in, update or delete from. |
|
||||
| `checkPassword(password, { email?, minLength? })`, `buildPasswordRuleHook({ minLength? })`, `applyPasswordRule(config, slugs, rule)`, `resolvePasswordRule(option)`, `DEFAULT_PASSWORD_MIN_LENGTH` | `@intecion/ipal-kit` | `accounts.password`: `'short' \| 'email' \| null` for a new password (length in characters); the `beforeOperation` hook for `create` / `update` / `resetPassword` (throws Payload's `ValidationError` on `password`, text in the panel's language; the account's address is looked up by id, reset token or bulk query when the request carries none; a password that is not text is refused; login is never checked); the applier; the option → `{ minLength }` or `null`; `12`. |
|
||||
| `writeOnlySecret(field, options?)`, `writeOnlySecrets(fields, names, optionsByName?)`, `maskSecretAfterRead`, `keepSecretBeforeValidate`, `buildKeepSecret(options?)`, `SECRET_MASK`, `SECRET_CLEAR`, `isSecretMask(value)`, `INTEGRATION_SECRET_FIELDS`, `SMTP_PASSWORD_BOUND_TO` | `@intecion/ipal-kit` | Write-only secret fields (`secrets.writeOnly`): the wrapper for one field and for named fields anywhere in a tree (tabs, rows, groups); the two field hooks (reads through access control get `'********'`, the Local API with access control off gets the value; a save with nothing / empty / the mask keeps the stored value, `'[[clear]]'` removes it); the hook builder with options — `{ boundTo: ['siblingField'], appliesWhen?: (siblingData) => boolean }`: a save through access control that changes a bound sibling field without sending the secret throws a `ValidationError` on the secret (`secrets.reenterOnChange`); the two constants; the plugin's own secret field names (`smtpPassword`, `turnstileSecretKey`); the fields the SMTP password is bound to (`emailTransport`, `smtpHost`, `smtpPort`, `smtpUser`, `smtpRequireTls`). |
|
||||
| `maskSecretsOnRestore`, `maskWriteOnlySecrets(data, fields)` | `@intecion/ipal-kit` | Versions and write-only secrets: the `afterRead` hook for a global or a collection (a restore answers with the version document, fields under `version`, where field hooks do not run — it masks them there for reads through access control); the walker it uses (masks every write-only field in `data`, following tabs, rows, groups, arrays and blocks). On Site integrations by default; add the hook to your own entity that has both. |
|
||||
| `requestFromOwnOrigin(req, extraOrigins?)`, `ownOrigins(req, extraOrigins?)`, `reportRefusedOrigin(req, extraOrigins?)` | `@intecion/ipal-kit` | `twoFactor.sameOrigin`: `false` when a browser marks the request as coming from another origin (`Origin` not among the request's host, `serverURL`, `csrf`, `cors`, the extras; a default port written out on the host is ignored; else `Sec-Fetch-Site` not `same-origin` / `none`); `true` without those headers. `ownOrigins` → `{ hosts, origins }`. `reportRefusedOrigin` writes one log line per refused origin and process (at most 50) with the ways to allow it, and returns whether it wrote. For your own state-changing endpoint. |
|
||||
| `buildVerifyLimit(collection, { max?, windowMinutes?, store? })`, `verifyLimitKey(collection, id)`, `clearVerifyLimits()` | `@intecion/ipal-kit` | `twoFactor.verifyLimit`: `async (req) => Response \| null` — counts an attempt of `req.user` in memory and, unless `store: 'memory'`, in `payload.kv`; a `429` with `Retry-After` past `max`. The kv key of an account's count; emptying the in-memory counts (tests). |
|
||||
| `turnstileSecretFromEnv(integrations)`, `TURNSTILE_SECRET_ENV` | `@intecion/ipal-kit` | `true` when the Turnstile secret in use comes from the environment because the panel field is empty (**deprecated** path; the doctor's `turnstile-env-key`); the variable's name, `'TURNSTILE_SECRET_KEY'`. |
|
||||
| `userMeetsRole(req, minimum)` | `@intecion/ipal-kit` | Predicate → `boolean` with `req` (`{ payload, user }`), in this order: the account belongs to a **staff collection** (`admin.user`, `access.authCollection`, `access.staffCollections`); with 2FA on it has passed the second factor (`secondFactorPassed`); it has a role ≥ `minimum`, **or** its collection has no `roles` field (the project omitted `access`). An account of any other auth collection never passes, whatever fields it has. The plugin's staff features (Site integrations, settings globals, form submissions, consent records, stats, cookie scanner, the e-mail test) use it; use it in your own endpoints. |
|
||||
@@ -79,7 +81,7 @@ Admin panel components from `@intecion/ipal-kit/admin` — the project does NOT
|
||||
| `buildRolesField(defaultRole?, { firstUserAdmin? })` | `@intecion/ipal-kit` | The `roles` select field the plugin injects (only admins set roles; `firstUserAdmin` default `true` = the account made on "Create first user" gets `admin`). The plugin wires it itself — use it only for an auth collection the plugin does not manage. |
|
||||
| `injectRoles(config, accessOption)` | `@intecion/ipal-kit` | Adds `roles` to `accessOption.authCollection` in a config. The plugin calls it itself with `access` — do not call. |
|
||||
|
||||
**Types:** `AccountsOptions` (`accounts`: `panelRole`, `adminOnlyCreate`, `firstUserRoute`, `password`), `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`, `firstUserRoute`, `password`), `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`
|
||||
|
||||
|
||||
@@ -249,15 +249,25 @@ the panel shows Site settings, Site integrations, Cookies, Form messages, the Fo
|
||||
blocked"). One entity reachable without the code: `custom.ipal.secondFactor`.
|
||||
- **Account rules** (`accounts`, on by default; `false` or key by key to change): the panel opens for `editor`
|
||||
and above (`panelRole`; an account with only `user` sees "Unauthorized", the API is not touched — give panel
|
||||
users at least `editor`); only an admin creates staff accounts, also in the project's own collection
|
||||
(`adminOnlyCreate`), and Payload's first-user route answers only for the panel's login collection
|
||||
(`firstUserRoute`) — so **create the first account right after the first deploy**, it becomes the admin; a new
|
||||
password has at least 12 characters (`password`). A customer collection with sign-up: write its own
|
||||
`create: () => true`; the rules do not touch it. access.md "Account rules".
|
||||
users at least `editor`); only an admin creates staff accounts, and an account is changed by an admin or by
|
||||
itself — also in the project's own staff collection (`adminOnlyCreate`, `adminOnlyWrite`; a staff collection
|
||||
with role values of its own gets "an account of that collection, or a plugin admin" instead, so write its
|
||||
`create` / `update` / `delete` / `read` rules yourself); Payload's first-user route answers only for the
|
||||
panel's login collection (`firstUserRoute`) — so **create the first account right after the first deploy**, it
|
||||
becomes the admin; a new password has at least 12 characters (`password`). A customer collection with
|
||||
sign-up: write its own `create: () => true`; the rules do not touch it. Do not combine
|
||||
`access.firstUserAdmin: false` with a default role below the panel role (the start refuses or drops the panel
|
||||
role). access.md "Account rules".
|
||||
- **`serverURL`**: set it in the Payload config. Without it, behind a proxy that rewrites `Host` and sends no
|
||||
`X-Forwarded-Host`, the 2FA code page is refused as "another origin" (logged once: `[ipal] 2FA: a code from
|
||||
origin … was refused`). Coolify / Traefik keep `Host`, so it works there either way.
|
||||
- **Stored secrets:** the SMTP password and the Turnstile secret key are entered **in the panel** (Site
|
||||
integrations) and are write-only — the panel and the API show "a value is set". Do not add env variables for
|
||||
them; `TURNSTILE_SECRET_KEY` is deprecated (local test keys in `.env` still work). Read them only on the
|
||||
server with the Local API. `secrets: { writeOnly: false }` turns it off.
|
||||
server with the Local API. `secrets: { writeOnly: false }` turns it off. Changing the SMTP server, port or
|
||||
user name in the panel asks for the password again (`secrets.reenterOnChange`); a seed with the Local API is
|
||||
not asked. Tick **Require encryption** in Site integrations → E-mail sending where the mail server supports
|
||||
STARTTLS (off by default; the field `smtpRequireTls` needs a migration on Postgres / SQLite).
|
||||
- **Forms with files** are refused while Turnstile cannot check (wrong keys, Cloudflare down); text forms are
|
||||
still accepted. `forms: { turnstileOnConfigError: … }` changes either.
|
||||
- A second auth collection (`customers`, a client zone): set `admin: { user: 'users' }` in `buildConfig`; its
|
||||
|
||||
@@ -424,8 +424,11 @@ setup screen with "Set up two-step verification by …"; after the code it is in
|
||||
account → "Two-step verification: Set up." and the reset button; delete the account.
|
||||
|
||||
**→ the release with `accounts` / `secrets` (CHANGELOG "Unreleased — hardening"; PROGRAMISTA §6, item 69) — read every point, most sites change nothing:**
|
||||
1. Update the package, `pnpm install`, `pnpm ipal:skills`, `pnpm payload generate:types`. No import-map change, no
|
||||
schema change, no migration (the verify count uses Payload's own `payload-kv` collection).
|
||||
1. Update the package, `pnpm install`, `pnpm ipal:skills`, `pnpm payload generate:types`. No import-map change.
|
||||
**One new field**: `smtpRequireTls` (a checkbox) in Site integrations — MongoDB needs nothing; **Postgres /
|
||||
SQLite: `pnpm payload migrate:create`, commit, deploy the migration with the code** (deployment.md §4.3), or
|
||||
Site integrations cannot be read (no e-mail, no Turnstile). The verify count uses Payload's own `payload-kv`
|
||||
collection.
|
||||
2. **Panel access by role.** After the first start read the log: `[ipal] N account(s) of "users" are below the
|
||||
role "editor" and cannot open the admin panel`. Those accounts (role `user`, or no role) now see
|
||||
"Unauthorized" in the panel. Give the people who work in the panel `editor`, or set
|
||||
@@ -436,7 +439,13 @@ account → "Two-step verification: Set up." and the reset button; delete the ac
|
||||
stored; the panel shows "a value is set". `grep -rn "smtpPassword\|turnstileSecretKey" src` — code that read
|
||||
them over REST / GraphQL as an admin, or with `overrideAccess: false`, now gets `'********'`: read them on the
|
||||
server with `payload.findGlobal({ slug: 'site-integrations' })`. A script that saves the whole global back
|
||||
keeps the secrets (the mask means "keep").
|
||||
keeps the secrets (the mask means "keep"). **New:** a save in the panel or over the API that changes the SMTP
|
||||
server, port, user name or "Require encryption" must send the password again ("Enter the password again…");
|
||||
a script that does that over REST / GraphQL sends the password with it, a seed with the Local API is not
|
||||
asked. `secrets: { reenterOnChange: false }` turns it off. With the owner, consider ticking **Require
|
||||
encryption** (Site integrations → E-mail sending) where the server supports STARTTLS, then send a test
|
||||
e-mail. During a rolling update a page opened under the new version and saved against the OLD one stores
|
||||
`********` as the password: after the deploy, check that a test e-mail goes out.
|
||||
4. **`TURNSTILE_SECRET_KEY` is deprecated** (it still works). If the log says `[ipal] Deprecated: the Turnstile
|
||||
secret key comes from the TURNSTILE_SECRET_KEY environment variable` or `ipal-doctor --url` reports
|
||||
`turnstile-env-key`: with the owner, copy the key into Site integrations → Spam protection → Secret key, send a
|
||||
@@ -445,20 +454,35 @@ account → "Two-step verification: Set up." and the reset button; delete the ac
|
||||
5. **Forms with files and Turnstile.** While Turnstile cannot check (wrong keys, Cloudflare down), a form with a
|
||||
File field is now refused (text forms are accepted as before). Check `ipal-doctor --url` → no
|
||||
`turnstile-degraded`; to keep the old behaviour: `forms: { turnstileOnConfigError: { files: 'allow' } }`.
|
||||
6. **Account creation.** A project whose **own** staff collection has no `create` rule: only admins create
|
||||
accounts now (before: any signed-in account). `first-register` on any auth collection other than the panel's
|
||||
login collection answers `403` unless that collection allows sign-up. Wanted otherwise: write the `create`
|
||||
rule, or `accounts: { adminOnlyCreate: false, firstUserRoute: 'all' }`.
|
||||
6. **Account creation and changes.** A project whose **own** staff collection has no `create` / `update` /
|
||||
`delete` rule gets one (before: any signed-in account of any auth collection — a customer could change a
|
||||
staff password):
|
||||
- the collection carries the plugin's roles (`access.authCollection`, or a `roles` select with only `user` /
|
||||
`editor` / `admin`): create and delete — an admin; update — an admin or the account itself. **Check:** does
|
||||
a non-admin create or edit other accounts there today? Then write the rule you want;
|
||||
- the collection has **role values of its own** (`superadmin`, …) or no roles: accounts of that collection
|
||||
keep working as before; accounts of other collections are refused. Nothing to do, but write your own rules
|
||||
— the plugin does not know your roles.
|
||||
`first-register` on any auth collection other than the panel's login collection answers `403` unless that
|
||||
collection allows sign-up. `access.firstUserAdmin: false` with a default role below `editor`: the panel role
|
||||
is not applied (a warning at start), or — with `accounts.panelRole` set — the start fails with the fix in the
|
||||
message. Wanted otherwise: `accounts: { adminOnlyCreate: false, adminOnlyWrite: false, firstUserRoute: 'all' }`.
|
||||
7. **Passwords.** New passwords of staff accounts need 12 characters; **existing shorter passwords keep
|
||||
working** — nobody is logged out or asked to change. A script that creates staff accounts with a short
|
||||
password fails with a validation error: lengthen it, or `accounts: { password: { minLength: 8 } }`.
|
||||
8. **2FA attempts from another origin** get `403`. A panel or front end on **another domain** than the API that
|
||||
posts to `/api/verify-totp`: add it — `twoFactor: { …, sameOrigin: { origins: ['https://panel.example.com'] } }`
|
||||
(or set Payload's `csrf` / `cors`). Same-domain sites change nothing.
|
||||
(or set Payload's `csrf` / `cors`). A same-domain site changes nothing **when the server knows its own
|
||||
address**: `serverURL` is set, or the proxy passes `Host` (Coolify / Traefik do) or `X-Forwarded-Host`.
|
||||
**Check before the deploy:** is `serverURL` set? If not and the proxy rewrites `Host` (nginx's plain
|
||||
`proxy_pass`), nobody can enter a 2FA code after the upgrade — set `serverURL`. After the deploy log in with
|
||||
a code; if it answers "Not allowed from this origin.", the log has `[ipal] 2FA: a code from origin "…" was
|
||||
refused` with the fix.
|
||||
9. **Dashboard alerts.** Editors now see "An integration needs attention. Ask an administrator." instead of the
|
||||
error text; accounts with only `user` see no alerts. `dashboardAlerts: { integrations: 'all' }` restores it.
|
||||
error text; accounts with only `user` see no alerts. `dashboardAlerts: { integrations: 'all' }` restores it
|
||||
(`'all'` checks no role and no second factor).
|
||||
**Check:** `pnpm exec ipal-doctor --url <site>` (new rules: `access-missing`, `csrf-empty`, `open-signup`,
|
||||
`turnstile-degraded`, `turnstile-env-key`); as an admin `GET /api/globals/site-integrations` shows
|
||||
`staff-accounts-open`, `turnstile-degraded`, `turnstile-env-key`); as an admin `GET /api/globals/site-integrations` shows
|
||||
`"smtpPassword":"********"`; a test e-mail and a test form still work; an editor and an admin still log in.
|
||||
|
||||
## 2. Inventory (no code changes)
|
||||
|
||||
Reference in New Issue
Block a user