M1 review round 3: a built-site e2e for a late staff collection (both bundlers); docs follow
Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
6e0ad26b2c
commit
8a01c72c2a
+15
-7
@@ -16,10 +16,11 @@ once there are more than 20.
|
||||
> with a password under 12 characters fails; behind a proxy that hides the site's address and without
|
||||
> `serverURL` nobody can enter a 2FA code; a project's own staff collection without access rules gets rules;
|
||||
> changing the SMTP server in the panel asks for the password again; a slug in `access.staffCollections` that
|
||||
> is not an auth collection stops the start. No import-map change, **no schema change and no migration** on any
|
||||
> is not an auth collection keeps Payload from starting (the old container keeps serving). No import-map change, **no schema change and no migration** on any
|
||||
> database.
|
||||
|
||||
### Security
|
||||
- **A secret that is not text is refused** (`false`, `0`, a list, an object used to be stored as typed).
|
||||
- **Stored secrets are write-only.** `smtpPassword` and `turnstileSecretKey` (Site integrations) were returned
|
||||
by REST and GraphQL, and sent to the browser by the panel, for everyone who could read that global; the
|
||||
"masked" field only drew dots. Now every read through access control gets `'********'` when a value is stored;
|
||||
@@ -45,8 +46,10 @@ once there are more than 20.
|
||||
itself); with role values of its own, or none — an account of that same collection, or a plugin admin.
|
||||
`unlock` gets the admin rule and `read` "a staff account" (a visitor account could list the staff accounts
|
||||
and lift their login lock). An account never changes its **own** roles: the collection's `roles` field, when
|
||||
it has no field access of its own, is closed for that. The rules hold with 2FA on and off, and for a staff
|
||||
collection that a plugin listed after ipalKit adds. Anonymous sign-up into the staff collection was already refused; the
|
||||
it has no field access of its own, is closed for that. `readVersions` gets the `read` rule (versions hold
|
||||
what the accounts hold). The rules hold with 2FA on and off, in a production build, and for a staff
|
||||
collection that a plugin listed after ipalKit adds — there they are put in front of whatever rules that
|
||||
collection has (in a sanitized config Payload's default cannot be told from a rule somebody wrote). Anonymous sign-up into the staff collection was already refused; the
|
||||
plugin's injected collection already had these rules. No known site has a second staff collection
|
||||
([access.md](./access.md) "Account rules").
|
||||
- **2FA verify and setup attempts only from the site's own origin.** A page on another origin that the browser
|
||||
@@ -85,7 +88,7 @@ once there are more than 20.
|
||||
`keepSecretBeforeValidate`, `buildKeepSecret`, `isSecretMask`, `INTEGRATION_SECRET_FIELDS`,
|
||||
`SMTP_PASSWORD_BOUND_TO`, `maskSecretsOnRestore`, `maskWriteOnlySecrets`; `panelAccess`, `applyPanelRole`,
|
||||
`resolvePanelRole`, `countBelowPanelRole`, `DEFAULT_PANEL_ROLE`; `staffCreateAccess`, `staffUpdateAccess`,
|
||||
`staffReadAccess`, `sameStaffCollectionAccess`, `rolesByAdminOnly`, `rolesNotOwn`, `hasPluginRoles`,
|
||||
`staffReadAccess`, `sameStaffCollectionAccess`, `rolesByAdminOnly`, `rolesNotOwn`, `bothAllow`, `hasPluginRoles`,
|
||||
`applyStaffAccountAccess`, `adoptLateAuthCollections`, `unknownStaffCollections`, `buildFirstUserEndpoint`,
|
||||
`applyFirstUserRoute`, `openSignUpCollections`, `staffCollectionsOpenToOthers`, `staffCollectionsOnOwnRoles`; `checkPassword`,
|
||||
`buildPasswordRuleHook`, `applyPasswordRule`, `resolvePasswordRule`, `DEFAULT_PASSWORD_MIN_LENGTH`;
|
||||
@@ -100,9 +103,14 @@ once there are more than 20.
|
||||
that has `payload.kv` already contains; where it cannot be reached the count stays in memory and the limit
|
||||
still holds.
|
||||
- **A slug in `access.staffCollections` (or `access.authCollection`) that is not an auth collection of the
|
||||
config stops the start**: `[ipal] access names "…" as a staff collection, but this config has no auth
|
||||
collection with that slug`. Fix the slug. (A plugin listed after ipalKit may add the collection; it gets the
|
||||
account rules when the site starts.)
|
||||
config: Payload does not start.** The log says `[ipal] access names "…" as a staff collection, but this config
|
||||
has no auth collection with that slug` and lists the auth collections. The process stays up, but every Payload
|
||||
call fails: `/api/health` answers 503, `/api/*` and the panel 500 (a page that needs no Payload call may still
|
||||
answer). With a health check ([deployment.md](./deployment.md) §4.4) Coolify keeps the old container. Check
|
||||
the slugs before the deploy. (A plugin listed after ipalKit may add the collection.)
|
||||
- **A staff collection added by a plugin listed after ipalKit**: the plugin's rules are put in front of the
|
||||
rules that collection has, so both must allow — a rule of its own there can only narrow, not widen. To keep
|
||||
its rules exactly as they are: `custom: { ipal: { accountRules: false } }` on that collection.
|
||||
- **Set `serverURL`** if it is not set. Behind a reverse proxy that rewrites `Host` and sends no
|
||||
`X-Forwarded-Host` (nginx's plain `proxy_pass`; Coolify / Traefik keep `Host`) the server does not know its
|
||||
own address, and the 2FA code page is refused as "another origin": **nobody can enter a code**. The log says
|
||||
|
||||
+18
-7
@@ -288,7 +288,7 @@ list the staff accounts, and lift the lock after failed logins.
|
||||
**Which rule a staff collection gets** (the panel's login collection, `access.authCollection`,
|
||||
`access.staffCollections`) — only for an operation it has **no** rule for; a rule you wrote always stays:
|
||||
|
||||
| The collection | `create`, `delete`, `unlock` | `update` | the `roles` field (when it has no `access.update`) | `read` |
|
||||
| The collection | `create`, `delete`, `unlock` | `update` | the `roles` field (when it has no `access.update`) | `read`, `readVersions` |
|
||||
|---|---|---|---|---|
|
||||
| carries **the plugin's roles**: it is `access.authCollection`, or has a `roles` select whose values are all `user` / `editor` / `admin` (`hasPluginRoles`) | an admin (`staffCreateAccess`) | an admin, or the account itself (`staffUpdateAccess(slug)`) | only an admin changes it (`rolesByAdminOnly`) | a staff account (`staffReadAccess`) |
|
||||
| has **roles of its own** (`superadmin`, `writer`, …) or no `roles` field — the plugin cannot tell who its admins are | an account of that same collection, or a plugin admin of another staff collection (`sameStaffCollectionAccess(slug)`) | the same | an account never changes its **own** (`rolesNotOwn(slug)`) | a staff account |
|
||||
@@ -308,11 +308,22 @@ it may also manage the accounts of the other staff collections. Give it the plug
|
||||
(`buildRolesField`), or write its rules.
|
||||
|
||||
**A staff collection that a plugin listed after ipalKit adds** gets the same rules, the password rule and the
|
||||
first-user endpoint when the site starts (and on a dev reload); the log says `[ipal] Account rules also put on
|
||||
auth collections added after ipalKit: …`. There the plugin tells "no rule" from "your rule" by Payload's own
|
||||
default function, so a rule you wrote stays. A slug in `access.staffCollections` or `access.authCollection`
|
||||
that is **not an auth collection of the config stops the start** with the slug and the list of auth
|
||||
collections (`unknownStaffCollections`).
|
||||
first-user endpoint when the config goes live — at start and on every dev reload. The log says exactly what was
|
||||
put: `[ipal] "late-staff" was added after ipalKit: put on it — access rules for create, update, delete, unlock,
|
||||
read, readVersions, roles; the password rule; the first-user endpoint.` One difference from a collection of your
|
||||
own config: by then Payload has sanitized the collection and filled every missing rule with its default, and
|
||||
that default cannot be told from a rule somebody wrote (a production build renames every function). So the
|
||||
plugin does not guess: **its rule is put in front of whatever rule is there, and both must allow**
|
||||
(`bothAllow`). With Payload's default behind it the result is the plugin's rule; a rule of the collection's own
|
||||
is kept and can only narrow it. To keep a late collection's rules exactly as they are — an open `create`, a
|
||||
wider `read` — say so on the collection: `custom: { ipal: { accountRules: false } }` (the password rule and the
|
||||
first-user endpoint still apply), or list that plugin before ipalKit.
|
||||
|
||||
**A slug in `access.staffCollections` or `access.authCollection` that is not an auth collection of the config:**
|
||||
Payload does not start. The log names the slug and the auth collections it knows. The process stays up, but
|
||||
every Payload call fails — `/api/health` answers 503, `/api/*` and the panel 500; a page that needs no Payload
|
||||
call may still answer. With a health check ([deployment.md](./deployment.md) §4.4) Coolify keeps the old
|
||||
container serving, so a wrong slug never goes live (`unknownStaffCollections`).
|
||||
|
||||
- `adminOnlyCreate: false` = Payload's default `create`; `adminOnlyWrite: false` = Payload's default `update`,
|
||||
`delete` and `unlock`, and the `roles` field is left alone; `staffOnlyRead: false` = Payload's default `read`.
|
||||
@@ -341,7 +352,7 @@ collections (`unknownStaffCollections`).
|
||||
(error) names a staff collection an account of another collection may create in, read (a warning), update, delete from or unlock
|
||||
(the rules are off, or your own rule is wider).
|
||||
- Building blocks: `staffCreateAccess`, `staffUpdateAccess`, `staffReadAccess`, `sameStaffCollectionAccess`,
|
||||
`rolesByAdminOnly`, `rolesNotOwn`, `hasPluginRoles`, `applyStaffAccountAccess`, `adoptLateAuthCollections`,
|
||||
`rolesByAdminOnly`, `rolesNotOwn`, `bothAllow`, `hasPluginRoles`, `applyStaffAccountAccess`, `adoptLateAuthCollections`,
|
||||
`unknownStaffCollections`, `buildFirstUserEndpoint`, `applyFirstUserRoute`, `openSignUpCollections`,
|
||||
`staffCollectionsOpenToOthers`, `staffCollectionsOnOwnRoles`.
|
||||
- **Check:** `curl -X POST <site>/api/members/first-register -H 'content-type: application/json' -d
|
||||
|
||||
+1
-1
@@ -1172,7 +1172,7 @@ add missing hosts with flags / `extra`; (3) change `mode` to `'enforce'` in both
|
||||
| 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. **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` rule gets one: with the plugin's roles — create, delete, unlock: an admin; update: an admin or the account itself; the `roles` field: only an admin. With roles of its own, 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** (`ipal-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. A slug in `access.staffCollections` that is not an auth collection stops the start | `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` |
|
||||
| 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 — create, delete, unlock: an admin; update: an admin or the account itself; the `roles` field: only an admin. With roles of its own, 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** (`ipal-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 password set on a staff account has at least 12 characters and is not the e-mail address; existing passwords are not checked | `accounts: { password: false }` | `password: { minLength }`; `checkPassword`, `buildPasswordRuleHook` |
|
||||
| While Turnstile cannot check (wrong secret, Cloudflare down): a text form is accepted, a form with files is refused | `forms: { turnstileOnConfigError: 'allow' }` | `'reject'`, `{ text, files }`; `turnstileOnConfigError` at a call site wins |
|
||||
| Dashboard alerts by role: integration details for admins, a neutral line for editors, nothing for others; cookie alerts for editors and above. `'all'` checks nothing — no role, no second factor | `dashboardAlerts: { integrations: 'all', cookies: 'all' }` | `integrations: 'editor'`; the components' `details` / `audience` props |
|
||||
|
||||
@@ -1160,12 +1160,42 @@ Rules: AGENT.md §8a.
|
||||
| File | What it shows |
|
||||
|---|---|
|
||||
| `e2e/create-test-admin.ts` | two test admins with a known TOTP secret (the specs share out the five 2FA verify attempts per account), their stored verify counts cleared, and e-mail sending pointed at the tests' mail sink (local / CI database only) |
|
||||
| `e2e/late-staff-fixture.ts` | test fixture, on only with E2E_LATE_STAFF=1: a plugin listed after ipalKit that adds a staff collection without rules and a visitor collection with open sign-up (below) |
|
||||
| `e2e/late-staff.spec.ts` | the account rules on a BUILT site for a staff collection a later plugin adds (run after a webpack and a Turbopack build): a visitor account gets nothing, nobody raises its own role |
|
||||
| `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) |
|
||||
| `e2e/totp.ts` | RFC 6238 code generator for the 2FA sign-in in the smoke test, and the address of the second test admin (below) |
|
||||
| `e2e/two-factor-back.spec.ts` | browser test of the 2FA screens' `back` link (twoFactor.safeBack): a prepared link — script or another host — ends on the admin root, an ordinary one is followed |
|
||||
| `e2e/two-factor-setup.spec.ts` | browser check of "2FA setup required": the first admin of a fresh site, a new editor, the administrator's reset on the account page |
|
||||
|
||||
### `e2e/late-staff-fixture.ts`
|
||||
|
||||
```ts
|
||||
import type { Config, Plugin } from 'payload'
|
||||
|
||||
/**
|
||||
* Test fixture, on only with E2E_LATE_STAFF=1 (e2e/late-staff.spec.ts): a plugin listed AFTER ipalKit that adds
|
||||
* a staff collection (`late-staff`, named in `access.staffCollections`) and a visitor collection with open
|
||||
* sign-up. ipalKit has already run when these collections appear, so it must give them its account rules when
|
||||
* the config goes live — and it must do so in a BUILT site too, where bundlers rename every function.
|
||||
* Never part of a real site: the starter drops `e2e/` and the lines that use this file.
|
||||
*/
|
||||
export const E2E_LATE_STAFF = process.env.E2E_LATE_STAFF === '1'
|
||||
|
||||
export const e2eLateStaff: Plugin = (config: Config) =>
|
||||
E2E_LATE_STAFF
|
||||
? {
|
||||
...config,
|
||||
collections: [
|
||||
...(config.collections ?? []),
|
||||
// no access rules at all: Payload's defaults ("any logged-in user") are what ipalKit must replace
|
||||
{ slug: 'late-staff', auth: true, fields: [{ name: 'roles', type: 'select', hasMany: true, options: ['user', 'editor', 'admin'], saveToJWT: true }], versions: true },
|
||||
{ slug: 'e2e-visitors', access: { create: () => true }, auth: true, fields: [] },
|
||||
],
|
||||
}
|
||||
: config
|
||||
```
|
||||
|
||||
### `e2e/totp.ts`
|
||||
|
||||
```ts
|
||||
|
||||
@@ -106,7 +106,8 @@ through this procedure. Ask only when you are missing something you cannot get y
|
||||
| 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` |
|
||||
| an account saves its own profile and its `roles` do not change (no error) | `accounts.adminOnlyWrite`: nobody changes its own roles; with the plugin's roles only an admin changes roles | an admin changes the role; or give the `roles` field its own `access.update` |
|
||||
| a logged-in visitor (customer) gets `403` reading a staff collection — an author box went empty | `accounts.staffOnlyRead`: only staff accounts read a staff collection without a `read` rule | write that collection's `read` rule; or `staffOnlyRead: false` |
|
||||
| the site does not start: `[ipal] access names "…" as a staff collection, but this config has no auth collection with that slug` | a slug in `access.staffCollections` / `access.authCollection` is not an auth collection (a typo, a removed collection) | fix the slug or add the collection |
|
||||
| `/api/health` answers 503, the panel and `/api/*` 500 after a deploy; log: `[ipal] access names "…" as a staff collection, but this config has no auth collection with that slug` | a slug in `access.staffCollections` / `access.authCollection` is not an auth collection (a typo, a removed collection): Payload does not start, the process stays up (with a health check Coolify keeps the old container) | fix the slug or add the collection |
|
||||
| a collection added by a plugin listed after ipalKit refuses what its own access rule allows | it is in `access.staffCollections`: the plugin's account rules are put in front of its rules and both must allow (the log at start lists what was put) | `custom: { ipal: { accountRules: false } }` on that collection, or list that plugin before ipalKit |
|
||||
| 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 or user name changed and the stored SMTP password is kept only for the settings it was saved with — also when the transport says Microsoft Graph | 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 }` |
|
||||
| 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` |
|
||||
|
||||
@@ -35,7 +35,7 @@ description: Complete map of everything @intecion/ipal-kit provides — every ip
|
||||
| `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 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`, `delete` and `unlock`: with the plugin's roles — update: an admin or the account itself; delete, unlock: an admin; otherwise an account of that same collection, or a plugin admin. With it the collection's `roles` field (when it has no `access.update`) is closed for self-promotion: with the plugin's roles only an admin changes roles; with role values of the project's own an account never changes its own (the plugin cannot rank them — write that collection's rules). Closes Payload's default, under which a visitor account could change a staff account's password | `false` = Payload's default, the `roles` field left alone; rules you wrote always win |
|
||||
| `accounts.staffOnlyRead` | on | `read` on a staff collection without a `read` rule: 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.staffOnlyRead` | on | `read` and `readVersions` on a staff collection without those rules: a fully signed-in account of a staff collection (Payload's default let a visitor account list the staff accounts) | `false` = Payload's default; a `read` rule you wrote wins |
|
||||
| `accounts.firstUserRoute` | `'panel'` | which auth collections `POST /api/<slug>/first-register` answers for while they are empty: only the one the panel logs in with (the first account of a site → admin). Others get `403`, a second staff collection included, in any spelling of the URL (the plugin's own endpoint sits in front of Payload's); a collection whose own `create` allows an anonymous request keeps its route. With `access.firstUserAdmin: false` and a default role below the panel role, the default `panelRole` is not applied (logged) and an explicit one is refused at start | a list of slugs; `'all'` = Payload's behaviour |
|
||||
| `accounts.password` | `{ minLength: 12 }` | when a password is SET on a staff collection (create, first-user screen, change, reset by e-mail; panel, API and Local API): at least `minLength` characters, not the account's e-mail address. Existing passwords are never checked — a shorter one keeps logging in | `{ minLength }`; `false` = Payload's rule (3 characters) |
|
||||
| `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 |
|
||||
|
||||
@@ -68,7 +68,7 @@ Admin panel components from `@intecion/ipal-kit/admin` — the project does NOT
|
||||
| `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`, `staffUpdateAccess(slug)`, `staffReadAccess`, `sameStaffCollectionAccess(slug)`, `rolesByAdminOnly`, `rolesNotOwn(slug)`, `hasPluginRoles(collection)`, `applyStaffAccountAccess(config, staffSlugs, { create?, write?, read?, pluginRoles? })` | `@intecion/ipal-kit` | `accounts.adminOnlyCreate` / `adminOnlyWrite` / `staffOnlyRead`: the access functions — "an admin, fully signed in" (create, delete, unlock); "an admin, or the account itself" (update; self = an account of THAT collection); "a fully signed-in account of a staff collection" (read); "an account of this staff collection, or a plugin admin of another" (a collection whose roles are not the plugin's); the two field-access functions for a `roles` field (`update`: only an admin / never the account itself); whether a collection carries the plugin's roles (a `roles` select at the top level of the data with only `user` / `editor` / `admin`); the applier — puts the rules on the named staff collections for the operations that have none and closes the `roles` field where the plugin's `update` rule is in force, `pluginRoles` = slugs whose roles field is injected later. Run it before any plugin that wraps access (the 2FA package). |
|
||||
| `buildFirstUserEndpoint(option?)`, `applyFirstUserRoute(config, option?)`, `adoptLateAuthCollections(payload, staffSlugs, { access?, beforeOperation?, firstUserRoute? })`, `unknownStaffCollections(payload, staffSlugs)`, `openSignUpCollections(payload)`, `staffCollectionsOpenToOthers(payload)`, `staffCollectionsOnOwnRoles(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, read, update, delete from or unlock; slugs of staff collections with role values of their own on the default rules. `adoptLateAuthCollections` gives auth collections that a plugin listed after ipalKit added the same rules on the live config (called by the plugin at start and on a dev reload; returns the slugs); `unknownStaffCollections` lists staff slugs that are not auth collections (the plugin stops the start on any). |
|
||||
| `buildFirstUserEndpoint(option?)`, `applyFirstUserRoute(config, option?)`, `adoptLateAuthCollections(config, staffSlugs, { access?, beforeOperation?, firstUserRoute? })`, `bothAllow(first, second)`, `unknownStaffCollections(config, staffSlugs)`, `openSignUpCollections(payload)`, `staffCollectionsOpenToOthers(payload)`, `staffCollectionsOnOwnRoles(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, read, update, delete from or unlock; slugs of staff collections with role values of their own on the default rules. `adoptLateAuthCollections` takes the LIVE config (`payload.config`) and gives auth collections that a plugin listed after ipalKit added the same rules, in place (called by the plugin at start and on every dev reload; returns `LateAdoption[]` — per collection what was put). There the rules are combined with the collection's own by `bothAllow` (an access function that allows only when both do; two query constraints are joined with `and`), because in a sanitized config Payload's default cannot be told from a written rule — never by a function's name, which a production build changes. `custom.ipal.accountRules: false` on a late collection keeps its rules as they are. `unknownStaffCollections` lists staff slugs that are not auth collections (Payload does not start on any). |
|
||||
| `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 (`smtpHost`, `smtpPort`, `smtpUser` — not the transport: the mail adapter may fall back to SMTP). |
|
||||
| `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. |
|
||||
@@ -81,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`, `adminOnlyWrite`, `staffOnlyRead`, `firstUserRoute`, `password`), `StaffAccountAccessOptions` (`{ create?, write?, read?, pluginRoles? }`), `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`), `StaffAccountAccessOptions` (`{ create?, write?, read?, pluginRoles? }`), `LateAdoption` (`{ slug, applied, password, firstUser }`), `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`
|
||||
|
||||
|
||||
@@ -257,7 +257,9 @@ the panel shows Site settings, Site integrations, Cookies, Form messages, the Fo
|
||||
account with any role — **write its `create` / `update` / `delete` rules and the field access of its `roles`
|
||||
field yourself** (`ipal-doctor --url` → `staff-own-roles`). Give every staff collection a `roles` field: without
|
||||
one each of its accounts is an admin to the plugin. Every slug in `access.staffCollections` must be an auth
|
||||
collection of the config, or the site does not start; Payload's first-user route answers only for the
|
||||
collection of the config, or Payload does not start (`/api/health` 503, the slug in the log); a staff collection
|
||||
from a plugin listed after ipalKit gets the rules in front of its own (`custom: { ipal: { accountRules: false } }`
|
||||
on it keeps its own as they are); 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
|
||||
|
||||
@@ -427,7 +427,8 @@ account → "Two-step verification: Set up." and the reset button; delete the ac
|
||||
1. Update the package, `pnpm install`, `pnpm ipal:skills`, `pnpm payload generate:types`. No import-map change, **no
|
||||
schema change and no migration** on any database (the verify count uses Payload's own `payload-kv`
|
||||
collection). `grep -n "staffCollections\|authCollection" src/payload.config.ts`: every slug there must be an
|
||||
auth collection of the config — a wrong one now stops the start with the slug in the message.
|
||||
auth collection of the config — with a wrong one Payload does not start (the slug is in the log; `/api/health`
|
||||
answers 503, so with a health check Coolify keeps the old container).
|
||||
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
|
||||
@@ -466,7 +467,9 @@ account → "Two-step verification: Set up." and the reset button; delete the ac
|
||||
- `read`: only staff accounts read a staff collection. **Check:** does the front end show staff accounts
|
||||
(an author box) to logged-in visitors with the visitor's session? Then write that collection's `read` rule,
|
||||
or `accounts: { staffOnlyRead: false }`. Anonymous visitors never could.
|
||||
A staff collection added by a plugin listed after ipalKit gets the same rules at start.
|
||||
A staff collection added by a plugin listed after ipalKit gets the same rules at start, put in FRONT of the
|
||||
rules it has (both must allow). If that plugin's collection needs a rule wider than the plugin's default,
|
||||
set `custom: { ipal: { accountRules: false } }` on it.
|
||||
`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
|
||||
|
||||
@@ -676,7 +676,7 @@ Do one item at a time, build, check. Order by importance:
|
||||
| 66 | **1.16.4** — production `PAYLOAD_SECRET` shorter than 32 characters (the site would stop at `assertEnv`) | Before deploying 1.16.4, check the length in Coolify (`node -e 'console.log(process.env.PAYLOAD_SECRET.length)'`). Shorter: a random 32+ character secret (logs everyone out, asks for 2FA again, breaks stored API keys), or `ipalEnvRules({ secretMinLength: 0 })` for now | CHANGELOG 1.16.4, deployment.md "PAYLOAD_SECRET — length and changing it" |
|
||||
| 67 | **1.16.5 — security** — with 2FA on, `/admin/verify-totp?back=https%3A%2F%2Fexample.com%2F` sends the user to example.com after the code (and `back=javascript:…` runs script in the panel) | Upgrade and, **in ONE deploy**, `pnpm payload generate:importmap` (adds `@intecion/ipal-kit/admin#SafeTotpView`), commit `importMap.js`, `rm -rf .next`, redeploy on Coolify — with the old map the 2FA screens have no code form and nobody can sign in (run `pnpm exec ipal-doctor` before deploying; the start log says so too); check: the link above ends on `/admin`. `pnpm ipal:skills`. No option, env or migration; off / own rule: `twoFactor.safeBack` | CHANGELOG 1.16.5, security.md "The `back` link of the 2FA screens" |
|
||||
| 68 | **1.16.6 — 2FA setup required** (not a routine patch: a new default that can lock accounts out) — an account that has not set 2FA up still reads data over the API with its password; or after the upgrade an account "can do nothing" / is blocked | Before upgrading: `ipal-doctor --url` → accounts without 2FA set it up or are removed; one admin (better two) must have 2FA; deploy day agreed with the owner. Then, in ONE deploy: update, `generate:types`, `generate:importmap` (`TwoFactorStatusField`, `TwoFactorAlert`), **Postgres/SQLite: `migrate:create` and the migration applied in the same deploy when the new container starts — `prodMigrations` or `pnpm payload migrate && pnpm start`, never a pre-deployment command (deployment.md §4.3) — (column `totp_setup_from`); without it every login answers 500**, build, redeploy. Existing accounts get 72 h from the first start; blocked later → admin: account page → "Reopen setup". Password-login integrations: API key or `requireSetup.exempt`. `pnpm ipal:skills` | CHANGELOG 1.16.6, security.md "Setup required" |
|
||||
| 69 | **Unreleased — hardening (M1)** — an account with only the role `user` sees "Unauthorized" in the panel; or the API returns `"smtpPassword":"********"`; or a form with a File field is refused while Turnstile is misconfigured; or "The password must have at least 12 characters."; or "Enter the password again…" on the SMTP password; or `403` "Not allowed from this origin." on the 2FA code | Update, `generate:types`, redeploy; no import map, schema or migration. Every slug in `access.staffCollections` must be an auth collection (the start stops otherwise). Set `serverURL` (a proxy that rewrites `Host` otherwise blocks the 2FA code; the log names the origin). Read the start log (`N account(s) … cannot open the admin panel`) and give panel users `editor`. Own code that read the two secrets over the API → Local API on the server. `TURNSTILE_SECRET_KEY` is deprecated: with the owner move the key into the panel. Own staff collection without rules: an admin (update: or the account itself; roles only by an admin; read by staff only) where the roles are the plugin's, accounts of that collection where they are the project's own — write that collection's own rules. Existing short passwords keep working. Switches: `accounts`, `secrets`, `forms.turnstileOnConfigError`, `twoFactor.sameOrigin`, `dashboardAlerts`. `pnpm ipal:skills` | CHANGELOG "Unreleased — hardening", access.md "Account rules", security.md "Stored secrets", turnstile.md |
|
||||
| 69 | **Unreleased — hardening (M1)** — an account with only the role `user` sees "Unauthorized" in the panel; or the API returns `"smtpPassword":"********"`; or a form with a File field is refused while Turnstile is misconfigured; or "The password must have at least 12 characters."; or "Enter the password again…" on the SMTP password; or `403` "Not allowed from this origin." on the 2FA code | Update, `generate:types`, redeploy; no import map, schema or migration. Every slug in `access.staffCollections` must be an auth collection (otherwise Payload does not start: `/api/health` 503, the old container keeps serving). Set `serverURL` (a proxy that rewrites `Host` otherwise blocks the 2FA code; the log names the origin). Read the start log (`N account(s) … cannot open the admin panel`) and give panel users `editor`. Own code that read the two secrets over the API → Local API on the server. `TURNSTILE_SECRET_KEY` is deprecated: with the owner move the key into the panel. Own staff collection without rules: an admin (update: or the account itself; roles only by an admin; read by staff only) where the roles are the plugin's, accounts of that collection where they are the project's own — write that collection's own rules. Existing short passwords keep working. Switches: `accounts`, `secrets`, `forms.turnstileOnConfigError`, `twoFactor.sameOrigin`, `dashboardAlerts`. `pnpm ipal:skills` | CHANGELOG "Unreleased — hardening", access.md "Account rules", security.md "Stored secrets", turnstile.md |
|
||||
|
||||
After updating the package: `pnpm ipal:skills` (new skill versions), `pnpm payload generate:importmap`, `rm -rf .next`, restart dev, grep for the new symbol in
|
||||
`node_modules/@intecion/ipal-kit/dist`.
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@ Turn off: `ipalKit({ doctor: false })`. Adapt: `ipalKit({ doctor: { tokenVar: 'M
|
||||
| | `csrf-empty` | warning | the config sets `serverURL` or `csrf` — otherwise Payload accepts the login cookie from any origin |
|
||||
| | `open-signup` | info | (deep) auth collections whose `create` rule lets an anonymous request through: sign-up is open there (intended for a customer zone — silence with a reason) |
|
||||
| | `staff-own-roles` | warning | (deep) a staff collection with role values of its own (not `user` / `editor` / `admin`) that runs on the plugin's default account rules: the plugin cannot rank those roles, so inside the collection every account may create an account with any role and change or delete another. Write the collection's own rules |
|
||||
| | `staff-accounts-open` | error (warning for `read`) | (deep) a staff collection that an account of another, non-staff auth collection may create in, read, update, delete from or unlock — it can make itself staff, change a staff password, list the accounts or lift a login lock. The account rules are off (`accounts: false`, `adminOnlyCreate` / `adminOnlyWrite` / `staffOnlyRead: false`) or the project's own rule is wider. Asked with a made-up outside account; a rule that throws counts as closed |
|
||||
| | `staff-accounts-open` | error (warning for `read`, `readVersions`) | (deep) a staff collection that an account of another, non-staff auth collection may create in, read (also its versions), update, delete from or unlock — it can make itself staff, change a staff password, list the accounts or lift a login lock. The account rules are off (`accounts: false`, `adminOnlyCreate` / `adminOnlyWrite` / `staffOnlyRead: false`) or the project's own rule is wider. Asked with a made-up outside account; a rule that throws counts as closed |
|
||||
| | `turnstile-degraded` | warning / error | (deep) Turnstile is checking forms; while it is not (wrong or missing secret, Cloudflare down) a warning, an error once it has lasted 24 hours (counted from the recorded start to now) |
|
||||
| | `turnstile-env-key` | warning | (deep) the Turnstile secret key is in the panel, not in the deprecated `TURNSTILE_SECRET_KEY` environment variable |
|
||||
| | `cookie-scanner` | error / warning / info | `cookieScanner` on (with `crawl`, else info); deep: nothing waits for approval (warning) |
|
||||
|
||||
@@ -943,6 +943,7 @@ size while reading, content signature, container and macro checks, an optional `
|
||||
| nothing for the field, an empty value, `null`, or `'********'` back | the stored value is kept |
|
||||
| a new value | replaces it (the answer shows `'********'`) |
|
||||
| `'[[clear]]'` (`SECRET_CLEAR`) | removes it |
|
||||
| a value that is not text (`false`, `0`, a list, an object) | **refused** (`400`): "Enter the value as text." |
|
||||
| the server, the port or the user name **changed** (whatever the transport), and **no** new password | **refused** (`400`, on the password field): "Enter the password again…" |
|
||||
|
||||
In the panel the field says "A value is set. It is not shown; type a new one to replace it." and offers "Remove
|
||||
|
||||
Reference in New Issue
Block a user