M1: docs, agent guide, skills and changelog for the hardening items
security.md (stored secrets, own-origin 2FA attempts, stored verify count, dashboard alerts by role), access.md (account rules: panel role, no self-registration, passwords), turnstile.md (the deprecated env secret, forms.turnstileOnConfigError), doctor.md (five new rules, the deep status), AGENT.md, ipal-setup, ipal-upgrade, ipal-debug, ipal-reference (+ api.md), ipal-doctor and their mirrors, PROGRAMISTA row 69, CHANGELOG under an unreleased heading with "Requires project changes". Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
f7296edc71
commit
83356ab4ed
@@ -8,6 +8,99 @@ 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.
|
||||
|
||||
## Unreleased — hardening (M1; version to be set at release)
|
||||
|
||||
> **Read before upgrading.** Several defaults get stricter. Most sites change nothing, but check
|
||||
> "Requires project changes": an account with only the role `user` can no longer open the panel, and a form with
|
||||
> files is refused while Turnstile is misconfigured. No import-map change, no schema change, no migration.
|
||||
|
||||
### Security
|
||||
- **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;
|
||||
only server code (the Local API with access control off) reads the value. A save that sends nothing, an empty
|
||||
value or the mask keeps the stored value; `'[[clear]]'` removes it. The panel is the source of these secrets
|
||||
([security.md](./security.md) "Stored secrets").
|
||||
- **Nobody creates an account for themselves.** (1) Payload's first-user route
|
||||
(`POST /api/<slug>/first-register`) answers for every empty auth collection. On an empty **second staff
|
||||
collection** (`access.staffCollections`) the first visitor became a staff account — an admin to the plugin.
|
||||
It now answers only for the collection the panel logs in with. (2) A project's **own** staff collection without
|
||||
a `create` rule let any signed-in account create accounts (Payload's default); now only an admin does.
|
||||
Anonymous sign-up into the staff collection was already refused. 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
|
||||
still sends the login cookie to (a sibling subdomain, when neither `serverURL` nor `csrf` is set) could burn an
|
||||
account's five verify attempts and lock its owner out, without the password. Such requests are refused before
|
||||
they are counted. **The verify count is also stored in the database**, so a restart or a second instance no
|
||||
longer resets it.
|
||||
- **Dashboard alerts no longer show integration error texts to every panel role**: details for admins, a neutral
|
||||
line for editors, nothing for others or for a session that still owes its second factor.
|
||||
|
||||
### Changed
|
||||
- **The admin panel opens for `editor` and above** (`accounts.panelRole`). An account that holds only `user`
|
||||
sees "Unauthorized" in the panel; the API is not touched.
|
||||
- **A password set on a staff account has at least 12 characters** and is not the account's e-mail address
|
||||
(`accounts.password`). Existing passwords are never checked.
|
||||
- **A form with files is refused while Turnstile cannot check** (wrong or missing secret, Cloudflare down); a
|
||||
text form is accepted as before (`forms.turnstileOnConfigError`).
|
||||
- **`TURNSTILE_SECRET_KEY` from the environment is deprecated.** It still works when the panel field is empty
|
||||
and logs a notice once per start. It will be removed in a later release, named here in advance.
|
||||
|
||||
### Added
|
||||
- Options: `accounts` (`panelRole`, `adminOnlyCreate`, `firstUserRoute`, `password`), `secrets.writeOnly`,
|
||||
`forms.turnstileOnConfigError`, `twoFactor.sameOrigin`, `twoFactor.verifyLimit.store`, `dashboardAlerts`.
|
||||
- ipal-doctor rules: `access-missing` (no `access` option: every panel account is an admin), `csrf-empty`
|
||||
(neither `serverURL` nor `csrf`), and with `--url`: `open-signup` (info), `turnstile-degraded` (warning, error
|
||||
after a day), `turnstile-env-key`. The deep status gained `openSignUp`, `turnstile`, `turnstileSecretFromEnv`
|
||||
(states and slugs, never a key).
|
||||
- Exports: `writeOnlySecret`, `writeOnlySecrets`, `SECRET_MASK`, `SECRET_CLEAR`, `maskSecretAfterRead`,
|
||||
`keepSecretBeforeValidate`, `isSecretMask`, `INTEGRATION_SECRET_FIELDS`; `panelAccess`, `applyPanelRole`,
|
||||
`resolvePanelRole`, `countBelowPanelRole`, `DEFAULT_PANEL_ROLE`; `staffCreateAccess`, `applyAdminOnlyCreate`,
|
||||
`buildFirstUserGuard`, `applyFirstUserRoute`, `openSignUpCollections`; `checkPassword`,
|
||||
`buildPasswordRuleHook`, `applyPasswordRule`, `resolvePasswordRule`, `DEFAULT_PASSWORD_MIN_LENGTH`;
|
||||
`requestFromOwnOrigin`, `ownOrigins`; `buildVerifyLimit`, `verifyLimitKey`, `clearVerifyLimits`;
|
||||
`turnstileSecretFromEnv`, `TURNSTILE_SECRET_ENV`; from `/server`: `passTurnstile`, `passSubmitGates`,
|
||||
`resolveTurnstileOnConfigError`, `TURNSTILE_ON_CONFIG_ERROR_DEFAULT`.
|
||||
- `MaskedField` says "A value is set" for a write-only field and offers "Remove the stored value".
|
||||
|
||||
### Requires project changes
|
||||
- **Every site: read the first start's log.** `[ipal] N account(s) of "users" are below the role "editor" and
|
||||
cannot open the admin panel` — give the people who work in the panel `editor`, or set
|
||||
`accounts: { panelRole: 'user' }`. `NOBODY can open the admin panel` (an error): no account has the role —
|
||||
a script with the Local API (`roles: ['admin']`), or `accounts: { panelRole: false }` and redeploy.
|
||||
- **Own code that read `smtpPassword` / `turnstileSecretKey` over REST or GraphQL**, or with
|
||||
`overrideAccess: false`: it now gets `'********'`. Read them on the server with
|
||||
`payload.findGlobal({ slug: 'site-integrations' })`. Nothing to do otherwise: stored values stay, e-mail and
|
||||
Turnstile keep working.
|
||||
- **A site whose Turnstile secret is only in `TURNSTILE_SECRET_KEY`:** nothing breaks. With the owner, move the
|
||||
key into Site integrations → Spam protection, then remove the variable (`ipal-doctor --url` →
|
||||
`turnstile-env-key`).
|
||||
- **Forms with a File field:** make sure Turnstile works (`ipal-doctor --url` → no `turnstile-degraded`); while
|
||||
it does not, those forms are refused. To keep accepting them: `forms: { turnstileOnConfigError: { files: 'allow' } }`.
|
||||
- **A project's own staff collection without a `create` rule:** only admins create accounts now. Write the rule
|
||||
you want, or `accounts: { adminOnlyCreate: false }`. `first-register` for other auth collections: `403` unless
|
||||
the collection allows sign-up, or `accounts: { firstUserRoute: 'all' }`.
|
||||
- **Scripts that create staff accounts with a password under 12 characters** fail with a validation error.
|
||||
Existing accounts with short passwords keep logging in.
|
||||
- **A panel or front end on another domain that posts to `/api/verify-totp`:**
|
||||
`twoFactor: { …, sameOrigin: { origins: ['https://…'] } }`.
|
||||
- `pnpm payload generate:types`, `pnpm ipal:skills`.
|
||||
|
||||
### Known limitations
|
||||
- Write-only protects the API and the panel, not the database: the two secrets are stored in plain text there
|
||||
and in backups (encryption at rest is not part of this release). A secret equal to `********` or `[[clear]]`
|
||||
cannot be stored.
|
||||
- The panel role and the password rule need `access` (roles) resp. a staff collection with password login; a
|
||||
second staff collection without a `roles` field is not affected by `panelRole`.
|
||||
- The stored verify count uses Payload's `payload.kv`; on a Payload version without it the count is in memory
|
||||
only. Two instances can each let a few attempts through before the other's write lands ("max per instance" at
|
||||
worst, never unlimited).
|
||||
- The own-origin check trusts `Host` / `X-Forwarded-Host` as the proxy sets them, and passes requests without
|
||||
`Origin` and `Sec-Fetch-Site` (non-browser clients).
|
||||
- `access-missing` and `csrf-empty` are text searches of the config file and can miss or misread unusual
|
||||
spellings; `open-signup` evaluates a `create` rule with an anonymous request and counts a rule that throws as closed.
|
||||
- **Not run for this release:** see the hand-over; in short, the panel checks ran in Chromium on MongoDB only.
|
||||
|
||||
## Unreleased
|
||||
|
||||
### Fixes
|
||||
|
||||
@@ -224,8 +224,92 @@ applyGlobalOverrides(globals, { notifications: { … } }) // the same logic as
|
||||
|
||||
Types: `AccessOption`, `Role`, `GlobalOverride`, `GlobalOverrides`, `IpalGlobalSlug`.
|
||||
|
||||
## Account rules (`accounts`)
|
||||
|
||||
Rules for the accounts of the staff collection. All on by default; each has its own switch, and
|
||||
`ipalKit({ accounts: false })` turns them all off.
|
||||
|
||||
```ts
|
||||
ipalKit({
|
||||
access: { authCollection: 'users' },
|
||||
// accounts: { panelRole: 'user' }, // every account may open the panel (as before)
|
||||
// accounts: { adminOnlyCreate: false }, // Payload's default `create` on your own staff collection
|
||||
// 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: false, // none of the rules
|
||||
})
|
||||
```
|
||||
|
||||
### Who may open the panel (`accounts.panelRole`, default `'editor'`)
|
||||
|
||||
The lowest role, `user`, is what a new account gets (`access.defaultRole`) and has no business in the panel. The
|
||||
panel opens for `editor` and above: it is Payload's `access.admin` on the collection that carries the roles. An
|
||||
account that holds only `user` (or no role) logs in and sees Payload's "Unauthorized" screen. **The API is not
|
||||
touched** — such an account still gets over REST / GraphQL what its role allows. The rule looks at the role, not
|
||||
at the second factor, so the 2FA screens stay reachable.
|
||||
|
||||
- **What an existing site sees on the first start:** the log line `[ipal] N account(s) of "users" are below the
|
||||
role "editor" and cannot open the admin panel` — give those people `editor`, or set `panelRole: 'user'`. When
|
||||
**no** account has the role it is an error (`NOBODY can open the admin panel`): give one account the role with
|
||||
a script (`payload.update`, Local API) or set `accounts: { panelRole: false }` and redeploy.
|
||||
- `'admin'` = admins only; `'user'` or `false` = everyone, as before. Needs `access` (the roles). Your own
|
||||
`access.admin` on the collection, or `access.authAccess.admin`, wins. Building blocks: `panelAccess(role)`,
|
||||
`applyPanelRole`, `resolvePanelRole`, `countBelowPanelRole`, `DEFAULT_PANEL_ROLE`.
|
||||
- **Check:** log in to `/admin` as an account with the role `user` → "Unauthorized"; `GET /api/access` for it →
|
||||
`canAccessAdmin: false`; `GET /api/users/me` still answers.
|
||||
|
||||
### Nobody creates an account for themselves (`accounts.adminOnlyCreate`, `accounts.firstUserRoute`)
|
||||
|
||||
By default only the first account of a site can be registered by a visitor, and it becomes admin
|
||||
(`access.firstUserAdmin`); every other account is made by an admin.
|
||||
|
||||
| | Before | Now (default) |
|
||||
|---|---|---|
|
||||
| Anonymous `POST /api/users`, GraphQL `createUser` | refused | refused |
|
||||
| The first account: `POST /api/users/first-register` on an empty collection | 200, role `admin` | the same |
|
||||
| A signed-in editor or plain user creates an account in the plugin's injected collection | refused | refused |
|
||||
| …in **the project's own** staff collection that has no `create` rule | **allowed** (Payload's default: any logged-in user) | refused — an admin, fully signed in (`staffCreateAccess`) |
|
||||
| `POST /api/<slug>/first-register` on another empty auth collection (`members`) | **200** | 403 |
|
||||
| …on an empty **second staff collection** (`access.staffCollections`) | **200, and that account was staff** | 403 — an admin of the panel's collection creates its first account |
|
||||
| A collection that allows sign-up (`customers` with `create: () => true`) | allowed | allowed, its first-user route too |
|
||||
|
||||
- `adminOnlyCreate` applies to the staff collections (the panel's login collection, `access.authCollection`,
|
||||
`access.staffCollections`) that have **no** `create` rule; a rule you wrote stays. `false` = Payload's default.
|
||||
- `firstUserRoute`: `'panel'` (default) = the collection the panel logs in with; a list of slugs = those;
|
||||
`'all'` = Payload's behaviour. A collection whose own `create` rule lets an anonymous request through keeps
|
||||
its route.
|
||||
- **A fresh site:** whoever opens the panel first becomes the admin — create the first account right after the
|
||||
first deploy.
|
||||
- **What an existing site sees:** nothing, unless its own staff collection relied on Payload's default `create`
|
||||
(non-admins creating accounts) — then give it a `create` rule or set `adminOnlyCreate: false`.
|
||||
- `ipal-doctor --url` lists auth collections with open sign-up (`open-signup`, info).
|
||||
- Building blocks: `staffCreateAccess`, `applyAdminOnlyCreate`, `buildFirstUserGuard`, `applyFirstUserRoute`,
|
||||
`openSignUpCollections`.
|
||||
- **Check:** `curl -X POST <site>/api/members/first-register -H 'content-type: application/json' -d
|
||||
'{"email":"x@example.com","password":"a-long-password-1"}'` → `403`; the same for `/api/users` → `403`.
|
||||
|
||||
### Passwords (`accounts.password`, default 12 characters)
|
||||
|
||||
When a password is **set** on a staff collection — a new account, the first-user screen, a change, a reset by
|
||||
e-mail; in the panel, over the API and through the Local API — it must have at least 12 characters and must not
|
||||
be the account's own e-mail address (Payload's own rule is 3 characters). **Existing passwords are never
|
||||
checked:** an account with a shorter one keeps logging in, and meets the rule the next time its password is
|
||||
changed. The message is in the panel's language, English or Polish ("The password must have at least 12
|
||||
characters."; texts `passwordTooShort`, `passwordIsEmail` in `i18n.translations.<lang>.ipal`).
|
||||
|
||||
- `password: { minLength: 16 }`; `password: false` = Payload's rule. Visitor collections are not touched.
|
||||
- No breached-password lookup (it would send part of a hash of every new password to an outside service);
|
||||
build one on `checkPassword` / `buildPasswordRuleHook` if a project needs it.
|
||||
- A script or seed that creates a staff account with a shorter password now fails with a validation error.
|
||||
- Building blocks: `checkPassword`, `buildPasswordRuleHook`, `applyPasswordRule`, `resolvePasswordRule`,
|
||||
`DEFAULT_PASSWORD_MIN_LENGTH`.
|
||||
- **Check:** create an account with an 11-character password → "The password must have at least 12 characters.".
|
||||
|
||||
## Turn off, override, extend
|
||||
|
||||
- **Account rules:** `accounts: false`, or one by one — `panelRole`, `adminOnlyCreate`, `firstUserRoute`,
|
||||
`password` (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),
|
||||
|
||||
+8
-1
@@ -1167,7 +1167,14 @@ add missing hosts with flags / `extra`; (3) change `mode` to `'enforce'` in both
|
||||
| 2FA on the panel's login collection, mismatch = startup error; redirect to the 2FA screens by `TotpRedirectProvider` | `twoFactor: false` (discouraged) | `twoFactor.collectionSlug`, `allowCollectionMismatch: true`, `twoFactor.provider` (own component, or `false` for the package's) |
|
||||
| 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`), `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 verify attempts per account in 10 minutes (`POST /api/verify-totp` → `429`) | `twoFactor.verifyLimit: false` | `verifyLimit: { max, windowMinutes }` |
|
||||
| At most 5 verify attempts per account in 10 minutes (`POST /api/verify-totp` → `429`); the count is kept in memory and in the database (`payload.kv`), so a restart or a second instance does not reset it | `twoFactor.verifyLimit: false` | `verifyLimit: { max, windowMinutes, store: 'memory' }` |
|
||||
| 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 | `twoFactor.sameOrigin: false` | `sameOrigin: { origins: ['https://app.example.com'] }`; `requestFromOwnOrigin` |
|
||||
| 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 |
|
||||
| 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: only an admin creates accounts in a staff collection (also the project's own); Payload's first-user route answers only for the panel's login collection (the first account, which becomes admin) | `accounts: { adminOnlyCreate: false, firstUserRoute: 'all' }` | your own `create` rule wins; `firstUserRoute: ['users', 'partners']`; a collection with open sign-up keeps its routes; `staffCreateAccess`, `buildFirstUserGuard` |
|
||||
| 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 | `dashboardAlerts: { integrations: 'all', cookies: 'all' }` | `integrations: 'editor'`; the components' `details` / `audience` props |
|
||||
| The `back` link of the 2FA setup and verify screens is checked on the server (`SafeTotpView` in front of the package's views): only a path on the site's origin inside the admin route is kept, anything else (`javascript:`, another host) becomes the admin root. Needs `generate:importmap` in the same deploy — with a stale map the 2FA screens have no code form and nobody can sign in (`ipal-doctor`, the start log and a notice above the screen report it; the notice is a hint from the file on disk and never replaces the screen; `twoFactor.importMapCheck: false` turns it off); check: password only → `/admin/verify-totp?back=https%3A%2F%2Fexample.com%2F` → code → lands on `/admin` | `twoFactor.safeBack: false` | `safeBack: (back, { adminRoute, origin }) => string`; `safeAdminBack`, `wrapTotpViews` (`@intecion/ipal-kit`), `SafeTotpView` (`@intecion/ipal-kit/admin`) for own views |
|
||||
| The 2FA package's endpoints (`/api/setup-totp`, `verify-totp`, `remove-totp`, `admin/*`) answer accounts of the 2FA collection only; reset and remove need the second factor | — (always on with 2FA) | `adminManageAccess` through the wrapped factory (security.md "Resetting 2FA") |
|
||||
| Roles count only for accounts of a staff collection, in every predicate and access function | — | `access.staffCollections` |
|
||||
|
||||
@@ -100,6 +100,16 @@ through this procedure. Ask only when you are missing something you cannot get y
|
||||
| emails are not sent | no `email: mailAdapter()` / empty transport / empty Emails tab | email.md; Send test in the panel |
|
||||
| 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` |
|
||||
| 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 |
|
||||
| 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 |
|
||||
|
||||
### Environment
|
||||
|
||||
@@ -50,7 +50,7 @@ Existing client sites are not gated on it; run it there as a report only.
|
||||
## The status endpoint
|
||||
|
||||
`GET /api/ipal/doctor` is added by `ipalKit` and answers 404 until the site has `IPAL_DOCTOR_TOKEN` (≥ 32 characters).
|
||||
Then `Authorization: Bearer <token>`; counts only (`usersWithout2fa`, `usersSetupClosed` = of those, blocked because the 2FA setup window has passed, `pendingCookies`, `plugin`, `node`). With the same
|
||||
Then `Authorization: Bearer <token>`; counts and states only (`usersWithout2fa`, `usersSetupClosed` = of those, blocked because the 2FA setup window has passed, `pendingCookies`, `openSignUp` = slugs of auth collections with open sign-up, `turnstile` = the recorded state of the Turnstile check, `turnstileSecretFromEnv`, `plugin`, `node`) — never a key or a name. With the same
|
||||
`IPAL_DOCTOR_TOKEN` in the doctor's environment, `--url` reads it. Off: `ipalKit({ doctor: false })`; adapt:
|
||||
`ipalKit({ doctor: { tokenVar, access } })`.
|
||||
|
||||
|
||||
@@ -31,6 +31,13 @@ description: Complete map of everything @intecion/ipal-kit provides — every ip
|
||||
| `access.authAccess` | `{ create: adminOnly, delete: adminOnly, read: adminOrSelfIn(slug), unlock: adminOnly, update: adminOrSelfIn(slug) }` | access of the auth collection the plugin **injects** (Payload's default lets any logged-in account edit or delete every other account) | your keys win, e.g. `{ read: authenticated }`; your own collection with that slug wins whole (give it `adminOrSelf` / `adminOnly` yourself) |
|
||||
| `access.firstUserAdmin` | `true` | the account made on Payload's "Create first user" screen (`/first-register` on an empty collection) gets `roles: ['admin']`; an open sign-up still gets `defaultRole` | `false` = that account gets what was submitted |
|
||||
| `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.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) |
|
||||
| `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 | — |
|
||||
@@ -41,7 +48,8 @@ description: Complete map of everything @intecion/ipal-kit provides — every ip
|
||||
| `twoFactor.importMapCheck` | on | production only: at start searches the `importMap.js` on disk (where Payload looks for it) for `@intecion/ipal-kit/admin#SafeTotpView`; when not found, logs `[ipal] The admin import map may be out of date …` and ipal-kit's `TotpRedirectProvider` puts the notice "Two-step verification may not be available" above the 2FA screens (never instead of them). A hint only — the map in the build can differ from the file on disk (Dockerfile runner stage, re-exporting map); a file that is not found is not reported | `false` = no file read, log line or notice |
|
||||
| `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 }` | 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`; in memory per instance | `{ max, windowMinutes }`; `false` = no limit |
|
||||
| `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.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 |
|
||||
@@ -77,6 +85,7 @@ description: Complete map of everything @intecion/ipal-kit provides — every ip
|
||||
| `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 |
|
||||
| `forms.turnstileOnConfigError` | `{ text: 'allow', files: 'reject' }` | what a form does while Turnstile CANNOT check (wrong / missing secret, Cloudflare down): a text form is accepted, a submission to the file endpoint is refused. Not involved while Turnstile is off | `'allow'` / `'reject'` for every form, or `{ text, files }`; `turnstileOnConfigError` at a call site (`createSubmitAction`, `attachments.submit`) wins |
|
||||
| `forms.attachments` | off | **File** field in the form builder; a file is checked (size, count, type by content, refused extensions), attached to the company e-mail and dropped — **never stored**; adds `POST /api/ipal/forms/submit`, the fields `submissionFiles` / `filesDelivery` / `filesDeliveryNote` / `attemptKey` on `form-submissions`, and the **Files** texts in Form messages | `true` / `FormAttachmentsOption`: `maxSizeMB` (10), `maxTotalMB`, `maxFiles` (3), `fileTypes`, `allowRisky`, `scan` (antivirus hook — none built in), `strictPdf`, `notice`, `maxConcurrent` (2), `path`, `submit` (`maxPerMinute`, `clientIp`, `honeypotField`, `turnstileHostnames`, `turnstileOnConfigError`, `allowedOrigins`, `idleTimeoutMs`, `timeoutMs`); block only: `forms.fields.file: false` or `buildFileBlock(…)`. Postgres: `migrate:create`. Check: submit a PDF → attached to the company e-mail, absent from the customer e-mail, submission shows *File delivery: Handed to the mail server* (forms.md "Files") |
|
||||
| `forms.consentFieldName` | `'consent'` | name of the GDPR consent field `submitForm` requires (read from `config.custom.ipal`) | `createSubmitAction({ consentFieldName })` / `submitForm` argument wins |
|
||||
| `consentLog` | off | `consent-records` collection + `POST /api/ipal/consent` (rate limit 20/min) | `true` / `{ retentionDays }` (default 1095) |
|
||||
|
||||
@@ -20,7 +20,7 @@ Admin panel components from `@intecion/ipal-kit/admin` — the project does NOT
|
||||
|
||||
| Export | Import from | What it does / when |
|
||||
|---|---|---|
|
||||
| `MaskedField` | `@intecion/ipal-kit/admin` | Masked text field (••••, Reveal button) for secrets in SiteIntegrations (SMTP password, R2 key, Turnstile secret) — masking in the UI only, not encryption. Injected by the plugin; you can also wire it to your own `text` field via `admin.components.Field`, then `pnpm generate:importmap`. |
|
||||
| `MaskedField` | `@intecion/ipal-kit/admin` | Text input for a secret. With a write-only field (`writeOnlySecret`, the default for the plugin's SMTP password and Turnstile secret) the value never reaches the browser: the input stays empty, says "A value is set", typing replaces it, "Remove the stored value" clears it on save. With a plain text field the value arrives and is drawn as dots with Show / Hide. Injected by the plugin; you can also wire it to your own `text` field via `admin.components.Field`, then `pnpm generate:importmap`. |
|
||||
| `TestEmailButton` | `@intecion/ipal-kit/admin` | "Send test e-mail" button in the SiteIntegrations e-mail tab — POST `/api/ipal/test-email` through the selected transport (SMTP/Graph), shows the result/error. Injected by the plugin — do not call. |
|
||||
| `RowLabel` | `@intecion/ipal-kit/admin` | Array row title in the panel taken from the row content (e.g. "Fast delivery" instead of "Item 01"). Do not wire by hand — use `rowLabel()`; after adding, `pnpm generate:importmap`. |
|
||||
| `AdminLogo` | `@intecion/ipal-kit/admin` | Server Component: large panel logo (login screen) from SiteSettings `logo`, fallback `siteName`. Injected by the plugin with `whiteLabel`; after turning the option on, `pnpm generate:importmap`. |
|
||||
@@ -66,13 +66,20 @@ Admin panel components from `@intecion/ipal-kit/admin` — the project does NOT
|
||||
| `hasMinimumRole(user, minimum, source?)` | `@intecion/ipal-kit`; in client components `@intecion/ipal-kit/client` | Predicate → `boolean`: the user is an account of a **staff collection** and has a role ≥ `minimum` (reads `user.roles` and `user.collection` safely). A role on an account of another auth collection never counts. `source` says which collections are staff: `req.payload` on the server, the config from `useConfig()` in a client component (it has `admin.user` only; for `access.staffCollections` pass the list), or `{ staffCollections: ['users'] }` (middleware). Without it: the staff collections of the config ipalKit built in this process (two different configs: only what both call staff) — and **`false` where there is none** (browser bundle, middleware, edge). Does not check the second factor. |
|
||||
| `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. |
|
||||
| `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. |
|
||||
| `staffCollectionSlugs(source?)` | `@intecion/ipal-kit` | `string[]`: the staff collections — `admin.user`, `access.authCollection` and `access.staffCollections` — from `req.payload`, a config or `{ staffCollections }`; without an argument what the configs built in this process agree on (`[]` when there is none). Roles and staff checks count only for accounts of these. |
|
||||
| `ROLE_HIERARCHY` | `@intecion/ipal-kit` | Constant `['user', 'editor', 'admin']` (lowest first) — a higher role meets the requirements of a lower one. The plugin injects the `roles` field into the auth collection (`access.authCollection`). |
|
||||
| `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:** `VerifyLimitOptions` (`twoFactor.verifyLimit`: `{ max?, windowMinutes? }`), `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`, `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`).
|
||||
|
||||
## Accessibility — widget (`accessibility`) — details: `node_modules/@intecion/ipal-kit/docs/accessibility.md`
|
||||
|
||||
@@ -370,7 +377,7 @@ Full option lists of `createContentHelpers` / `createPageRoute` / `SiteProviders
|
||||
| `recordIntegrationStatus(payload, field, previous, { state, code?, message? })` | `@intecion/ipal-kit` | saves the state of your own integration in Site integrations (only on change / every 10 min); does not throw. For e-mail and Turnstile the plugin calls it itself — do not call |
|
||||
| `buildIntegrationStatusField(name)` | `@intecion/ipal-kit` | hidden status group field (`state`, `code`, `message`, `since`, `checkedAt`) for `integrationsFields` |
|
||||
| `buildIntegrationStatusBanner(statusField, label, texts?)` | `@intecion/ipal-kit` | UI field with a status banner on the integration tab (`label` string or `{ en, pl }`; `texts` = `{ failing, hint }` keys of your own `ipal` translations) (`integrationsFields`; then `pnpm generate:importmap`) |
|
||||
| `IntegrationAlerts` | `@intecion/ipal-kit/admin` | dashboard alert about integrations in the `degraded` state; always injected by the plugin (`beforeDashboard`); your own integrations: a second instance with `checks` |
|
||||
| `IntegrationAlerts` | `@intecion/ipal-kit/admin` | dashboard alert about integrations in the `degraded` state; always injected by the plugin (`beforeDashboard`); your own integrations: a second instance with `checks`. By role: the detail (error text, link) for `details` and above (`'admin'` default, `'editor'`, `'all'`), a neutral "ask an administrator" for editors below it, nothing for others or for a session that owes its second factor (`dashboardAlerts.integrations`). `CookieCrawlAlert` takes `audience: 'editor' \| 'all'` the same way |
|
||||
| `IntegrationStatusBanner` | `@intecion/ipal-kit/admin` | status banner on the tab; injected by the plugin / `buildIntegrationStatusBanner` through the import map (`pnpm generate:importmap`), the project does not import it |
|
||||
|
||||
**Types:** `IntegrationState` (`'ok' | 'degraded'`), `IntegrationStatus` — integration state and saved status; `IntegrationLabel` (`string | { en, pl }`) — banner / alert label; `IntegrationBannerTexts` (`{ failing, hint }` text keys) — third argument of `buildIntegrationStatusBanner` for your own wording.
|
||||
@@ -855,6 +862,7 @@ Bin: `ipal-doctor` (`pnpm exec ipal-doctor [dir] [--json] [--md] [--strict] [--f
|
||||
| `useOptionalTurnstile()` | `@intecion/ipal-kit/client` | Like `useTurnstile`, but without a provider it returns `enabled: false` instead of throwing — for shared components. |
|
||||
| `Turnstile({ siteKey, onToken, theme? })` | `@intecion/ipal-kit/client` | Raw widget with an explicit key — when you do not use the provider. |
|
||||
| `verifyTurnstile({ token, payload, ip?, onConfigError?, hostnames? })` | `@intecion/ipal-kit/server` | Server-side token verification → `boolean` (`degraded` lets it through by default; `hostnames` = token must be solved on one of them, unset = not checked). `submitForm` does this itself — call it only in your own actions. |
|
||||
| `passTurnstile({ payload, turnstileToken, turnstileKind?, turnstileOnConfigError?, … })`, `passSubmitGates(…)`, `resolveTurnstileOnConfigError(payload, kind?, explicit?)`, `TURNSTILE_ON_CONFIG_ERROR_DEFAULT` | `@intecion/ipal-kit/server` | The Turnstile gate of a form (`null` = passed, else `{ success: false, reason: 'turnstile' }`) and the rate limit + Turnstile pair; the policy for a `degraded` check: the call-site value, else `forms.turnstileOnConfigError`, else the default for the kind (`{ text: 'allow', files: 'reject' }`). |
|
||||
| `checkTurnstile({ token, payload, ip? })` | `@intecion/ipal-kit/server` | As above, but returns `{ outcome: 'pass' \| 'reject' \| 'degraded', code? }` and updates the integration status in the panel. |
|
||||
|
||||
**Types:** `TurnstileConfig` (root) — `getTurnstileConfig` result; `TurnstileCheck`, `TurnstileOutcome` (`/server`) — verification result; `TurnstileProps`, `TurnstileTheme` (`/client`) — widget props and theme.
|
||||
|
||||
@@ -198,7 +198,7 @@ export default buildConfig({
|
||||
`.env.example` (no values, in the repo): `DATABASE_URI`, `PAYLOAD_SECRET`, `NEXT_PUBLIC_SERVER_URL`, `R2_BUCKET`,
|
||||
`R2_ENDPOINT`, `R2_ACCESS_KEY_ID`, `R2_SECRET_ACCESS_KEY`, `R2_PUBLIC_URL` (empty = media through the app — the default), `IPAL_IP_HEADER` (`cf-connecting-ip`
|
||||
behind Cloudflare, `x-forwarded-for` behind a plain proxy), `IPAL_NOINDEX` (empty; `1` on staging only), `INDEXNOW_KEY`,
|
||||
`NEXT_PUBLIC_TURNSTILE_SITE_KEY`, `TURNSTILE_SECRET_KEY` (panel fallback), with Graph `GRAPH_TENANT_ID`,
|
||||
`NEXT_PUBLIC_TURNSTILE_SITE_KEY`, `TURNSTILE_SECRET_KEY` (deprecated fallback — production keys go into the panel), with Graph `GRAPH_TENANT_ID`,
|
||||
`GRAPH_CLIENT_ID`, `GRAPH_CLIENT_SECRET`, `GRAPH_SENDER`. Local `.env` with `PAYLOAD_SECRET` ≥ 32 characters (in production `ipalEnvRules` refuses a shorter one; `secretMinLength` changes it).
|
||||
One language: one entry in `locales`, no `[locale]` folder (i18n.md).
|
||||
|
||||
@@ -247,6 +247,19 @@ the panel shows Site settings, Site integrations, Cookies, Form messages, the Fo
|
||||
sessions and needs the admin's own TOTP code (`twoFactor.resetAccess` changes who). Have two administrators
|
||||
with 2FA: when all are blocked, only a script or a redeploy helps (security.md "Every administrator is
|
||||
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".
|
||||
- **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.
|
||||
- **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
|
||||
accounts pass none of the plugin's checks and no role counts for them (not even their own `roles: ['admin']`);
|
||||
a field that grants rights is never writable at sign-up; use `adminOrSelfIn('<slug>')` in every auth collection; a second
|
||||
|
||||
@@ -423,6 +423,44 @@ site without steps 1–3 and a deploy day agreed with the owner. Steps 2, 3 and
|
||||
setup screen with "Set up two-step verification by …"; after the code it is in. As an administrator open that
|
||||
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).
|
||||
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
|
||||
`accounts: { panelRole: 'user' }`. The line `NOBODY can open the admin panel` (an error) means no account has
|
||||
the role: fix with a script (`payload.update({ collection: 'users', id, data: { roles: ['admin'] } })`,
|
||||
`pnpm payload run`) or `accounts: { panelRole: false }` + redeploy.
|
||||
3. **Secrets are write-only.** Nothing to do for a normal site: the SMTP password and Turnstile secret stay
|
||||
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").
|
||||
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
|
||||
test form, then remove the variable in Coolify. Do not do it on a client site without the owner. Nothing
|
||||
breaks if you wait; the removal will be announced in the changelog.
|
||||
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' }`.
|
||||
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.
|
||||
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.
|
||||
**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
|
||||
`"smtpPassword":"********"`; a test e-mail and a test form still work; an editor and an admin still log in.
|
||||
|
||||
## 2. Inventory (no code changes)
|
||||
**What changed for projects** between your old and new plugin version is exactly the reference site's diff —
|
||||
`git diff v<old> v<new> -- reference/` in the ipal-kit repo (or the two `docs/agent/reference-site/INDEX.md` files):
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ URLs point at that domain. Outside production, `R2_PUBLIC_URL` alone → read-on
|
||||
| `R2_SECRET_ACCESS_KEY` | ⬜ (✅ prod) | storage | R2 secret |
|
||||
| `R2_PUBLIC_URL` | ⬜ (✅ prod only with `storage: { requirePublicUrl: true }`) | storage | media domain attached to the bucket; empty = media through the app (§6); dev: also the `/media` path |
|
||||
| `IPAL_IP_HEADER` | ⬜ (✅ prod) | forms | header with the real IP for the rate limit (`cf-connecting-ip`, `x-forwarded-for`); without it, a warning in the log |
|
||||
| `NEXT_PUBLIC_TURNSTILE_SITE_KEY`, `TURNSTILE_SECRET_KEY` | ⬜ | forms | fallback when the Turnstile keys are not in Site integrations |
|
||||
| `NEXT_PUBLIC_TURNSTILE_SITE_KEY`, `TURNSTILE_SECRET_KEY` | ⬜ | forms | fallback when the Turnstile keys are not in Site integrations. **`TURNSTILE_SECRET_KEY` is deprecated** — put the secret key into the panel (turnstile.md); the variable keeps working until a later, announced release |
|
||||
| `INDEXNOW_KEY` | ⬜ | SEO | IndexNow key (takes precedence over the key from the panel) |
|
||||
| `IPAL_COOKIE_SCAN_URL`, `IPAL_COOKIE_SCAN_TOKEN` | ⬜ (✅ prod with `ipalEnvRules({ cookieCrawl: true })`) | consent | cookie crawl (`cookieScanner.crawl`): the shared scanner service's URL and this site's token ([cookie-scanner.md](./cookie-scanner.md#browser-crawl)) |
|
||||
| `IPAL_NOINDEX` | ⬜ | SEO | `1`/`true`/`yes` **on staging only** — the whole site is noindex (robots, meta, `X-Robots-Tag`) |
|
||||
|
||||
@@ -676,6 +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." | Update, `generate:types`, redeploy; no import map, schema or migration. 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 a `create` rule: admins only now. 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`.
|
||||
|
||||
+6
-1
@@ -66,7 +66,7 @@ Added by `ipalKit` and **off until the site has `IPAL_DOCTOR_TOKEN`** (at least
|
||||
returns counts only — never names, e-mails or values:
|
||||
|
||||
```json
|
||||
{ "node": "v22.20.0", "pendingCookies": 0, "plugin": "1.15.0", "usersSetupClosed": 0, "usersWithout2fa": 0 }
|
||||
{ "node": "v22.20.0", "openSignUp": [], "pendingCookies": 0, "plugin": "1.15.0", "turnstile": null, "turnstileSecretFromEnv": false, "usersSetupClosed": 0, "usersWithout2fa": 0 }
|
||||
```
|
||||
|
||||
Turn off: `ipalKit({ doctor: false })`. Adapt: `ipalKit({ doctor: { tokenVar: 'MY_TOKEN', access: ({ req }) => isAdmin(req.user, req.payload) } })` (a logged-in staff admin may read it too; the second factor is checked for you — never test `req.user.roles` by hand, an account of another collection can carry the same value)
|
||||
@@ -99,6 +99,11 @@ Turn off: `ipalKit({ doctor: false })`. Adapt: `ipalKit({ doctor: { tokenVar: 'M
|
||||
| | `powered-by` | error | `withSecurityConfig`; live: no `X-Powered-By` on `/` and the admin |
|
||||
| | `csp` | warning / info | CSP on the site and the admin; report-only is info, a warning after 4 weeks (`seen`) |
|
||||
| | `2fa` | error | `twoFactor: { plugin: payloadTotp }` + the package; deep: 0 users without TOTP (the message says how many of them are blocked because their setup window has passed); error: a Postgres / SQLite project whose migrations do not mention the 2FA column `totp_setup_from` (every login would answer 500; a warning when there is no migrations folder — the doctor cannot see a schema that gets there another way); warning: `twoFactor.requireSetup: false`; info: no setup window (`windowHours: false`) |
|
||||
| | `access-missing` | warning | `ipalKit` has an `access` option — without it there are no roles and every panel account is an admin |
|
||||
| | `csrf-empty` | warning | the config sets `serverURL` or `csrf` — otherwise Payload accepts the login cookie from any origin |
|
||||
| | `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) |
|
||||
| | `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 a day |
|
||||
| | `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) |
|
||||
| admin | `admin-meta` | warning | ipal-kit ≥ 1.14.5, no `adminMeta: false` / `agency: false`; live: the admin `og:image` is `/api/ipal/admin-og` |
|
||||
| | `admin-noindex` | error | (live) the admin login page is noindex |
|
||||
|
||||
+1
-1
@@ -227,7 +227,7 @@ the File field shows "The file … was refused: …", nothing is stored or sent.
|
||||
| `notice` | built-in text | the "not checked for viruses" line in the e-mail: `false` = none, a string or `(locale) => string` = your own |
|
||||
| `maxConcurrent` | `2` | file submissions handled at once per instance (each holds its files in memory); more get the "too many attempts" message; `0` = no guard |
|
||||
| `path` | `'/ipal/forms/submit'` | endpoint path under the API route |
|
||||
| `submit` | `{}` | the endpoint's gates, same meaning as in `createSubmitAction`: `maxPerMinute`, `clientIp`, `honeypotField`, `turnstileHostnames`, `turnstileOnConfigError`; `allowedOrigins` (other origins allowed to post, e.g. a front end on another domain); `idleTimeoutMs` (default `30000`: no byte of the upload for this long → the request is given up, `0` = off) and `timeoutMs` (default `300000`: ceiling for the whole request, `0` = off) |
|
||||
| `submit` | `{}` | the endpoint's gates, same meaning as in `createSubmitAction`: `maxPerMinute`, `clientIp`, `honeypotField`, `turnstileHostnames`, `turnstileOnConfigError`; `allowedOrigins` (other origins allowed to post, e.g. a front end on another domain); `idleTimeoutMs` (default `30000`: no byte of the upload for this long → the request is given up, `0` = off) and `timeoutMs` (default `300000`: ceiling for the whole request, `0` = off) **While Turnstile cannot check (wrong or missing secret, Cloudflare down) this endpoint refuses the submission by default** — `forms.turnstileOnConfigError: { files: 'allow' }` or `submit.turnstileOnConfigError: 'allow'` changes it (turnstile.md) |
|
||||
|
||||
Built-in types (`FORM_FILE_TYPES`): PDF, DOC, DOCX, ODT, RTF, XLS, XLSX, JPG, PNG, WebP. A new field has PDF, DOC and
|
||||
DOCX ticked.
|
||||
|
||||
+69
-2
@@ -546,8 +546,24 @@ counts attempts per account on `POST /api/verify-totp`: by default the **sixth a
|
||||
right or wrong — is refused with `429` and `Retry-After`, and a line goes to the log. Only a session that already
|
||||
passed the password reaches the endpoint, so nobody without the password can lock an account's owner out; someone
|
||||
who has the password can delay the owner's login by ten minutes at a time (and that shows in the log). Counted in
|
||||
memory per server instance. `verifyLimit: { max: 10, windowMinutes: 5 }` changes it, `verifyLimit: false` turns
|
||||
it off (a limiter in front of the site).
|
||||
memory per server instance **and in the database** (Payload's key-value store, `payload.kv` — the `payload-kv`
|
||||
collection Payload itself adds; no new collection): a restart, a redeploy or a second instance does not hand out
|
||||
new attempts. The higher of the two counts decides; when the database part fails, the memory count still does
|
||||
(there is no "allow when the store fails" path). `verifyLimit: { max: 10, windowMinutes: 5 }` changes it,
|
||||
`{ store: 'memory' }` keeps the count in this instance only, `verifyLimit: false` turns it off (a limiter in
|
||||
front of the site).
|
||||
|
||||
**Verify and setup attempts only from the site's own origin** (`twoFactor.sameOrigin`). The limit counts every
|
||||
attempt of an account, so a page that can make the browser send the account's login cookie could burn the
|
||||
owner's attempts and lock them out — no password needed. A sibling subdomain is such a page (`SameSite=Lax` does
|
||||
not stop it, and Payload's own `csrf` list is empty unless `serverURL` or `csrf` is set). So
|
||||
`POST /api/verify-totp` and `POST /api/setup-totp` refuse (`403`) a request that the browser marks as coming from
|
||||
elsewhere — the `Origin` header, else `Sec-Fetch-Site` — **before it is counted**. Own origins: the host the
|
||||
request came in on (`Host`, `X-Forwarded-Host`), `serverURL`, Payload's `csrf` and `cors` lists, and
|
||||
`twoFactor: { …, sameOrigin: { origins: ['https://app.example.com'] } }` for a front end on another domain.
|
||||
A request with neither header (a script, `curl`, a server) passes: it cannot ride on somebody's cookie.
|
||||
`sameOrigin: false` turns it off. `ipal-doctor` warns (`csrf-empty`) when the config sets neither `serverURL` nor
|
||||
`csrf` — Payload then accepts the login cookie from any origin.
|
||||
|
||||
**What is NOT covered — the complete list.** (1) Anonymous requests: the access function decides. (2) Accounts
|
||||
of other auth collections: 2FA is about one collection; such an account is not staff unless its collection is in
|
||||
@@ -901,8 +917,59 @@ size while reading, content signature, container and macro checks, an optional `
|
||||
Emails tab (recipients, BCC) is readable only by `editor+`.
|
||||
- Full table: [access.md](./access.md#what-the-plugin-locks-down-by-itself).
|
||||
|
||||
## Stored secrets (`secrets.writeOnly`)
|
||||
|
||||
`smtpPassword` and `turnstileSecretKey` live in the Site integrations global: **the panel is their source**
|
||||
(there is no env variable for the SMTP password, and the env fallback for the Turnstile secret is deprecated —
|
||||
[turnstile.md](./turnstile.md)). They are **write-only**:
|
||||
|
||||
| Who reads | Gets |
|
||||
|---|---|
|
||||
| REST (`GET /api/globals/site-integrations`), GraphQL, the panel's form, versions — anything through access control, an admin included | `'********'` when a value is stored (`SECRET_MASK`), the empty value when none is |
|
||||
| Server code through the Local API with access control off (the default of `payload.findGlobal`) — the mail adapter, the Turnstile check, your own server code | the real value |
|
||||
| The Local API **with** access control (`overrideAccess: false` and a `user`) | `'********'` |
|
||||
|
||||
| A save sends | Result |
|
||||
|---|---|
|
||||
| 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 |
|
||||
|
||||
In the panel the field says "A value is set. It is not shown; type a new one to replace it." and offers "Remove
|
||||
the stored value". A stolen admin session, or any way past the global's read rule, no longer yields a working
|
||||
mailbox password. What it does **not** protect: the database and its backups hold the value in plain text
|
||||
(encryption at rest is a separate, open question), and whoever can change the config or run server code can
|
||||
read it.
|
||||
|
||||
- **What an existing site sees after the upgrade:** nothing to do. The stored values stay; the panel shows "a
|
||||
value is set"; the API returns the mask. Code of your own that read the secret over REST / GraphQL as an admin
|
||||
must read it on the server with the Local API instead.
|
||||
- **Off:** `ipalKit({ secrets: { writeOnly: false } })` — the value is returned to whoever may read the global.
|
||||
- **Your own secret fields:** `writeOnlySecret({ name: 'apiToken', type: 'text', admin: { components: { Field:
|
||||
'@intecion/ipal-kit/admin#MaskedField' } } })`, or `writeOnlySecrets(fields, ['apiToken'])` for fields inside
|
||||
tabs / rows / groups; the hooks `maskSecretAfterRead` / `keepSecretBeforeValidate`, `SECRET_MASK`,
|
||||
`SECRET_CLEAR`, `isSecretMask`, `INTEGRATION_SECRET_FIELDS` are exported. A real secret equal to `********` or
|
||||
`[[clear]]` cannot be stored.
|
||||
- **Check:** as a fully signed-in admin, `GET /api/globals/site-integrations` → `"smtpPassword":"********"`; save
|
||||
the form without touching the field → a test e-mail still goes out.
|
||||
|
||||
## Dashboard alerts by role (`dashboardAlerts`)
|
||||
|
||||
The plugin's dashboard alerts read data that only some roles may read (with access control off, on the server),
|
||||
so each decides who sees it. **Integration alerts** (Site integrations is admin-only): an admin sees what is
|
||||
failing and the link; an editor sees "An integration needs attention. Ask an administrator to look at it."; anyone
|
||||
else sees nothing. **Cookie alerts** (crawl result, cookies waiting): editors and above. A session that still owes
|
||||
its second factor sees none of them. `ipalKit({ dashboardAlerts: { integrations: 'editor' | 'all', cookies: 'all' } })`
|
||||
loosens it (`'all'` = everyone who opens the dashboard, as before); the components take the same as props
|
||||
(`details`, `audience`).
|
||||
|
||||
## Turn off, override, extend
|
||||
|
||||
- **Stored secrets:** `secrets: { writeOnly: false }`; `writeOnlySecret` / `writeOnlySecrets` for your own fields.
|
||||
- **2FA attempts from another origin:** `twoFactor.sameOrigin: false`, or `{ origins: [...] }`; `requestFromOwnOrigin`,
|
||||
`ownOrigins` are exported. **Verify count:** `verifyLimit: { store: 'memory' }`; `buildVerifyLimit`,
|
||||
`verifyLimitKey`, `clearVerifyLimits` (tests) are exported.
|
||||
- **Dashboard alerts:** `dashboardAlerts: { integrations, cookies }`.
|
||||
- **Verify limit:** `twoFactor.verifyLimit: { max, windowMinutes }`, or `false`.
|
||||
- **`back` link check of the 2FA screens:** `twoFactor.safeBack: false`, or a function as your own rule;
|
||||
`safeAdminBack`, `wrapTotpViews`, `copyViews`, `changedViewKeys`, `SAFE_TOTP_VIEW`, `SafeTotpView` are exported.
|
||||
|
||||
+43
-12
@@ -6,9 +6,17 @@ reads the secret server-side.
|
||||
|
||||
## Config
|
||||
|
||||
No options — the `turnstileSiteKey` / `turnstileSecretKey` fields are in
|
||||
SiteIntegrations (Spam protection tab). The editor enters the keys in the panel (env fallback:
|
||||
`NEXT_PUBLIC_TURNSTILE_SITE_KEY` / `TURNSTILE_SECRET_KEY`).
|
||||
The `turnstileSiteKey` / `turnstileSecretKey` fields are in SiteIntegrations (Spam protection tab): **the
|
||||
panel is the source of the keys.** The secret key is write-only there — the panel and the API show "a value is
|
||||
set", never the value ([security.md](./security.md) "Stored secrets"). Env fallback for the public site key:
|
||||
`NEXT_PUBLIC_TURNSTILE_SITE_KEY`.
|
||||
|
||||
> **Deprecated: `TURNSTILE_SECRET_KEY` from the environment.** It still works when the panel field is empty,
|
||||
> and will be removed in a later release that the changelog names in advance. A site that relies on it logs
|
||||
> `[ipal] Deprecated: the Turnstile secret key comes from the TURNSTILE_SECRET_KEY environment variable…` once
|
||||
> per start, and `ipal-doctor --url` reports it (`turnstile-env-key`). **Move it:** copy the key into Site
|
||||
> integrations → Spam protection → Secret key, send a test form, then remove the variable from the environment
|
||||
> (Coolify). Local development with Cloudflare's test keys in `.env` keeps working until the removal.
|
||||
|
||||
**On = both keys set.** Then the widget shows, and `submitForm`
|
||||
**requires** a valid token: a missing token is a rejection, so a bot cannot skip
|
||||
@@ -60,8 +68,8 @@ if (!ok) {
|
||||
```
|
||||
|
||||
`verifyTurnstile` reads the secret from SiteIntegrations (Local API), and when the field is
|
||||
empty — from the **`TURNSTILE_SECRET_KEY`** variable (the same one
|
||||
`ipalEnvRules({ turnstile: true })` requires). It returns `true` for `pass`, `false` for `reject`,
|
||||
empty — from the **`TURNSTILE_SECRET_KEY`** variable (deprecated, see Config; the same one
|
||||
`ipalEnvRules({ turnstile: true })` names). It returns `true` for `pass`, `false` for `reject`,
|
||||
and for `degraded` (a problem on our side, see below) — depending on
|
||||
`onConfigError`: **by default `'allow'` → `true`**, `'reject'` → `false`. No token
|
||||
→ `false`. Every result other than `pass` is **logged** in the server logs:
|
||||
@@ -86,11 +94,29 @@ and for `degraded` (a problem on our side, see below) — depending on
|
||||
|---|---|---|
|
||||
| `pass` | valid token | accepts |
|
||||
| `reject` | bad token from the **visitor**: `invalid-input-response`, `timeout-or-duplicate`, no token | **rejects** (`reason: 'turnstile'`) |
|
||||
| `degraded` | an error **on our side**: no secret, `invalid-input-secret` / `missing-input-secret`, Cloudflare unreachable / 5xx / `internal-error` / unexpected response | **accepts** (`turnstileOnConfigError: 'allow'`) — rate limit, honeypot and validation still work |
|
||||
| `degraded` | an error **on our side**: no secret, `invalid-input-secret` / `missing-input-secret`, Cloudflare unreachable / 5xx / `internal-error` / unexpected response | a **text form accepts** (`'allow'`) — rate limit, honeypot and validation still work; a **form with files** (the file endpoint) **rejects** (`'reject'`) |
|
||||
|
||||
> Note: with the default `'allow'`, a wrong secret in the panel (`invalid-input-secret`)
|
||||
**`forms.turnstileOnConfigError`** sets what `degraded` means, once for the project:
|
||||
|
||||
```ts
|
||||
ipalKit({ forms: {
|
||||
// turnstileOnConfigError: 'reject', // every form fails closed
|
||||
// turnstileOnConfigError: 'allow', // every form keeps working, forms with files too
|
||||
// turnstileOnConfigError: { text: 'allow', files: 'allow' }, // per kind
|
||||
} })
|
||||
```
|
||||
|
||||
Default `{ text: 'allow', files: 'reject' }`: an enquiry matters more than spam, but an accepted bot submission
|
||||
with a file puts an attachment into a mailbox. A value at a call site (`turnstileOnConfigError` in
|
||||
`createSubmitAction` / `submitForm`, `attachments.submit.turnstileOnConfigError`) still wins. Not involved while
|
||||
Turnstile is off (no keys). **What an existing site sees:** nothing while Turnstile works; while it is degraded,
|
||||
forms with a File field answer "verification failed" instead of sending — fix the keys (the dashboard alert and
|
||||
`ipal-doctor --url`, rule `turnstile-degraded`, say so), or set `{ files: 'allow' }`.
|
||||
|
||||
> Note: where the policy is `'allow'`, a wrong secret in the panel (`invalid-input-secret`)
|
||||
> means forms accept submissions **without effective verification** —
|
||||
> visible only as an alert in the panel and in the log. `submitForm` checks Turnstile only
|
||||
> visible as an alert in the panel, in the log, and in `ipal-doctor --url` (`turnstile-degraded`: a warning,
|
||||
> an error after a day). `submitForm` checks Turnstile only
|
||||
> when both keys are set (`getTurnstileConfig().enabled`); then a missing token
|
||||
> always → `reason: 'turnstile'`.
|
||||
|
||||
@@ -123,7 +149,8 @@ above), then whether the secret is in the database — in Coolify open the Mongo
|
||||
`mongosh <db> --eval 'db.globals.findOne({globalType:"site-integrations"}, {turnstileSecretKey:1})'`
|
||||
(the Mongo adapter keeps all globals in the `globals` collection).
|
||||
Do not write the secret from code (`updateGlobal` in `onInit` / an action) — it overwrites the panel on
|
||||
every start; if you prefer env, set `TURNSTILE_SECRET_KEY` and leave the field empty. `server-only` guarantees it never
|
||||
every start (the env variable `TURNSTILE_SECRET_KEY` with an empty field still works but is deprecated: the
|
||||
panel is the source). `server-only` guarantees it never
|
||||
reaches the browser bundle.
|
||||
|
||||
> In forms you usually do not call `verifyTurnstile` directly —
|
||||
@@ -225,9 +252,13 @@ full control or have an unusual case. The provider is a convenience layer over i
|
||||
|
||||
- **Turn off:** leave both keys empty (panel and env) → no widget, `submitForm` skips the check.
|
||||
The Turnstile fields in Site integrations are currently always added.
|
||||
- **Fail closed:** `turnstileOnConfigError: 'reject'` in `submitForm` / `createSubmitAction`
|
||||
(or `onConfigError: 'reject'` in `verifyTurnstile`).
|
||||
- **Keys:** the panel wins; empty field → env `NEXT_PUBLIC_TURNSTILE_SITE_KEY` / `TURNSTILE_SECRET_KEY`.
|
||||
- **Fail closed / open:** `forms.turnstileOnConfigError` for the project (`'reject'`, `'allow'`, or
|
||||
`{ text, files }`); `turnstileOnConfigError` in `submitForm` / `createSubmitAction` /
|
||||
`attachments.submit` for one call site (or `onConfigError` in `verifyTurnstile`). From `/server`:
|
||||
`passTurnstile`, `passSubmitGates`, `resolveTurnstileOnConfigError`, `TURNSTILE_ON_CONFIG_ERROR_DEFAULT`.
|
||||
- **Keys:** the panel is the source; empty site key → env `NEXT_PUBLIC_TURNSTILE_SITE_KEY`; empty secret →
|
||||
env `TURNSTILE_SECRET_KEY` (**deprecated**, see Config). `turnstileSecretFromEnv(integrations)` and
|
||||
`TURNSTILE_SECRET_ENV` are exported.
|
||||
- **Access to the keys:** Site integrations is admin-only (read and update); change it with
|
||||
`ipalKit({ globalOverrides: { 'site-integrations': { access: … } } })` — keep `read` restricted, the secret lives there.
|
||||
- **Look:** `theme` on `<Turnstile>` / `<TurnstileWidget theme>`, `turnstileTheme` in `RenderForm` / `BuilderForm`.
|
||||
|
||||
@@ -100,6 +100,16 @@ through this procedure. Ask only when you are missing something you cannot get y
|
||||
| emails are not sent | no `email: mailAdapter()` / empty transport / empty Emails tab | email.md; Send test in the panel |
|
||||
| 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` |
|
||||
| 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 |
|
||||
| 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 |
|
||||
|
||||
### Environment
|
||||
|
||||
@@ -50,7 +50,7 @@ Existing client sites are not gated on it; run it there as a report only.
|
||||
## The status endpoint
|
||||
|
||||
`GET /api/ipal/doctor` is added by `ipalKit` and answers 404 until the site has `IPAL_DOCTOR_TOKEN` (≥ 32 characters).
|
||||
Then `Authorization: Bearer <token>`; counts only (`usersWithout2fa`, `usersSetupClosed` = of those, blocked because the 2FA setup window has passed, `pendingCookies`, `plugin`, `node`). With the same
|
||||
Then `Authorization: Bearer <token>`; counts and states only (`usersWithout2fa`, `usersSetupClosed` = of those, blocked because the 2FA setup window has passed, `pendingCookies`, `openSignUp` = slugs of auth collections with open sign-up, `turnstile` = the recorded state of the Turnstile check, `turnstileSecretFromEnv`, `plugin`, `node`) — never a key or a name. With the same
|
||||
`IPAL_DOCTOR_TOKEN` in the doctor's environment, `--url` reads it. Off: `ipalKit({ doctor: false })`; adapt:
|
||||
`ipalKit({ doctor: { tokenVar, access } })`.
|
||||
|
||||
|
||||
@@ -31,6 +31,13 @@ description: Complete map of everything @intecion/ipal-kit provides — every ip
|
||||
| `access.authAccess` | `{ create: adminOnly, delete: adminOnly, read: adminOrSelfIn(slug), unlock: adminOnly, update: adminOrSelfIn(slug) }` | access of the auth collection the plugin **injects** (Payload's default lets any logged-in account edit or delete every other account) | your keys win, e.g. `{ read: authenticated }`; your own collection with that slug wins whole (give it `adminOrSelf` / `adminOnly` yourself) |
|
||||
| `access.firstUserAdmin` | `true` | the account made on Payload's "Create first user" screen (`/first-register` on an empty collection) gets `roles: ['admin']`; an open sign-up still gets `defaultRole` | `false` = that account gets what was submitted |
|
||||
| `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.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) |
|
||||
| `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 | — |
|
||||
@@ -41,7 +48,8 @@ description: Complete map of everything @intecion/ipal-kit provides — every ip
|
||||
| `twoFactor.importMapCheck` | on | production only: at start searches the `importMap.js` on disk (where Payload looks for it) for `@intecion/ipal-kit/admin#SafeTotpView`; when not found, logs `[ipal] The admin import map may be out of date …` and ipal-kit's `TotpRedirectProvider` puts the notice "Two-step verification may not be available" above the 2FA screens (never instead of them). A hint only — the map in the build can differ from the file on disk (Dockerfile runner stage, re-exporting map); a file that is not found is not reported | `false` = no file read, log line or notice |
|
||||
| `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 }` | 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`; in memory per instance | `{ max, windowMinutes }`; `false` = no limit |
|
||||
| `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.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 |
|
||||
@@ -77,6 +85,7 @@ description: Complete map of everything @intecion/ipal-kit provides — every ip
|
||||
| `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 |
|
||||
| `forms.turnstileOnConfigError` | `{ text: 'allow', files: 'reject' }` | what a form does while Turnstile CANNOT check (wrong / missing secret, Cloudflare down): a text form is accepted, a submission to the file endpoint is refused. Not involved while Turnstile is off | `'allow'` / `'reject'` for every form, or `{ text, files }`; `turnstileOnConfigError` at a call site (`createSubmitAction`, `attachments.submit`) wins |
|
||||
| `forms.attachments` | off | **File** field in the form builder; a file is checked (size, count, type by content, refused extensions), attached to the company e-mail and dropped — **never stored**; adds `POST /api/ipal/forms/submit`, the fields `submissionFiles` / `filesDelivery` / `filesDeliveryNote` / `attemptKey` on `form-submissions`, and the **Files** texts in Form messages | `true` / `FormAttachmentsOption`: `maxSizeMB` (10), `maxTotalMB`, `maxFiles` (3), `fileTypes`, `allowRisky`, `scan` (antivirus hook — none built in), `strictPdf`, `notice`, `maxConcurrent` (2), `path`, `submit` (`maxPerMinute`, `clientIp`, `honeypotField`, `turnstileHostnames`, `turnstileOnConfigError`, `allowedOrigins`, `idleTimeoutMs`, `timeoutMs`); block only: `forms.fields.file: false` or `buildFileBlock(…)`. Postgres: `migrate:create`. Check: submit a PDF → attached to the company e-mail, absent from the customer e-mail, submission shows *File delivery: Handed to the mail server* (forms.md "Files") |
|
||||
| `forms.consentFieldName` | `'consent'` | name of the GDPR consent field `submitForm` requires (read from `config.custom.ipal`) | `createSubmitAction({ consentFieldName })` / `submitForm` argument wins |
|
||||
| `consentLog` | off | `consent-records` collection + `POST /api/ipal/consent` (rate limit 20/min) | `true` / `{ retentionDays }` (default 1095) |
|
||||
|
||||
@@ -20,7 +20,7 @@ Admin panel components from `@intecion/ipal-kit/admin` — the project does NOT
|
||||
|
||||
| Export | Import from | What it does / when |
|
||||
|---|---|---|
|
||||
| `MaskedField` | `@intecion/ipal-kit/admin` | Masked text field (••••, Reveal button) for secrets in SiteIntegrations (SMTP password, R2 key, Turnstile secret) — masking in the UI only, not encryption. Injected by the plugin; you can also wire it to your own `text` field via `admin.components.Field`, then `pnpm generate:importmap`. |
|
||||
| `MaskedField` | `@intecion/ipal-kit/admin` | Text input for a secret. With a write-only field (`writeOnlySecret`, the default for the plugin's SMTP password and Turnstile secret) the value never reaches the browser: the input stays empty, says "A value is set", typing replaces it, "Remove the stored value" clears it on save. With a plain text field the value arrives and is drawn as dots with Show / Hide. Injected by the plugin; you can also wire it to your own `text` field via `admin.components.Field`, then `pnpm generate:importmap`. |
|
||||
| `TestEmailButton` | `@intecion/ipal-kit/admin` | "Send test e-mail" button in the SiteIntegrations e-mail tab — POST `/api/ipal/test-email` through the selected transport (SMTP/Graph), shows the result/error. Injected by the plugin — do not call. |
|
||||
| `RowLabel` | `@intecion/ipal-kit/admin` | Array row title in the panel taken from the row content (e.g. "Fast delivery" instead of "Item 01"). Do not wire by hand — use `rowLabel()`; after adding, `pnpm generate:importmap`. |
|
||||
| `AdminLogo` | `@intecion/ipal-kit/admin` | Server Component: large panel logo (login screen) from SiteSettings `logo`, fallback `siteName`. Injected by the plugin with `whiteLabel`; after turning the option on, `pnpm generate:importmap`. |
|
||||
@@ -66,13 +66,20 @@ Admin panel components from `@intecion/ipal-kit/admin` — the project does NOT
|
||||
| `hasMinimumRole(user, minimum, source?)` | `@intecion/ipal-kit`; in client components `@intecion/ipal-kit/client` | Predicate → `boolean`: the user is an account of a **staff collection** and has a role ≥ `minimum` (reads `user.roles` and `user.collection` safely). A role on an account of another auth collection never counts. `source` says which collections are staff: `req.payload` on the server, the config from `useConfig()` in a client component (it has `admin.user` only; for `access.staffCollections` pass the list), or `{ staffCollections: ['users'] }` (middleware). Without it: the staff collections of the config ipalKit built in this process (two different configs: only what both call staff) — and **`false` where there is none** (browser bundle, middleware, edge). Does not check the second factor. |
|
||||
| `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. |
|
||||
| `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. |
|
||||
| `staffCollectionSlugs(source?)` | `@intecion/ipal-kit` | `string[]`: the staff collections — `admin.user`, `access.authCollection` and `access.staffCollections` — from `req.payload`, a config or `{ staffCollections }`; without an argument what the configs built in this process agree on (`[]` when there is none). Roles and staff checks count only for accounts of these. |
|
||||
| `ROLE_HIERARCHY` | `@intecion/ipal-kit` | Constant `['user', 'editor', 'admin']` (lowest first) — a higher role meets the requirements of a lower one. The plugin injects the `roles` field into the auth collection (`access.authCollection`). |
|
||||
| `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:** `VerifyLimitOptions` (`twoFactor.verifyLimit`: `{ max?, windowMinutes? }`), `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`, `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`).
|
||||
|
||||
## Accessibility — widget (`accessibility`) — details: `node_modules/@intecion/ipal-kit/docs/accessibility.md`
|
||||
|
||||
@@ -370,7 +377,7 @@ Full option lists of `createContentHelpers` / `createPageRoute` / `SiteProviders
|
||||
| `recordIntegrationStatus(payload, field, previous, { state, code?, message? })` | `@intecion/ipal-kit` | saves the state of your own integration in Site integrations (only on change / every 10 min); does not throw. For e-mail and Turnstile the plugin calls it itself — do not call |
|
||||
| `buildIntegrationStatusField(name)` | `@intecion/ipal-kit` | hidden status group field (`state`, `code`, `message`, `since`, `checkedAt`) for `integrationsFields` |
|
||||
| `buildIntegrationStatusBanner(statusField, label, texts?)` | `@intecion/ipal-kit` | UI field with a status banner on the integration tab (`label` string or `{ en, pl }`; `texts` = `{ failing, hint }` keys of your own `ipal` translations) (`integrationsFields`; then `pnpm generate:importmap`) |
|
||||
| `IntegrationAlerts` | `@intecion/ipal-kit/admin` | dashboard alert about integrations in the `degraded` state; always injected by the plugin (`beforeDashboard`); your own integrations: a second instance with `checks` |
|
||||
| `IntegrationAlerts` | `@intecion/ipal-kit/admin` | dashboard alert about integrations in the `degraded` state; always injected by the plugin (`beforeDashboard`); your own integrations: a second instance with `checks`. By role: the detail (error text, link) for `details` and above (`'admin'` default, `'editor'`, `'all'`), a neutral "ask an administrator" for editors below it, nothing for others or for a session that owes its second factor (`dashboardAlerts.integrations`). `CookieCrawlAlert` takes `audience: 'editor' \| 'all'` the same way |
|
||||
| `IntegrationStatusBanner` | `@intecion/ipal-kit/admin` | status banner on the tab; injected by the plugin / `buildIntegrationStatusBanner` through the import map (`pnpm generate:importmap`), the project does not import it |
|
||||
|
||||
**Types:** `IntegrationState` (`'ok' | 'degraded'`), `IntegrationStatus` — integration state and saved status; `IntegrationLabel` (`string | { en, pl }`) — banner / alert label; `IntegrationBannerTexts` (`{ failing, hint }` text keys) — third argument of `buildIntegrationStatusBanner` for your own wording.
|
||||
@@ -855,6 +862,7 @@ Bin: `ipal-doctor` (`pnpm exec ipal-doctor [dir] [--json] [--md] [--strict] [--f
|
||||
| `useOptionalTurnstile()` | `@intecion/ipal-kit/client` | Like `useTurnstile`, but without a provider it returns `enabled: false` instead of throwing — for shared components. |
|
||||
| `Turnstile({ siteKey, onToken, theme? })` | `@intecion/ipal-kit/client` | Raw widget with an explicit key — when you do not use the provider. |
|
||||
| `verifyTurnstile({ token, payload, ip?, onConfigError?, hostnames? })` | `@intecion/ipal-kit/server` | Server-side token verification → `boolean` (`degraded` lets it through by default; `hostnames` = token must be solved on one of them, unset = not checked). `submitForm` does this itself — call it only in your own actions. |
|
||||
| `passTurnstile({ payload, turnstileToken, turnstileKind?, turnstileOnConfigError?, … })`, `passSubmitGates(…)`, `resolveTurnstileOnConfigError(payload, kind?, explicit?)`, `TURNSTILE_ON_CONFIG_ERROR_DEFAULT` | `@intecion/ipal-kit/server` | The Turnstile gate of a form (`null` = passed, else `{ success: false, reason: 'turnstile' }`) and the rate limit + Turnstile pair; the policy for a `degraded` check: the call-site value, else `forms.turnstileOnConfigError`, else the default for the kind (`{ text: 'allow', files: 'reject' }`). |
|
||||
| `checkTurnstile({ token, payload, ip? })` | `@intecion/ipal-kit/server` | As above, but returns `{ outcome: 'pass' \| 'reject' \| 'degraded', code? }` and updates the integration status in the panel. |
|
||||
|
||||
**Types:** `TurnstileConfig` (root) — `getTurnstileConfig` result; `TurnstileCheck`, `TurnstileOutcome` (`/server`) — verification result; `TurnstileProps`, `TurnstileTheme` (`/client`) — widget props and theme.
|
||||
|
||||
@@ -198,7 +198,7 @@ export default buildConfig({
|
||||
`.env.example` (no values, in the repo): `DATABASE_URI`, `PAYLOAD_SECRET`, `NEXT_PUBLIC_SERVER_URL`, `R2_BUCKET`,
|
||||
`R2_ENDPOINT`, `R2_ACCESS_KEY_ID`, `R2_SECRET_ACCESS_KEY`, `R2_PUBLIC_URL` (empty = media through the app — the default), `IPAL_IP_HEADER` (`cf-connecting-ip`
|
||||
behind Cloudflare, `x-forwarded-for` behind a plain proxy), `IPAL_NOINDEX` (empty; `1` on staging only), `INDEXNOW_KEY`,
|
||||
`NEXT_PUBLIC_TURNSTILE_SITE_KEY`, `TURNSTILE_SECRET_KEY` (panel fallback), with Graph `GRAPH_TENANT_ID`,
|
||||
`NEXT_PUBLIC_TURNSTILE_SITE_KEY`, `TURNSTILE_SECRET_KEY` (deprecated fallback — production keys go into the panel), with Graph `GRAPH_TENANT_ID`,
|
||||
`GRAPH_CLIENT_ID`, `GRAPH_CLIENT_SECRET`, `GRAPH_SENDER`. Local `.env` with `PAYLOAD_SECRET` ≥ 32 characters (in production `ipalEnvRules` refuses a shorter one; `secretMinLength` changes it).
|
||||
One language: one entry in `locales`, no `[locale]` folder (i18n.md).
|
||||
|
||||
@@ -247,6 +247,19 @@ the panel shows Site settings, Site integrations, Cookies, Form messages, the Fo
|
||||
sessions and needs the admin's own TOTP code (`twoFactor.resetAccess` changes who). Have two administrators
|
||||
with 2FA: when all are blocked, only a script or a redeploy helps (security.md "Every administrator is
|
||||
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".
|
||||
- **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.
|
||||
- **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
|
||||
accounts pass none of the plugin's checks and no role counts for them (not even their own `roles: ['admin']`);
|
||||
a field that grants rights is never writable at sign-up; use `adminOrSelfIn('<slug>')` in every auth collection; a second
|
||||
|
||||
@@ -423,6 +423,44 @@ site without steps 1–3 and a deploy day agreed with the owner. Steps 2, 3 and
|
||||
setup screen with "Set up two-step verification by …"; after the code it is in. As an administrator open that
|
||||
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).
|
||||
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
|
||||
`accounts: { panelRole: 'user' }`. The line `NOBODY can open the admin panel` (an error) means no account has
|
||||
the role: fix with a script (`payload.update({ collection: 'users', id, data: { roles: ['admin'] } })`,
|
||||
`pnpm payload run`) or `accounts: { panelRole: false }` + redeploy.
|
||||
3. **Secrets are write-only.** Nothing to do for a normal site: the SMTP password and Turnstile secret stay
|
||||
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").
|
||||
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
|
||||
test form, then remove the variable in Coolify. Do not do it on a client site without the owner. Nothing
|
||||
breaks if you wait; the removal will be announced in the changelog.
|
||||
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' }`.
|
||||
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.
|
||||
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.
|
||||
**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
|
||||
`"smtpPassword":"********"`; a test e-mail and a test form still work; an editor and an admin still log in.
|
||||
|
||||
## 2. Inventory (no code changes)
|
||||
**What changed for projects** between your old and new plugin version is exactly the reference site's diff —
|
||||
`git diff v<old> v<new> -- reference/` in the ipal-kit repo (or the two `docs/agent/reference-site/INDEX.md` files):
|
||||
|
||||
+5
-3
@@ -182,9 +182,11 @@ describe('M1 rules: access-missing, turnstile-degraded, turnstile-env-key', () =
|
||||
})
|
||||
|
||||
test('csrf-empty: without serverURL and csrf Payload takes the login cookie from any origin', async () => {
|
||||
expect(await run("export default buildConfig({ plugins: [ipalKit({ access: { authCollection: 'users' } })] })", ['csrf-empty'])).toEqual(['csrf-empty:warning'])
|
||||
expect(await run('export default buildConfig({ serverURL: process.env.NEXT_PUBLIC_SERVER_URL, plugins: [] })', ['csrf-empty'])).toEqual([])
|
||||
expect(await run("export default buildConfig({ csrf: ['https://site.example'], plugins: [] })", ['csrf-empty'])).toEqual([])
|
||||
// the word is spelled in two parts: test/testConfig.test.ts refuses test files that name Payload's config builder
|
||||
const build = (body: string) => `export default ${'build'}${'Config'}(${body})`
|
||||
expect(await run(build("{ plugins: [ipalKit({ access: { authCollection: 'users' } })] }"), ['csrf-empty'])).toEqual(['csrf-empty:warning'])
|
||||
expect(await run(build('{ serverURL: process.env.NEXT_PUBLIC_SERVER_URL, plugins: [] }'), ['csrf-empty'])).toEqual([])
|
||||
expect(await run(build("{ csrf: ['https://site.example'], plugins: [] }"), ['csrf-empty'])).toEqual([])
|
||||
expect(await run('// not a Payload config', ['csrf-empty'])).toEqual([])
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user