IAPL rename: docs, agent guide, skills, reference site and starter on the new names; changelog draft
- docs, AGENT.md, the 16 skills, PROGRAMISTA and README use the preferred names (scripted, same list of forms); past CHANGELOG entries and the proposals in docs/dev are not rewritten - AGENT.md: 'Names: IAPL and ipal-kit' — old name, new name, state in 1.x; what is not renamed; storageNames - iapl-upgrade '→ 1.17.0', PROGRAMISTA §6 item 72, CHANGELOG 1.17.0 (draft): nothing required - env.md, doctor.md (legacy-names, storage-names), stats.md, security.md, project-starter.md, iapl-reference, iapl-setup - skill scripts read ipal-audit-skip and IPAL_IP_HEADER too; audit rule ids stay what they were - reference site: iapl(), iapl-doctor.json, iapl-* skills, storageNames: 'iapl'; INDEX.md regenerated Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
425fac14fb
commit
b91984fbcd
+55
-53
@@ -61,7 +61,7 @@ export default withPayload(withSecurityConfig(nextConfig))
|
||||
| `csp` | `false` | `buildCsp` args → the CSP header (+ `Reporting-Endpoints` with `reportUri`) |
|
||||
| `additional` | `[]` | extra headers; the same key overrides (also the `csp` ones) |
|
||||
|
||||
With `IPAL_NOINDEX=1` (staging), `X-Robots-Tag: noindex, nofollow` is added to every response.
|
||||
With `IAPL_NOINDEX=1` (staging), `X-Robots-Tag: noindex, nofollow` is added to every response.
|
||||
|
||||
**Uploads:** `buildUploadSecurityHeaders({ collections = ['media'] })` returns `headers()` rules for
|
||||
`/api/<collection>/file/*` (sandbox, no scripts) — an SVG from local disk cannot run a script on the site's
|
||||
@@ -299,7 +299,7 @@ The plugin sets the path through the `adminRoute` option:
|
||||
|
||||
```ts
|
||||
// payload.config.ts
|
||||
ipalKit({
|
||||
iapl({
|
||||
i18n: i18nConfig,
|
||||
adminRoute: '/its', // panel at /its instead of /admin
|
||||
})
|
||||
@@ -345,7 +345,7 @@ addition to real safeguards, not a replacement for them.
|
||||
The plugin enforces two-factor authentication (TOTP) for ALL panel users —
|
||||
with no way to turn it off per user. Every project gets it automatically.
|
||||
It uses `@clocklimited/payload-2fa`, which wraps access control: TOTP is checked before access to DATA
|
||||
(REST, GraphQL), not only in the panel UI. On top of the package ipal-kit runs its own check, so the second
|
||||
(REST, GraphQL), not only in the panel UI. On top of the package IAPL runs its own check, so the second
|
||||
factor also covers what the package cannot see — see "What the second factor covers" below.
|
||||
|
||||
### Dependency
|
||||
@@ -362,14 +362,14 @@ ERR_PNPM_NO_MATCHING_VERSION.
|
||||
```ts
|
||||
import { payloadTotp } from '@clocklimited/payload-2fa'
|
||||
|
||||
ipalKit({
|
||||
iapl({
|
||||
i18n: i18nConfig,
|
||||
twoFactor: {
|
||||
issuer: 'Company Name', // shown in the authenticator app
|
||||
plugin: payloadTotp, // ← INJECT — see below why
|
||||
// collectionSlug: 'users', // default: the panel login collection (admin.user, else the first auth collection)
|
||||
// allowCollectionMismatch: true, // deliberate only: 2FA on a collection other than admin.user
|
||||
// guard: false, // NOT recommended: ipal-kit's own check off, the package's wrapper only
|
||||
// guard: false, // NOT recommended: IAPL's own check off, the package's wrapper only
|
||||
},
|
||||
})
|
||||
```
|
||||
@@ -395,15 +395,15 @@ logging in. There is no per-user "on/off" option.
|
||||
### What the second factor covers
|
||||
|
||||
The package wraps the `access` functions of the collections and globals that are in the config **at the moment
|
||||
it runs**. ipalKit runs it early, so the plugin's own globals and collections (Site settings, Site integrations,
|
||||
it runs**. iapl runs it early, so the plugin's own globals and collections (Site settings, Site integrations,
|
||||
Cookie banner, Notifications, forms, form submissions, consent records, cookie review, stats) and anything a
|
||||
plugin listed after `ipalKit` adds were not wrapped. **Up to 1.16.3 a staff password without the TOTP code
|
||||
therefore read and changed them over the API.** Since 1.16.4 ipal-kit closes that itself:
|
||||
plugin listed after `iapl` adds were not wrapped. **Up to 1.16.3 a staff password without the TOTP code
|
||||
therefore read and changed them over the API.** Since 1.16.4 IAPL closes that itself:
|
||||
|
||||
| Where | How |
|
||||
|---|---|
|
||||
| every collection and global in the config when ipalKit finishes | `access` wrapped with `requireSecondFactor` |
|
||||
| collections and globals added by plugins listed **after** ipalKit | wrapped in ipalKit's `onInit`; the log line `[ipal] 2FA also enforced on entities added after ipalKit: …` names them |
|
||||
| every collection and global in the config when iapl finishes | `access` wrapped with `requireSecondFactor` |
|
||||
| collections and globals added by plugins listed **after** iapl | wrapped in iapl's `onInit`; the log line `[iapl] 2FA also enforced on entities added after iapl: …` names them |
|
||||
| the same after a dev hot reload, or when Payload runs with `disableOnInit` | the instance's `config` is watched, so a swapped config is guarded the moment Payload assigns it (before any request or Local API call); as a second line an auth strategy that authenticates nobody (`ipal-second-factor-guard` on the 2FA collection) does the same at the start of every request |
|
||||
| the plugin's endpoints (`/api/ipal/test-email`, `cookie-scan`, `cookie-approval`, `cookie-crawl`, the `access` option of `/api/ipal/doctor`) | `userMeetsRole` and `secondFactorPassed` |
|
||||
| the 2FA package's own endpoints (`/api/setup-totp`, `/api/verify-totp`, `/api/remove-totp`, `/api/admin/reset-user-totp`, `/api/admin/remove-user-totp`, any a later version adds) | accounts of the 2FA collection only; everything except setup and verify also needs the second factor ("The 2FA package's endpoints" below) |
|
||||
@@ -449,7 +449,7 @@ authenticator at any time; with it, that is possible only in the first days of t
|
||||
| New account (also the first admin of a fresh site) | logs in → setup screen with the notice "Set up two-step verification by <date>…" → after the code, the panel |
|
||||
| Not set up within the window | login still works, every request answers 403, the setup screen says the time has passed and to ask an administrator |
|
||||
| Administrator reopens setup / resets a lost phone | the account's page in the panel → **Two-step verification** (sidebar) → "Reopen setup" / "Reset two-step verification"; or `POST /api/ipal/two-factor/reset` with `{ "userId": "…" }`. A new window starts |
|
||||
| Administrators' overview | a notice on the dashboard: accounts without two-step verification, and how many of them are blocked; `ipal-doctor --url` reports the same as an error |
|
||||
| Administrators' overview | a notice on the dashboard: accounts without two-step verification, and how many of them are blocked; `iapl-doctor --url` reports the same as an error |
|
||||
| API key (`auth.useAPIKey`) | passes, whatever the setup state |
|
||||
| Seeds, scripts, the Local API with `overrideAccess` (the default) | not affected |
|
||||
| Bearer-token routes (`/api/ipal/doctor`, the cookie-crawl callback), MCP | not affected (no user) |
|
||||
@@ -457,9 +457,9 @@ authenticator at any time; with it, that is possible only in the first days of t
|
||||
|
||||
**Accounts that existed before this mode** (an upgrade): their window starts at the **first start of the site
|
||||
after the upgrade**, not at their creation date, so nobody is blocked the moment a site upgrades. The server log
|
||||
says how many there are: `[ipal] 2FA: N existing account(s) without two-step verification. They have 72 h from
|
||||
says how many there are: `[iapl] 2FA: N existing account(s) without two-step verification. They have 72 h from
|
||||
now to set it up…`. From that moment they can only set TOTP up; after 72 hours they are blocked until an
|
||||
administrator reopens setup. **Before upgrading a live site, run `pnpm exec ipal-doctor --url <site>`** (accounts
|
||||
administrator reopens setup. **Before upgrading a live site, run `pnpm exec iapl-doctor --url <site>`** (accounts
|
||||
without 2FA) and have those accounts set TOTP up, or remove the ones nobody uses.
|
||||
|
||||
That starting moment is **written once**, on each such account (`totpSetupFrom`), by the start that first finds
|
||||
@@ -492,8 +492,8 @@ twoFactor: {
|
||||
have it applied **when the new container starts** — `prodMigrations` in the database adapter, or the start command `pnpm payload migrate && pnpm start` ([deployment.md §4.3](./deployment.md#43-database-migrations-postgres)). **Not Coolify's Pre-deployment command:** it runs in the old container, which does not have the new migration, so the new version would start without the column.
|
||||
Without the column every query on the 2FA collection fails: **every login answers 500 —
|
||||
administrators with 2FA included — and nobody can sign in to the panel** (the public site keeps working). The
|
||||
log says `[ipal] 2FA: the column for "totpSetupFrom" is missing … NOBODY CAN LOG IN …` at start;
|
||||
`ipal-doctor` reports a SQL project whose migrations do not mention `totp_setup_from` (error; a warning when
|
||||
log says `[iapl] 2FA: the column for "totpSetupFrom" is missing … NOBODY CAN LOG IN …` at start;
|
||||
`iapl-doctor` reports a SQL project whose migrations do not mention `totp_setup_from` (error; a warning when
|
||||
there is no migrations folder at all — it cannot see a schema that is pushed some other way). Recovery: run
|
||||
the migration; no data is lost.
|
||||
- **`exempt` must answer `true` or `false` at once.** It runs inside access checks, which cannot wait. An
|
||||
@@ -502,7 +502,7 @@ twoFactor: {
|
||||
works on its password alone, so give it the lowest role that does its job.
|
||||
- **`windowHours`** must be a number (0 or more) or `false`; anything else (`'24'`, `-1`) stops the site at start.
|
||||
- **Import map.** The status field and the dashboard notice are admin components: `pnpm payload
|
||||
generate:importmap` after upgrading (`TwoFactorStatusField`, `TwoFactorAlert`); `ipal-doctor` reports a map
|
||||
generate:importmap` after upgrading (`TwoFactorStatusField`, `TwoFactorAlert`); `iapl-doctor` reports a map
|
||||
that lacks them. Without them the panel has no "Reopen setup" button (the endpoint still works).
|
||||
- **Switch a part off:** `requireSetup: { dashboardNotice: false }` (the administrators' notice),
|
||||
`{ statusField: false }` (the status / reset control on the account; the endpoint stays),
|
||||
@@ -514,7 +514,7 @@ twoFactor: {
|
||||
`resolveRequireSetup`, `strictExempt`, `SETUP_FROM_FIELD`, `TWO_FACTOR_RESET_PATH`, `DEFAULT_SETUP_WINDOW_HOURS`.
|
||||
- **Per collection or global:** the opt-out below (`custom.ipal.secondFactor`) also lets an account without TOTP
|
||||
in, because it takes the entity out of the second-factor check altogether.
|
||||
- **Needs** ipal-kit's check (`twoFactor.guard`, on by default); with `guard: false` the mode is off.
|
||||
- **Needs** IAPL's check (`twoFactor.guard`, on by default); with `guard: false` the mode is off.
|
||||
- **Project code** that calls `payload.find({ …, user, overrideAccess: false })` with a user fetched by id: refused
|
||||
for every account of the 2FA collection now — before, only for accounts that had TOTP set up. Take the user from
|
||||
`payload.auth({ headers })`.
|
||||
@@ -541,7 +541,7 @@ account, hand over the password, and have the owner set 2FA up at once.**
|
||||
the panel. As an administrator open the account → "Two-step verification: Set up."
|
||||
|
||||
**Verify attempts are limited** (`twoFactor.verifyLimit`). The package checks the code and never counts tries;
|
||||
a six-digit code has about three right answers in a million, so whoever held the password could guess. ipalKit
|
||||
a six-digit code has about three right answers in a million, so whoever held the password could guess. iapl
|
||||
counts attempts per account on `POST /api/verify-totp`: by default the **sixth attempt within 10 minutes** —
|
||||
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
|
||||
@@ -550,7 +550,9 @@ memory per server instance **and in the database** (Payload's key-value store, `
|
||||
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
|
||||
`{ store: 'memory' }` keeps the count in this instance only, `{ keyPrefix }` names the count's key in
|
||||
`payload-kv` (`<keyPrefix>:2fa-verify:<collection>:<id>`; default `ipal`, and `iapl` on a site with
|
||||
`iapl({ storageNames: 'iapl' })` — one prefix per site, a change starts the running counts from zero once), `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
|
||||
@@ -568,10 +570,10 @@ A default port written out (`X-Forwarded-Host: site.example:443`) is the same ho
|
||||
**Behind a reverse proxy that hides the site's address** — it rewrites `Host` and sends no `X-Forwarded-Host`
|
||||
(nginx's plain `proxy_pass`; Traefik and Coolify keep `Host`) — and without `serverURL`, the server cannot know
|
||||
its own address: the site's own verify page is refused, and **nobody can enter a code**. It is not silent: the
|
||||
first refusal of every origin is logged, `[ipal] 2FA: a code from origin "https://…" was refused and not counted
|
||||
first refusal of every origin is logged, `[iapl] 2FA: a code from origin "https://…" was refused and not counted
|
||||
— it is not one of this site's own origins (…)`, with the three ways out: set `serverURL` (the right fix, it
|
||||
also fills Payload's `csrf` list), or `twoFactor: { sameOrigin: { origins: ['https://…'] } }`, or make the proxy
|
||||
send `X-Forwarded-Host` (`proxy_set_header Host $host;` in nginx). `reportRefusedOrigin` is the building block. `ipal-doctor` warns (`csrf-empty`) when the config sets neither `serverURL` nor
|
||||
send `X-Forwarded-Host` (`proxy_set_header Host $host;` in nginx). `reportRefusedOrigin` is the building block. `iapl-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
|
||||
@@ -588,9 +590,9 @@ cannot read is refused.
|
||||
e.g. a health record the panel reads before the code is entered), operation by operation:
|
||||
|
||||
```ts
|
||||
// the 2FA package's own key — it leaves the operation unwrapped, and so does ipal-kit
|
||||
// the 2FA package's own key — it leaves the operation unwrapped, and so does IAPL
|
||||
{ slug: 'notices', custom: { totp: { disableAccessWrapper: { read: true } } }, … }
|
||||
// ipal-kit's key — the same, and it also works for entities the package never sees
|
||||
// IAPL's key — the same, and it also works for entities the package never sees
|
||||
{ slug: 'notices', custom: { ipal: { secondFactor: { read: false } } }, … } // or secondFactor: false = every operation
|
||||
```
|
||||
|
||||
@@ -599,12 +601,12 @@ Operations: `create`, `delete`, `read`, `readVersions`, `unlock`, `update` (coll
|
||||
(`{ notifications: { custom: { ipal: { secondFactor: { read: false } } } } }`) — and note that the plugin's
|
||||
staff rules (`userMeetsRole`) ask for the second factor themselves, so also give that operation your own
|
||||
`access` function there. `disableAccessWrapper: true` passed to the package's factory turns all access
|
||||
wrapping off, ipal-kit's included; the endpoints stay guarded.
|
||||
wrapping off, IAPL's included; the endpoints stay guarded.
|
||||
|
||||
**The 2FA package's endpoints.** The package takes `req.user` from whatever auth collection it comes and then
|
||||
acts on the 2FA collection by id: `/api/setup-totp` writes the TOTP secret under the **caller's** id. With
|
||||
numeric ids (Postgres, SQLite) an account of another auth collection could therefore set the secret of the
|
||||
staff account that has the same id, and whoever knew that staff password then passed 2FA. ipalKit wraps every
|
||||
staff account that has the same id, and whoever knew that staff password then passed 2FA. iapl wraps every
|
||||
endpoint the package registers: a logged-in account of another collection gets `403`; remove and the admin
|
||||
reset / remove endpoints also need the second factor, so a password alone cannot reset TOTP and enrol again.
|
||||
This guard is on whenever 2FA is on, also with `twoFactor.guard: false`.
|
||||
@@ -628,11 +630,11 @@ handler: async (req) => {
|
||||
access: { read: requireSecondFactor(({ req }) => isAdmin(req.user, req.payload)) }
|
||||
```
|
||||
|
||||
**Fails closed.** At startup ipalKit checks that the injected 2FA plugin added what the check reads (the
|
||||
**Fails closed.** At startup iapl checks that the injected 2FA plugin added what the check reads (the
|
||||
`totpSecret` and `hasTotp` fields and the `totp` auth strategy on the 2FA collection). When it did not — a
|
||||
package version with another shape — startup stops with `[ipal] twoFactor: the injected 2FA plugin did not
|
||||
package version with another shape — startup stops with `[iapl] twoFactor: the injected 2FA plugin did not
|
||||
add …`. Tested with `@clocklimited/payload-2fa` 3.0.0-beta.1 and 3.0.0-beta.7 (the versions in between are not run in the plugin's tests). `twoFactor.guard: false` switches
|
||||
ipal-kit's check off and leaves the package's wrapper alone; the plugin's own data is then open to a password
|
||||
IAPL's check off and leaves the package's wrapper alone; the plugin's own data is then open to a password
|
||||
without the code again, so use it only to get a site started while the package is being sorted out.
|
||||
|
||||
**Check** (replace the address and the account):
|
||||
@@ -649,7 +651,7 @@ done
|
||||
### Import map (required)
|
||||
|
||||
The 2FA screens and the redirect to them are admin components. After adding `twoFactor`, and after every
|
||||
ipal-kit upgrade, run:
|
||||
IAPL upgrade, run:
|
||||
|
||||
```bash
|
||||
pnpm generate:importmap
|
||||
@@ -664,7 +666,7 @@ pnpm generate:importmap
|
||||
The setup and verify screens and the user field read their texts through Payload's i18n
|
||||
(`totpPlugin:*`), in the user's admin language (*Account → Language*; without a choice, the
|
||||
browser's language — an English browser sees English screens on a Polish site). The package's own texts are long and informal,
|
||||
so ipal-kit merges `TOTP_TEXTS` (English and Polish, per `docs/dev/admin-ux.md`) over them, e.g.
|
||||
so IAPL merges `TOTP_TEXTS` (English and Polish, per `docs/dev/admin-ux.md`) over them, e.g.
|
||||
"Two-step verification" / "Weryfikacja dwuetapowa", "Enter the 6-digit code from the app:" /
|
||||
"Wpisz 6-cyfrowy kod z aplikacji:". The browser tab reads "Weryfikacja dwuetapowa — <site> | Panel"
|
||||
(`TOTP_VIEW_TITLE` in the site's default language: Payload's view title is a plain string).
|
||||
@@ -680,7 +682,7 @@ so ipal-kit merges `TOTP_TEXTS` (English and Polish, per `docs/dev/admin-ux.md`)
|
||||
The package's own admin provider decides on the server where to send the user, from an `x-pathname`
|
||||
request header. Nothing sets that header on `/admin` (the `createProxy` matcher skips `/admin`), so up to
|
||||
1.14.1 a user without TOTP was sent to `/admin/setup-totp?back=null`, and the setup screen redirected
|
||||
to itself forever. Since 1.14.2, ipal-kit swaps in its own provider,
|
||||
to itself forever. Since 1.14.2, IAPL swaps in its own provider,
|
||||
`TotpRedirectProvider`: it reads the path in the browser, never redirects away from the setup or verify
|
||||
screen or from logout, and renders nothing while a redirect is pending, so the panel does not flash.
|
||||
No project change is needed apart from `generate:importmap`.
|
||||
@@ -703,10 +705,10 @@ link with an outside address sent the user off the site straight after a real lo
|
||||
fixed this in `payload-totp` 3.0.5 (GHSA-rffw-fq79-g3ch); `@clocklimited/payload-2fa` (beta.1 to beta.7) has not.
|
||||
The panel's CSP does not stop it: the admin needs inline script.
|
||||
|
||||
ipal-kit closes it without changing the package. `SafeTotpView` (`@intecion/ipal-kit/admin`) is registered in
|
||||
IAPL closes it without changing the package. `SafeTotpView` (`@intecion/ipal-kit/admin`) is registered in
|
||||
place of the package's four views (`setup-totp`, `verify-totp`, each with and without a leading slash). It checks
|
||||
`back` on the server and renders the package's view with the checked value. The package's views stay in the
|
||||
import map through `admin.dependencies`, so ipal-kit still never imports the package.
|
||||
import map through `admin.dependencies`, so IAPL still never imports the package.
|
||||
|
||||
The rule (`safeAdminBack`, the same as upstream's): `back` is resolved the way a browser resolves it and kept
|
||||
only when it stays on the site's origin, over HTTP(S), without credentials, inside the admin route
|
||||
@@ -734,16 +736,16 @@ guarded. The same holds when the project also lists `payloadTotp(...)` in `plugi
|
||||
|
||||
**Your own 2FA screen.** Two ways, both keep the check:
|
||||
- Through the wrapped factory (the pattern from "Resetting 2FA"): set `views.VerifyTOTP.Component` (or `SetupTOTP`)
|
||||
on the config the factory returns. ipal-kit puts `SafeTotpView` in front of it. A server component gets every
|
||||
on the config the factory returns. IAPL puts `SafeTotpView` in front of it. A server component gets every
|
||||
server prop with `searchParams.back` checked. A client component (`'use client'`) gets Payload's client props,
|
||||
your `clientProps`, and `back` plus `searchParams` — both checked; read `back` from the props, not from
|
||||
`useSearchParams()`, which still holds the raw query value.
|
||||
- From a plugin listed after `ipalKit`, or under another key or route: that view is yours and is not wrapped. Use
|
||||
`wrapTotpViews` or `safeAdminBack` in it. `ipal-doctor` warns when the config uses the package's own view
|
||||
- From a plugin listed after `iapl`, or under another key or route: that view is yours and is not wrapped. Use
|
||||
`wrapTotpViews` or `safeAdminBack` in it. `iapl-doctor` warns when the config uses the package's own view
|
||||
(`@clocklimited/payload-2fa/rsc#TOTPVerify` / `#TOTPSetup`) as a view's `Component`; the same path as the
|
||||
`ipalTotpView` of `SafeTotpView`, or in `admin.dependencies`, is fine.
|
||||
|
||||
Wrapping views yourself, for a project that runs the 2FA package without `ipalKit`'s `twoFactor` (all from
|
||||
Wrapping views yourself, for a project that runs the 2FA package without `iapl`'s `twoFactor` (all from
|
||||
`@intecion/ipal-kit`):
|
||||
```ts
|
||||
const before = copyViews(config.admin?.components?.views) // copies: the factory's views are then never "the same object"
|
||||
@@ -760,13 +762,13 @@ guarded. The same holds when the project also lists `payloadTotp(...)` in `plugi
|
||||
passes and the site starts, but Payload renders nothing for a path its map lacks: the 2FA setup and verify
|
||||
screens have no code form (HTTP 200), so nobody can sign in to the panel. Payload's only trace is
|
||||
`getFromImportMap: PayloadComponent not found in importMap` in the server log. Development is not affected (Payload
|
||||
regenerates the map there). ipal-kit reports it in three places:
|
||||
- **Before deploy:** `pnpm exec ipal-doctor` reports `import map lacks @intecion/ipal-kit/admin#SafeTotpView` (error).
|
||||
- **At every start in production:** the log has `[ipal] The admin import map may be out of date: … was not found
|
||||
regenerates the map there). IAPL reports it in three places:
|
||||
- **Before deploy:** `pnpm exec iapl-doctor` reports `import map lacks @intecion/ipal-kit/admin#SafeTotpView` (error).
|
||||
- **At every start in production:** the log has `[iapl] The admin import map may be out of date: … was not found
|
||||
in <file> …`.
|
||||
- **On the screen:** a notice above the 2FA screen, "Two-step verification may not be available", with what a
|
||||
developer has to run. With a really stale map the notice is all the user sees (the form is missing); it is
|
||||
shown by ipal-kit's `TotpRedirectProvider` only — with your own `twoFactor.provider`, or `provider: false`,
|
||||
shown by IAPL's `TotpRedirectProvider` only — with your own `twoFactor.provider`, or `provider: false`,
|
||||
there is the log line alone.
|
||||
|
||||
The start-up check is a guess, and is built so that a wrong guess costs a wrong notice and nothing else: it
|
||||
@@ -781,7 +783,7 @@ not found is not reported. Building in place (Coolify's Nixpacks) reads the same
|
||||
|
||||
**Fix for a really stale map:** `pnpm payload generate:importmap`, commit `importMap.js`, rebuild, redeploy.
|
||||
A second error exists for the opposite case — the wrapper is in the map but the package's view is not:
|
||||
`[ipal] The admin import map has no "@clocklimited/payload-2fa/rsc#TOTPVerify"` (same fix).
|
||||
`[iapl] The admin import map has no "@clocklimited/payload-2fa/rsc#TOTPVerify"` (same fix).
|
||||
|
||||
**Check:** log in with the password only, open
|
||||
`/admin/verify-totp?back=https%3A%2F%2Fexample.com%2F`, enter the code: you must land on `/admin`, not on
|
||||
@@ -813,7 +815,7 @@ show the QR code. `back=null` or a page that keeps reloading means the import ma
|
||||
An admin resets another user's 2FA (a lost phone) or reopens setup for a blocked account on that account's page
|
||||
in the panel: **Two-step verification** in the sidebar → "Reset two-step verification" / "Reopen setup". Behind
|
||||
it: `POST /api/ipal/two-factor/reset` `{ userId }`. The account must set TOTP up again within a new window.
|
||||
The endpoint comes with ipal-kit's own check: with `twoFactor.guard: false` it does not exist (404), and neither
|
||||
The endpoint comes with IAPL's own check: with `twoFactor.guard: false` it does not exist (404), and neither
|
||||
does the control in the panel.
|
||||
|
||||
- **Who may reset.** By default a staff admin whose session has **entered its own TOTP code**. An admin on an API
|
||||
@@ -852,13 +854,13 @@ setup". Two ways out, both need a deploy or shell access — which is the point:
|
||||
administrators have, put the option back and deploy again. Accounts that still have not set TOTP up are
|
||||
blocked again from that moment (their start did not move).
|
||||
|
||||
Avoid it: at least two administrators with 2FA, and `ipal-doctor --url <site>` before an upgrade.
|
||||
Avoid it: at least two administrators with 2FA, and `iapl-doctor --url <site>` before an upgrade.
|
||||
|
||||
The 2FA package has its own reset, off unless you turn it on — through
|
||||
`adminManageAccess` in the @clocklimited configuration. ipalKit passes it only `collection`,
|
||||
`adminManageAccess` in the @clocklimited configuration. iapl passes it only `collection`,
|
||||
`forceSetup` and `issuer`; pass other options by wrapping the injected factory:
|
||||
`plugin: (opts) => payloadTotp({ ...opts, adminManageAccess: ({ req }) => isAdmin(req.user, req.payload) })`.
|
||||
ipal-kit's guard on those endpoints adds the rest: the caller must be an account of the 2FA collection that has
|
||||
IAPL's guard on those endpoints adds the rest: the caller must be an account of the 2FA collection that has
|
||||
passed the second factor itself. After a reset the account is "not set up" again — have its owner set TOTP up
|
||||
at once (see the note above).
|
||||
|
||||
@@ -867,7 +869,7 @@ at once (see the note above).
|
||||
Chosen because it wraps ACCESS CONTROL (TOTP before data access) + forceSetup
|
||||
(enforced for everyone). Other 2FA plugins for Payload only gate /admin
|
||||
navigation — a user with a password can bypass them through REST/GraphQL/Bearer. @clocklimited protects
|
||||
data access, not just the UI — for what is in the config when it runs; ipal-kit's own check covers the rest
|
||||
data access, not just the UI — for what is in the config when it runs; IAPL's own check covers the rest
|
||||
("What the second factor covers").
|
||||
|
||||
## 1.9.1 — security review results
|
||||
@@ -918,7 +920,7 @@ size while reading, content signature, container and macro checks, an optional `
|
||||
- Injected auth collection with roles: a `user` account reads and edits only itself; only an
|
||||
admin creates and deletes. Before, any logged-in account could change an admin's email/password.
|
||||
- 2FA without `collectionSlug` wraps the panel login collection (`admin.user`, else the first auth
|
||||
collection), not the literal `'users'`. Plugin startup fails with `[ipal] twoFactor…` when the target is not
|
||||
collection), not the literal `'users'`. Plugin startup fails with `[iapl] twoFactor…` when the target is not
|
||||
an auth collection or differs from `admin.user` — deliberate exception: `twoFactor.allowCollectionMismatch: true`.
|
||||
- Injected auth collection with roles: `unlock` is admin-only too. You can override all of it:
|
||||
`access.authAccess`, `access.firstUserAdmin: false`, `globalOverrides`, `forms.formOverrides`.
|
||||
@@ -959,7 +961,7 @@ SMTP when Graph is not configured, and for attachments Graph cannot take. A chan
|
||||
asks for nothing. Values are compared exactly (`587` and `'587'` are the same; another letter case or a space
|
||||
is a change), and a value never saved — or a `NULL` in a SQL row — counts as the field's default, so saving
|
||||
the form unchanged asks for nothing. Server code — a seed, a script with the Local API and access control off
|
||||
— is not asked. `ipalKit({ secrets: { reenterOnChange: false } })` = the stored password follows the new
|
||||
— is not asked. `iapl({ secrets: { reenterOnChange: false } })` = the stored password follows the new
|
||||
server, as before.
|
||||
|
||||
A stolen admin session, or any way past the global's read rule, no longer yields a working mailbox password.
|
||||
@@ -978,7 +980,7 @@ document, the fields under `version`, where field hooks do not run: the global's
|
||||
- **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.
|
||||
- **Off:** `iapl({ 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`,
|
||||
@@ -1000,7 +1002,7 @@ The plugin's dashboard alerts read data that only some roles may read (with acce
|
||||
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' } })`
|
||||
its second factor sees none of them. `iapl({ dashboardAlerts: { integrations: 'editor' | 'all', cookies: 'all' } })`
|
||||
loosens it. **`'all'` checks nothing** — no role and no second factor: whoever the dashboard is drawn for sees
|
||||
the full text, as before. The components take the same as props
|
||||
(`details`, `audience`).
|
||||
@@ -1024,7 +1026,7 @@ the full text, as before. The components take the same as props
|
||||
`buildSetupFields`, `stampSetupFrom`, `backfillSetupFrom`, `buildTwoFactorResetEndpoint`,
|
||||
`countAccountsWithoutTotp`, `resolveRequireSetup`, `strictExempt`, `SETUP_FROM_FIELD`.
|
||||
- **2FA check:** per entity `custom.ipal.secondFactor` / `custom.totp.disableAccessWrapper` (one operation or
|
||||
all); `twoFactor.guard: false` turns ipal-kit's own second-factor check off everywhere (not recommended);
|
||||
all); `twoFactor.guard: false` turns IAPL's own second-factor check off everywhere (not recommended);
|
||||
`requireSecondFactor` / `secondFactorPassed` are exported for your own access functions and endpoints.
|
||||
- **Turn off:** headers — do not call `buildSecurityHeaders`, or `null` / `false` per header (`frameOptions`,
|
||||
`referrerPolicy`, `permissionsPolicy`, `coop`), `hsts: false`; CSP — leave out `csp` (the default);
|
||||
@@ -1042,4 +1044,4 @@ the full text, as before. The components take the same as props
|
||||
or collector; `buildUploadSecurityHeaders({ collections })` for your own upload collections.
|
||||
- **Check:** `curl -sI https://domain/pl | grep -iE "strict-transport|x-frame|referrer|permissions|cross-origin|content-security|x-powered-by"`
|
||||
(no `x-powered-by`; `content-security-policy-report-only` while rolling out);
|
||||
on staging also `x-robots-tag`; startup with a wrong `twoFactor.collectionSlug` fails with `[ipal] twoFactor…`.
|
||||
on staging also `x-robots-tag`; startup with a wrong `twoFactor.collectionSlug` fails with `[iapl] twoFactor…`.
|
||||
|
||||
Reference in New Issue
Block a user