2FA setup required: review fixes (SR-1 to SR-9)
SR-1: /api/ipal/admin-icon sends the upload security headers (sandbox policy, nosniff) with the bytes: an SVG is shown, never run. fetchPublicImage stops reading at the size limit. SR-2: requireSetup.exempt exempts only on exactly true; an async function, and a windowHours that is not a number or false, stop the start. SR-3: on Postgres / SQLite the missing column makes every login fail: the log says so, the docs call the migration a required step of the same deploy, and ipal-doctor reports a SQL project without it. SR-4: an admin's reset also ends the account's sessions. SR-5: the reset needs a session that entered its own TOTP code by default. SR-6: the doctor's import-map rule covers TwoFactorStatusField and TwoFactorAlert. SR-7: building blocks exported; dashboard notice, status field, setup notice and the server-side image fetch can be switched off one by one. SR-8: totpSetupFrom is on the 2FA collection whenever 2FA is on. SR-9: both ways out of "every administrator is blocked" in security.md. Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
9d2ab43438
commit
75a6f5209e
+25
-6
@@ -21,7 +21,11 @@ once there are more than 20.
|
||||
- **Accounts that already exist** get their 72 hours from the **first start after the upgrade** (not from their
|
||||
creation date), so nobody is blocked at the moment of the upgrade. The server log names how many there are.
|
||||
That moment is written on each account once: later restarts, redeploys and further instances do not move it,
|
||||
nor does editing the account. On Postgres / SQLite it is the first start with the migration applied.
|
||||
nor does editing the account.
|
||||
- **A reset by an administrator ends the account's sessions**, and by default needs a session that entered its
|
||||
own TOTP code (not an API key, not an exempt account).
|
||||
- **`/api/ipal/admin-icon` answers with the favicon itself** instead of a redirect, with the same sandbox headers
|
||||
as the upload routes, so the tab icon also loads on the 2FA screens (`adminMeta.serveIcon: false` = the redirect).
|
||||
|
||||
### Added
|
||||
- On every account in the panel: **Two-step verification** (sidebar) — set up / open until a date / blocked — and
|
||||
@@ -30,12 +34,22 @@ once there are more than 20.
|
||||
- A dashboard notice for administrators: accounts without two-step verification, and how many are blocked.
|
||||
- A notice on the setup screen: until when setup has to be done, or that the time has passed. All texts in
|
||||
English and Polish.
|
||||
- Options: `twoFactor.requireSetup: false | { windowHours, exempt }`, `twoFactor.resetAccess`. Exports:
|
||||
`twoFactorSetupState`, `twoFactorSetupDeadline`; admin components `TwoFactorStatusField`, `TwoFactorResetButton`,
|
||||
`TwoFactorAlert`.
|
||||
- Options: `twoFactor.requireSetup: false | { windowHours, exempt, dashboardNotice, statusField, setupNotice }`,
|
||||
`twoFactor.resetAccess`, `whiteLabel.inlineImages`, `adminMeta.serveIcon`. Exports: `twoFactorSetupState`,
|
||||
`twoFactorSetupDeadline`, `buildSetupFields`, `stampSetupFrom`, `backfillSetupFrom`,
|
||||
`buildTwoFactorResetEndpoint`, `countAccountsWithoutTotp`, `resolveRequireSetup`, `strictExempt`,
|
||||
`SETUP_FROM_FIELD`, `TWO_FACTOR_RESET_PATH`, `DEFAULT_SETUP_WINDOW_HOURS`, `fetchPublicImage`,
|
||||
`publicImageDataUri`, `siteOrigin`, `PUBLIC_IMAGE_MAX_BYTES`, `UPLOAD_SECURITY_HEADERS`; admin components
|
||||
`TwoFactorStatusField`, `TwoFactorResetButton`, `TwoFactorAlert`.
|
||||
- `requireSetup.exempt` is strict: only an answer of exactly `true` exempts. An `async` function, and a
|
||||
`windowHours` that is not a number or `false`, stop the site at start with a clear error.
|
||||
- The date field `totpSetupFrom` is on the 2FA collection whenever 2FA is on, so switching `requireSetup` or
|
||||
`guard` never changes the schema (and never restarts anyone's window).
|
||||
- The panel's tab icon and logo load on the verify and setup screens: `GET /api/ipal/admin-icon` answers with the
|
||||
image itself (no redirect to the media file), and the logo components give a session that still owes its code
|
||||
the picture as an anonymous visitor would get it. No change to who can read `media`.
|
||||
- ipal-doctor: a SQL project without a migration for `totp_setup_from` (error), an import map without the two
|
||||
new admin components (error).
|
||||
- ipal-doctor: the `2fa` rule says how many accounts without 2FA are blocked (`usersSetupClosed` in the deep
|
||||
status), warns when `requireSetup` is switched off and notes a missing setup window.
|
||||
|
||||
@@ -43,10 +57,15 @@ once there are more than 20.
|
||||
- **Before upgrading a live site:** `pnpm exec ipal-doctor --url <site>` → accounts without 2FA. Each sets 2FA up
|
||||
now, or is removed. At least one administrator must have 2FA set up, or nobody can reopen setup from the panel.
|
||||
- `pnpm payload generate:importmap` (commit `importMap.js`) and `pnpm payload generate:types`, in the same
|
||||
deploy as the upgrade (as for 1.16.5: a stale import map leaves the 2FA screens without a code form).
|
||||
deploy as the upgrade (as for 1.16.5: a stale import map leaves the 2FA screens without a code form). `ipal-doctor`
|
||||
reports a map without `TwoFactorStatusField` / `TwoFactorAlert` (then the panel has no "Reopen setup").
|
||||
- **Plan the upgrade with the owner:** the 72 hours of every existing account without 2FA start at the deploy,
|
||||
once. Deploy when those people can act within three days (not before a holiday), or have them set 2FA up first.
|
||||
- **Postgres / SQLite:** `pnpm payload migrate:create` — the 2FA collection gets the column `totpSetupFrom`.
|
||||
- **Postgres / SQLite — required, in the same deploy: `pnpm payload migrate:create`, commit, and the migration
|
||||
applied before the new version serves requests** (the 2FA collection gets the column `totp_setup_from`).
|
||||
**Without it every login answers 500 — administrators with 2FA included — and nobody can sign in to the
|
||||
panel.** The log says so at start (`NOBODY CAN LOG IN`), and `ipal-doctor` reports a SQL project whose
|
||||
migrations do not mention the column. Every project with 2FA on needs it, also with `requireSetup: false`.
|
||||
MongoDB: nothing.
|
||||
- **An integration that logs in with a password and has no TOTP** stops working: give it an API key (passes as
|
||||
before) or exempt it on purpose: `twoFactor.requireSetup: { exempt: ({ user }) => user.email === '…' }`.
|
||||
|
||||
+1
-1
@@ -1165,7 +1165,7 @@ add missing hosts with flags / `extra`; (3) change `mode` to `'enforce'` in both
|
||||
| Injected `users`: admin manages everyone, others only themselves | — | `access.authAccess` (your keys win); your own `users` collection wins whole |
|
||||
| First registered account = admin | `access.firstUserAdmin: false` | `buildRolesField(defaultRole, { firstUserAdmin })` |
|
||||
| 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` | `requireSetup: { windowHours, exempt }`, `twoFactor.resetAccess`, texts `twoFactor*`; `twoFactorSetupState(req)` |
|
||||
| 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` before the version serves, 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 }` |
|
||||
| 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 |
|
||||
|
||||
@@ -37,9 +37,14 @@ through this procedure. Ask only when you are missing something you cannot get y
|
||||
| the 2FA code screen answers "Too many codes were tried…" (`429` from `/api/verify-totp`) | more than 5 verify attempts for that account in 10 minutes (`twoFactor.verifyLimit`); repeated lines `[ipal] 2FA: too many verify attempts` in the log without the owner trying = someone has the password | wait for the window, enter the current code once; unexplained attempts: change that account's password. Tests that log in often: `verifyLimit: { max: … }` for that environment |
|
||||
| `isAdmin(req.user)` says `false` for a real administrator on the server, in a process that loads two Payload configs (tests, a multi-site script) | a call without a source counts only collections that are staff in **every** config of the process | pass the source: `isAdmin(req.user, req.payload)` — with it each config gets its own answer |
|
||||
| `isAdmin(user)` / `isEditor(user)` is always `false` in a client component or in `proxy.ts` | the staff collections are not known there (no config in the browser bundle / middleware), and the predicates fail closed | `isAdmin(user, config)` with `useConfig()`; in middleware `isAdmin(user, { staffCollections: ['users'] })` |
|
||||
| an account logs in but every page and request answers 403 / the setup screen says "The time to set up two-step verification has passed" | 2FA setup required: the account did not set TOTP up within the window (72 h from its creation, an admin's reset, or the first start after the upgrade) | an administrator opens the account in the panel → Two-step verification → "Reopen setup" (or `POST /api/ipal/two-factor/reset` `{ userId }`); the only admin is blocked: a script with the Local API — `payload.update({ collection: 'users', id, data: { totpSetupFrom: new Date().toISOString() } })` (`pnpm payload run`), then log in and set TOTP up |
|
||||
| an account logs in but every page and request answers 403 / the setup screen says "The time to set up two-step verification has passed" | 2FA setup required: the account did not set TOTP up within the window (72 h from its creation, an admin's reset, or the first start after the upgrade) | an administrator opens the account in the panel → Two-step verification → "Reopen setup" (or `POST /api/ipal/two-factor/reset` `{ userId }`); every administrator is blocked: security.md "Every administrator is blocked" — a script with the Local API, `payload.update({ collection: 'users', id, data: { totpSetupFrom: new Date().toISOString() } })` (`pnpm payload run`), then log in and set TOTP up; or `requireSetup: { windowHours: false }`, redeploy, set up, put it back |
|
||||
| a new account gets `403` from the API although its role allows the request | 2FA setup required: until TOTP is set up the account reaches only the setup screen | set TOTP up (log in to the panel); an integration: use an API key, or `twoFactor.requireSetup.exempt` |
|
||||
| log: `[ipal] 2FA: could not start the setup window for existing accounts` | Postgres/SQLite: the migration that adds `totpSetupFrom` has not run | `pnpm payload migrate:create`, commit, deploy (migrations run in the Coolify pre-deploy command) |
|
||||
| after an upgrade EVERY panel login answers `500` (also `/api/users/init`), administrators with 2FA included; log: `[ipal] 2FA: the column for "totpSetupFrom" is missing … NOBODY CAN LOG IN` or `column users.totp_setup_from does not exist` | Postgres/SQLite: the migration that adds the 2FA column has not run (needed whenever 2FA is on) | `pnpm payload migrate:create` if no migration has it, commit, run `pnpm payload migrate` (the Coolify pre-deploy command) and redeploy; nothing is lost. `ipal-doctor` reports a project whose migrations lack `totp_setup_from` |
|
||||
| the site does not start: `[ipal] twoFactor.requireSetup.exempt must not be async` / `…windowHours must be a number` | `exempt` is an `async` function, or `windowHours` is a string / negative | `exempt: ({ user }) => user.email === '…'` (returns `true` / `false` at once); `windowHours: 72` or `false` |
|
||||
| log: `[ipal] twoFactor.requireSetup.exempt returned a Promise … The account is NOT exempt` (and the service account gets 403) | `exempt` does not return exactly `true` | return a boolean decided from the fields on `user` |
|
||||
| an administrator's "Reset two-step verification" answers 403 from a script with an API key, or for an exempt account | by default the reset needs a session that entered its own TOTP code | reset from the panel after logging in with the code; or `twoFactor.resetAccess: ({ req }) => …` |
|
||||
| after "Reset two-step verification" the user is logged out everywhere | intended: the reset ends the account's sessions | the user logs in again with the password and sets 2FA up; after a suspected compromise also change the password |
|
||||
| no "Two-step verification" box on the account page / no "Reopen setup" | the import map lacks `TwoFactorStatusField` (not regenerated), or `requireSetup: { statusField: false }` | `pnpm payload generate:importmap`, commit, redeploy; meanwhile `POST /api/ipal/two-factor/reset` `{ userId }` works |
|
||||
| "Two-step verification" is missing on the account page / the dashboard shows a missing component | the import map is stale | `pnpm payload generate:importmap`, commit `importMap.js`, `rm -rf .next`, redeploy |
|
||||
| startup: `[ipal] twoFactor: the injected 2FA plugin did not add the totpSecret field / hasTotp field / totp auth strategy` | the installed `@clocklimited/payload-2fa` is not a version ipal-kit's second-factor check recognises (tested: 3.0.0-beta.1 and beta.7), or a custom factory was injected | install a supported version; stop-gap only: `twoFactor.guard: false` (the plugin's own data is then not covered by 2FA — security.md) |
|
||||
| own route or script gets `403` / "not allowed" on `form-submissions`, `forms`, a settings global with `overrideAccess: false`, although the user is an admin | the `user` was fetched by id and passed by hand: it does not carry how the account logged in, so the second-factor check refuses it | take the user from `payload.auth({ headers })` (it sets `collection` and how the account logged in), or (server-only code that needs no access check) leave `overrideAccess` at its default; a hand-built user needs at least `collection: 'users'` for its role to count |
|
||||
|
||||
@@ -42,8 +42,11 @@ description: Complete map of everything @intecion/ipal-kit provides — every ip
|
||||
| `twoFactor.texts` | ipal-kit's en/pl texts (`TOTP_TEXTS`) over the package's; 2FA screens titled "Two-step verification" / "Weryfikacja dwuetapowa" (site's language) | `false` = the package's texts; one text: `i18n.translations.<lang>.totpPlugin.<key>` (security.md) |
|
||||
| `twoFactor.guard` | on | ipal-kit's own second-factor check on every collection and global (also the plugin's own and those of plugins listed after ipalKit) and in `userMeetsRole`; startup fails with `[ipal] twoFactor: the injected 2FA plugin did not add …` when the 2FA package lacks the `totp` strategy / `hasTotp` / `totpSecret` | per entity: `custom.ipal.secondFactor: false` / `{ read: false }` or the package's `custom.totp.disableAccessWrapper.<op>`; `false` = the package's wrapper only (the plugin's own data then opens to a password without the code; not recommended). The package's endpoints stay limited to accounts of the 2FA collection either way |
|
||||
| `twoFactor.verifyLimit` | `{ max: 5, windowMinutes: 10 }` | 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.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 fields `totpSetupFrom` (date, written by the plugin) and `totpSetupStatus` (panel) to the 2FA collection, a dashboard notice and `POST /api/ipal/two-factor/reset`. Existing accounts get their window at the first start after the upgrade. Postgres/SQLite: migration; `generate:importmap` | `false` = the package's rule (API open until setup); `{ windowHours: 24 }`, `{ windowHours: false }` (no limit), `{ exempt: ({ user }) => … }` (a service account) |
|
||||
| `twoFactor.resetAccess` | a staff admin | who may reset another account's TOTP / reopen its setup (the button on the account page, `POST /api/ipal/two-factor/reset`); the second factor is always required | `({ req }) => boolean` |
|
||||
| `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 run before the version serves, 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` | 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` — only `true` allows; `req.user._strategy` tells `'totp'`, `'api-key'`, `'local-jwt'` apart |
|
||||
| `whiteLabel.inlineImages` | on | on the 2FA screens the logo / icon is fetched by the server as an anonymous visitor gets it (max 512 KB) and inlined as `data:` — the session there is refused `media` | `false` = the browser tries the media URL |
|
||||
| `adminMeta.serveIcon` | on | `/api/ipal/admin-icon` answers with the favicon's bytes and the upload security headers (sandbox, nosniff) | `false` = a redirect to the media file |
|
||||
| `twoFactor.allowCollectionMismatch` | `false` | allows `collectionSlug` ≠ `admin.user` (panel users of the other collection then skip 2FA) | `true` only when you protect a second auth collection on purpose |
|
||||
| `whiteLabel` | none | `admin.components.graphics.Logo/Icon` (`AdminLogo`/`AdminIcon`) from Site settings + vendor credit | omit / `false`; `true` = defaults |
|
||||
| `whiteLabel.settingsSlug` | `'site-settings'` | global it reads the logo/name from | — |
|
||||
|
||||
@@ -72,7 +72,7 @@ Admin panel components from `@intecion/ipal-kit/admin` — the project does NOT
|
||||
| `buildRolesField(defaultRole?, { firstUserAdmin? })` | `@intecion/ipal-kit` | The `roles` select field the plugin injects (only admins set roles; `firstUserAdmin` default `true` = the account made on "Create first user" gets `admin`). The plugin wires it itself — use it only for an auth collection the plugin does not manage. |
|
||||
| `injectRoles(config, accessOption)` | `@intecion/ipal-kit` | Adds `roles` to `accessOption.authCollection` in a config. The plugin calls it itself with `access` — do not call. |
|
||||
|
||||
**Types:** `VerifyLimitOptions` (`twoFactor.verifyLimit`: `{ max?, windowMinutes? }`), `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:** `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`).
|
||||
|
||||
## Accessibility — widget (`accessibility`) — details: `node_modules/@intecion/ipal-kit/docs/accessibility.md`
|
||||
|
||||
@@ -595,6 +595,12 @@ Server only (`pnpm payload run`); never import it from client code, the Payload
|
||||
| `copyViews(views)` / `changedViewKeys(before, after)` | `@intecion/ipal-kit` | The comparison `ipalKit` uses to tell which views a 2FA factory registered: put `copyViews(views)` into the config before calling the factory, then `changedViewKeys(before, viewsAfter)` gives the keys whose view object changed — the `added` argument of `wrapTotpViews` (`(key) => keys.has(key)`). By object, not by key: the 2FA package replaces a view that already stands under its keys. Example: security.md "Your own 2FA screen". |
|
||||
| `SAFE_TOTP_VIEW` / `totpViewImportKey(component)` | `@intecion/ipal-kit` | `'@intecion/ipal-kit/admin#SafeTotpView'`, the wrapper's import-map path (the default `wrapper` of `wrapTotpViews`); and the import-map key (`path#export`) of a component given as a string or `{ path, exportName }`. |
|
||||
| `findImportMapFile(config, cwd?)` / `missingImportMapEntries(config, entries, cwd?)` | `@intecion/ipal-kit` | Where the project's `importMap.js` is on disk (`admin.importMap.importMapFile`, else `app/(payload)<admin route>/` or `src/app/…` under `admin.importMap.baseDir` / the working directory; `null` when not found), and which of `entries` its text does not contain (`{ file, missing }`). A hint from the file on disk, not the map in the build: warn on it, never block on it. Behind `twoFactor.importMapCheck`. |
|
||||
| `buildSetupFields({ statusField? })`, `stampSetupFrom`, `backfillSetupFrom(payload, collection)` | `@intecion/ipal-kit` | The parts of "2FA setup required" for a project that wires them itself: the fields for the 2FA collection (`totpSetupFrom`, and the panel's `totpSetupStatus` unless `statusField: false`), the `beforeChange` hook that stamps the window start (on create, and when an account loses its TOTP secret), and the start-up step that gives accounts without TOTP and without a start their window (returns how many; once per account). |
|
||||
| `buildTwoFactorResetEndpoint(collection, { access? })`, `TWO_FACTOR_RESET_PATH` | `@intecion/ipal-kit` | `POST /api/ipal/two-factor/reset` `{ userId }`: clears the account's TOTP secret and sessions and starts a new window. Default: a staff admin whose session entered its own TOTP code; `access` replaces that (only `true` allows; a session that owes its code is always refused). |
|
||||
| `countAccountsWithoutTotp(payload, collection, setupWindowMs?)` | `@intecion/ipal-kit` | `{ without, blocked }` — accounts of the 2FA collection without TOTP, and how many are past their window. |
|
||||
| `resolveRequireSetup(option)`, `strictExempt(fn)`, `SETUP_FROM_FIELD`, `DEFAULT_SETUP_WINDOW_HOURS` | `@intecion/ipal-kit` | `twoFactor.requireSetup` → `{ requireSetup, setupWindowMs, exempt? }` as the guard reads it (throws on a `windowHours` that is not a number ≥ 0 or `false`, and on an `async` `exempt`); the wrapper that makes an `exempt` function answer `true` only for exactly `true`; the field name `'totpSetupFrom'`; `72`. |
|
||||
| `fetchPublicImage(url, base)`, `publicImageDataUri(url, base)`, `siteOrigin(serverURL)`, `PUBLIC_IMAGE_MAX_BYTES` | `@intecion/ipal-kit` | An image fetched the way an anonymous visitor gets it (no cookies; http(s) only; `image/*`; at most 512 KB, reading stops at the limit) as `{ bytes, type }` or a `data:` address, else `null`. Used for the logo and icon on the 2FA screens. |
|
||||
| `UPLOAD_SECURITY_HEADERS` | `@intecion/ipal-kit` | The two headers of `buildUploadSecurityHeaders` (`Content-Security-Policy: default-src 'none'; … sandbox`, `X-Content-Type-Options: nosniff`) for a route of your own that returns an uploaded file's bytes from the site's origin. |
|
||||
| `twoFactorSetupState(req)`, `twoFactorSetupDeadline(req)` | `@intecion/ipal-kit` | Where an account stands with TOTP setup, from `{ payload, user }`: `'set-up'`, `'open'` (may set it up now), `'closed'` (the setup window has passed: blocked until an admin reopens it), `'exempt'` (`requireSetup.exempt`, or `requireSetup: false`), `'not-applicable'` (no user, another collection, 2FA off); and the moment setup closes (`Date`, or `null` without a window). Types: `TwoFactorSetupState`, `RequireSetupOptions`. |
|
||||
| `requireSecondFactor(access?)` | `@intecion/ipal-kit` | Wraps an `Access` function: refused while the second factor is owed, otherwise the function itself (Payload's default "logged in" when none). ipalKit applies it to every collection and global in the config, and to those added by plugins listed after it (in `onInit` and at the start of the first request, so also after a dev hot reload); use it for access functions that are not part of the config. Per-entity opt-out: `custom.ipal.secondFactor: false \| { read: false }` or the package's `custom.totp.disableAccessWrapper`. Wrapping twice is harmless. |
|
||||
| `totpRedirectTarget({ adminRoute, forceSetup?, pathname, user, excludePaths? })`, `totpAdminPath(adminRoute, path)` | `@intecion/ipal-kit` | The 2FA redirect rules as pure functions: the setup / verify URL (with `back`) to send this user to, or `null` (no path, api key, already on a TOTP screen or logout). For an own `twoFactor.provider`. Types `TotpRedirectArgs`, `TotpUser` |
|
||||
|
||||
@@ -236,10 +236,15 @@ the panel shows Site settings, Site integrations, Cookies, Form messages, the Fo
|
||||
opens everything its role allows. One entity reachable without the code: `custom.ipal.secondFactor`.
|
||||
**Setup required** (`twoFactor.requireSetup`, default): an account without TOTP reaches only the setup screen; it
|
||||
has 72 h from its creation (or an admin's "Reopen setup" on the account page), then it is blocked. So create an
|
||||
account, hand over the password and have the owner set 2FA up at once. Postgres/SQLite: `pnpm payload
|
||||
migrate:create` (field `totpSetupFrom`); `pnpm payload generate:importmap` (`TwoFactorStatusField`,
|
||||
`TwoFactorAlert`). A service account that logs in with a password: `requireSetup: { exempt }`; an API key needs
|
||||
nothing. One entity reachable without the code: `custom.ipal.secondFactor`.
|
||||
account, hand over the password and have the owner set 2FA up at once. **Postgres/SQLite: `pnpm payload
|
||||
migrate:create` and run the migration before the site serves** (column `totp_setup_from`, there whenever 2FA is
|
||||
on) — without it every login answers 500; `pnpm payload generate:importmap` (`TwoFactorStatusField`,
|
||||
`TwoFactorAlert`). A service account that logs in with a password: `requireSetup: { exempt }` (a plain function
|
||||
returning exactly `true`; never `async`); an API key needs nothing. Parts to switch off: `requireSetup:
|
||||
{ dashboardNotice: false, statusField: false, setupNotice: false }`. An admin's reset ends the account's
|
||||
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`.
|
||||
- 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
|
||||
|
||||
@@ -390,14 +390,24 @@ with 2FA on:**
|
||||
and redeploys do not extend them): agree the deploy day with the owner.
|
||||
2. Update the package, `pnpm install`, `pnpm ipal:skills`, `pnpm payload generate:types`,
|
||||
**`pnpm payload generate:importmap`** (new: `TwoFactorStatusField`, `TwoFactorAlert`; commit `importMap.js`).
|
||||
3. Postgres/SQLite: `pnpm payload migrate:create` (adds `totpSetupFrom` to the 2FA collection), commit. MongoDB: nothing.
|
||||
3. **Postgres/SQLite — required, same deploy, or nobody can log in:** `pnpm payload migrate:create` (adds the
|
||||
column `totp_setup_from` to the 2FA collection; needed whenever 2FA is on, also with `requireSetup: false`),
|
||||
commit, and make sure it is applied before the new version serves requests (the Coolify pre-deploy command
|
||||
`pnpm payload migrate`). Without the column every login answers 500, administrators included; the log says
|
||||
`[ipal] 2FA: the column for "totpSetupFrom" is missing … NOBODY CAN LOG IN`. `pnpm exec ipal-doctor` reports
|
||||
it before the deploy. MongoDB: nothing.
|
||||
4. An integration that logs in with a password and has no TOTP: give it an API key, or
|
||||
`twoFactor.requireSetup: { exempt: ({ user }) => user.email === '…' }`. `grep -rn "overrideAccess: false" src`:
|
||||
a `user` fetched by id is refused for every account now — take it from `payload.auth({ headers })`.
|
||||
5. `rm -rf .next`, build, redeploy on Coolify. Read the first lines of the log: `[ipal] 2FA: N existing account(s)
|
||||
without two-step verification…` — pass that number to the owner. The line appears on that first start only.
|
||||
Postgres/SQLite: the migration from step 3 must run in the same deploy; without it the log says
|
||||
`could not start the setup window` and the window starts at the first start that has it.
|
||||
Postgres/SQLite: if logins answer 500 after the deploy, the migration from step 3 did not run — run it now.
|
||||
6. `requireSetup.exempt` must be a plain function returning `true` / `false` (an `async` one stops the start).
|
||||
Scripts that used `POST /api/ipal/two-factor/reset` with an API key: refused by default now — pass
|
||||
`twoFactor.resetAccess` if that is wanted. A reset ends the account's sessions (it logs in again).
|
||||
**Every administrator is blocked** (all missed the 72 h): security.md "Every administrator is blocked" — a
|
||||
`pnpm payload run` script that sets `totpSetupFrom` to now for one administrator, or
|
||||
`requireSetup: { windowHours: false }` + redeploy, set 2FA up, put it back.
|
||||
**Check:** create a throwaway account → its token gets `403` from `/api/users/me`; in the panel it lands on the
|
||||
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.
|
||||
|
||||
@@ -675,7 +675,7 @@ Do one item at a time, build, check. Order by importance:
|
||||
| 65 | **1.16.4 — security** — with 2FA on, a login with the password only gets `200` from `/api/globals/site-integrations` or `/api/form-submissions`; or the project has a second auth collection (`customers`) | Upgrade and redeploy (no config change with one auth collection). With the owner: change the SMTP password and the Turnstile secret, review Site settings / Site integrations / each form's Emails tab for values nobody set. Second auth collection: `admin: { user }` in `buildConfig`, `adminOrSelfIn('<slug>')`, `access.staffCollections` only for a second STAFF collection. Every account must have 2FA set up (`ipal-doctor --url` → 0 without). Own endpoints: `secondFactorPassed(req)`; own `overrideAccess: false` calls: `user` from `payload.auth()`. `pnpm ipal:skills`; no migration | CHANGELOG 1.16.4, security.md "What the second factor covers", access.md "Who is staff" |
|
||||
| 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 | **Unreleased — 2FA setup required** — 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 must have 2FA. Then: update, `generate:types`, `generate:importmap` (`TwoFactorStatusField`, `TwoFactorAlert`), Postgres/SQLite `migrate:create` (`totpSetupFrom`), 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 "Unreleased — 2FA setup required", security.md "Setup required" |
|
||||
| 68 | **Unreleased — 2FA setup required** — 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 must have 2FA. Then: update, `generate:types`, `generate:importmap` (`TwoFactorStatusField`, `TwoFactorAlert`), **Postgres/SQLite: `migrate:create` and the migration applied in the same deploy (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 "Unreleased — 2FA setup required", security.md "Setup required" |
|
||||
|
||||
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`.
|
||||
|
||||
+2
-2
@@ -89,7 +89,7 @@ Turn off: `ipalKit({ doctor: false })`. Adapt: `ipalKit({ doctor: { tokenVar: 'M
|
||||
| | `layout-forbidden` | error | no `middleware.ts`, no `lib/{pages,locales,navigation}.ts`, `fields/{link,sectionHeader,sectionSettings}.ts` |
|
||||
| | `layout-extra` | info | `src/` entries outside the allow list (AGENT.md §3 + `seed/`, `design/`, `db.ts`, `env.rules.ts`, `content.config.ts`; extend with `layout.allow`) |
|
||||
| | `naming` | warning | block folders, collection and global files PascalCase, `scripts/*` kebab-case, no `index.ts` barrels |
|
||||
| | `importmap` | error | the import map exists, holds the entries for what the config turns on (2FA, R2, cookie scanner, `adminMeta`), names no export the plugin no longer has; with `--deep`, equals a fresh one. Warning: the config uses the 2FA package's own setup / verify view as a view's `Component` (outside the `back` link check — security.md); not for that path as `ipalTotpView` of `SafeTotpView` or in `admin.dependencies` |
|
||||
| | `importmap` | error | the import map exists, holds the entries for what the config turns on (2FA incl. `SafeTotpView`, `TwoFactorStatusField`, `TwoFactorAlert`; R2, cookie scanner, `adminMeta`), names no export the plugin no longer has; with `--deep`, equals a fresh one. Warning: the config uses the 2FA package's own setup / verify view as a view's `Component` (outside the `back` link check — security.md); not for that path as `ipalTotpView` of `SafeTotpView` or in `admin.dependencies` |
|
||||
| | `tsconfig-skills` | error | `tsconfig.json` excludes the skills folder |
|
||||
| env | `db-name` | error | `DATABASE_URI` in `.env` and `.env.example` names `<domain without dots>_dev`; a local `.env` on `_prod` is an error; `--env-file` checks `_prod` (`databaseNamesFor`) |
|
||||
| | `env-rules` | error / warning | `instrumentation.ts` calls `assertEnv(ipalEnvRules(…))` from `/env`, with `storage` (R2), `cookieCrawl` (crawl), `ipHeader`; `databaseName` suggested (info) |
|
||||
@@ -98,7 +98,7 @@ Turn off: `ipalKit({ doctor: false })`. Adapt: `ipalKit({ doctor: { tokenVar: 'M
|
||||
| security | `security-headers` | error | `buildSecurityHeaders`; live: HSTS, nosniff, Referrer-Policy, Permissions-Policy, frame protection |
|
||||
| | `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); warning: `twoFactor.requireSetup: false`; info: no setup window (`windowHours: false`) |
|
||||
| | `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`) |
|
||||
| | `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 |
|
||||
|
||||
+73
-12
@@ -433,7 +433,9 @@ the Local API with `overrideAccess: true` (the default) are not affected.
|
||||
### Setup required (`twoFactor.requireSetup`, on by default)
|
||||
|
||||
An account that has **not set TOTP up yet** reaches nothing at the access level — REST, GraphQL, the panel's
|
||||
data, the plugin's endpoints — until it has. It gets the setup screen and `POST /api/setup-totp`, nothing else.
|
||||
data, the plugin's endpoints — until it has. It gets the setup screen and `POST /api/setup-totp`, and what
|
||||
Payload gives any logged-in session about itself (`/api/access`, token refresh, logout, its own panel
|
||||
preferences), nothing else.
|
||||
The 2FA package alone only redirects such an account inside the panel; over the API its password would open
|
||||
everything its role allows.
|
||||
|
||||
@@ -465,8 +467,8 @@ the account without one. Later starts, redeploys and further instances find noth
|
||||
appears on that first start only), and editing the account or logging in does not move it — so a redeploy never
|
||||
hands out another 72 hours. Only an administrator's reset / "Reopen setup" opens a new window. An existing
|
||||
account that **has** TOTP gets no start; if its TOTP is removed later, its window starts then. On Postgres /
|
||||
SQLite "the first start" means the first start **with the migration applied**: before that there is no column
|
||||
to write to, the log warns, and those accounts have no time limit yet.
|
||||
SQLite the migration that adds the column must run in the same deploy (see "Data" below) — the first start
|
||||
after it is the one that counts.
|
||||
|
||||
```ts
|
||||
twoFactor: {
|
||||
@@ -475,17 +477,39 @@ twoFactor: {
|
||||
// requireSetup: { windowHours: 24 }, // another window
|
||||
// requireSetup: { windowHours: false }, // no time limit (0 works too): locked until set up, never blocked
|
||||
// requireSetup: { exempt: ({ user }) => user.email === 'integration@example.com' }, // a service account that logs in with a password, on purpose
|
||||
// requireSetup: { dashboardNotice: false, statusField: false, setupNotice: false }, // each panel part can be switched off; the lock stays
|
||||
// requireSetup: false, // the 2FA package's rule: redirect in the panel, API open until setup
|
||||
// resetAccess: ({ req }) => isAdmin(req.user, req.payload), // who may reset / reopen (default: a staff admin; the second factor is always required)
|
||||
}
|
||||
```
|
||||
|
||||
- **Data.** The mode adds a date field `totpSetupFrom` (hidden, written by the plugin only) and a panel-only field
|
||||
`totpSetupStatus` to the 2FA collection. MongoDB: nothing to do. **Postgres / SQLite: create and run a
|
||||
migration** (`pnpm payload migrate:create`); until it has run, the log shows `[ipal] 2FA: could not start the
|
||||
setup window…` and existing accounts have no time limit yet.
|
||||
- **Data.** The 2FA collection gets a date field `totpSetupFrom` (hidden, written by the plugin only) **whenever
|
||||
2FA is on** — also with `requireSetup: false` or `guard: false`, so that switching the mode does not change the
|
||||
schema — and, with the mode on, a panel-only field `totpSetupStatus`. MongoDB: nothing to do.
|
||||
**Postgres / SQLite: the migration is a required step of the same deploy.** Run `pnpm payload migrate:create`, commit the migration, and
|
||||
make sure it is applied (`pnpm payload migrate`, the Coolify pre-deploy command) **before the new version
|
||||
serves requests**. 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
|
||||
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
|
||||
`async` function stops the site at start with a clear error; any answer other than exactly `true` (a Promise,
|
||||
a string, an error) exempts nobody and is logged once. Decide from the fields on `user`. An exempt account
|
||||
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`).
|
||||
generate:importmap` after upgrading (`TwoFactorStatusField`, `TwoFactorAlert`); `ipal-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),
|
||||
`{ setupNotice: false }` (the notice on the setup screen). None of them changes who is refused. The logo and
|
||||
icon fetched by the server for the 2FA screens: `whiteLabel.inlineImages: false`, `adminMeta.serveIcon: false`
|
||||
([white-label.md](./white-label.md)).
|
||||
- **Building blocks** (`@intecion/ipal-kit`), for a project that wires the mode itself: `buildSetupFields`,
|
||||
`stampSetupFrom`, `backfillSetupFrom`, `buildTwoFactorResetEndpoint`, `countAccountsWithoutTotp`,
|
||||
`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.
|
||||
@@ -761,8 +785,43 @@ 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 }` — a staff admin who has passed the second factor
|
||||
(`twoFactor.resetAccess` changes who). The account must set TOTP up again within a new window.
|
||||
it: `POST /api/ipal/two-factor/reset` `{ userId }`. The account must set TOTP up again within a new window.
|
||||
|
||||
- **Who may reset.** By default a staff admin whose session has **entered its own TOTP code**. An admin on an API
|
||||
key, and an admin that `requireSetup.exempt` lets work on its password, are refused: removing someone's second
|
||||
factor should take one. `twoFactor.resetAccess: ({ req }) => boolean` replaces the rule; a session that still
|
||||
owes its code is refused whatever the function says, and only an answer of exactly `true` allows
|
||||
(`req.user._strategy` is `'totp'`, `'api-key'` or `'local-jwt'`).
|
||||
- **A reset ends the account's sessions.** Every token of that account stops working at once; its owner logs
|
||||
in again with the password and sets TOTP up. This matters when the account may be in someone else's hands: a
|
||||
session that had passed 2FA could otherwise enrol a new authenticator without the password (`/api/setup-totp`
|
||||
asks for none). **After a suspected compromise also change the account's password** — the reset does not, and
|
||||
whoever knows the password can log in and set TOTP up within the new window. With `auth.useSessions: false`
|
||||
on the collection there are no sessions to end: tokens live until they expire.
|
||||
- The 2FA package's own remove / reset endpoints (below) do **not** end sessions.
|
||||
|
||||
#### Every administrator is blocked
|
||||
|
||||
When no administrator can get in (each one missed the window, or the only one did), nobody can press "Reopen
|
||||
setup". Two ways out, both need a deploy or shell access — which is the point: the panel alone cannot undo it.
|
||||
|
||||
1. **A script, no redeploy** (`pnpm payload run scripts/reopen-2fa.ts` on the server; Local API, no access
|
||||
check):
|
||||
```ts
|
||||
import config from '@payload-config'
|
||||
import { getPayload } from 'payload'
|
||||
const payload = await getPayload({ config })
|
||||
const { docs } = await payload.find({ collection: 'users', where: { email: { equals: 'admin@example.com' } } })
|
||||
await payload.update({ id: docs[0].id, collection: 'users', data: { totpSetupFrom: new Date().toISOString() } })
|
||||
process.exit(0)
|
||||
```
|
||||
The administrator then logs in and sets TOTP up within the new window, and reopens the others from the panel.
|
||||
2. **No script, one redeploy each way:** set `twoFactor.requireSetup: { windowHours: false }` and deploy — the
|
||||
lock stays (nothing but setup), the time limit is gone, so every blocked account can set TOTP up. When the
|
||||
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.
|
||||
|
||||
The 2FA package has its own reset, off unless you turn it on — through
|
||||
`adminManageAccess` in the @clocklimited configuration. ipalKit passes it only `collection`,
|
||||
@@ -844,8 +903,10 @@ size while reading, content signature, container and macro checks, an optional `
|
||||
The stale import-map notice that comes with it: `twoFactor.importMapCheck: false`; its parts
|
||||
(`findImportMapFile`, `missingImportMapEntries`) are exported too.
|
||||
- **Setup required:** `twoFactor.requireSetup: false` (off), `{ windowHours }` (another window, `false` / `0` = none),
|
||||
`{ exempt }` (a service account), `twoFactor.resetAccess` (who reopens); exported: `twoFactorSetupState`,
|
||||
`twoFactorSetupDeadline`.
|
||||
`{ exempt }` (a service account), `{ dashboardNotice: false }`, `{ statusField: false }`, `{ setupNotice: false }`,
|
||||
`twoFactor.resetAccess` (who reopens); exported: `twoFactorSetupState`, `twoFactorSetupDeadline`,
|
||||
`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);
|
||||
`requireSecondFactor` / `secondFactorPassed` are exported for your own access functions and endpoints.
|
||||
|
||||
+7
-1
@@ -51,6 +51,12 @@ values win over yours); `afterLogin` / `afterNavLinks` are appended.
|
||||
|
||||
## Technology support credit — "Technology support: Intecion.com"
|
||||
|
||||
**On the 2FA screens** (a session that has typed its password but not its code, or has not set 2FA up) the
|
||||
panel's logo and icon cannot be loaded by the browser: that session is refused every collection, `media`
|
||||
included. The server fetches them the way an anonymous visitor gets them (no cookies, images only, at most
|
||||
512 KB) and puts them into the page as a `data:` image. `whiteLabel: { inlineImages: false }` turns the fetch
|
||||
off (the site name is shown instead of a refused image); `fetchPublicImage` / `publicImageDataUri` are exported.
|
||||
|
||||
A discreet line **"Technology support: Intecion.com"** (pl `Wsparcie technologiczne: Intecion.com`,
|
||||
a link to `https://intecion.com`) appears in **two places**:
|
||||
- **under the panel navigation** (`afterNavLinks`, variant `nav` — left-aligned),
|
||||
@@ -84,7 +90,7 @@ image. The plugin now fills the panel's `<head>` from Site settings, **with or w
|
||||
| `og:site_name` | the site name | your `admin.meta.openGraph.siteName` wins |
|
||||
| description | "Administration panel of <site>. Built on Payload CMS, technology support: Intecion.com." (Polish when the site's default locale is `pl`) | `adminMeta: { description: 'Panel of {site}' }` (string or `{ en, pl }`), `false`; `language: 'en' \| 'pl'`; your `admin.meta.description` wins |
|
||||
| preview image | `GET /api/ipal/admin-og` — 1200×630 PNG: the site's logo (or name), "Administration panel", "Technology support: Intecion.com" | `adminMeta: { image: '/my-og.png' }` or `false`; your `admin.meta.openGraph.images` wins |
|
||||
| icon | `GET /api/ipal/admin-icon` — answers with the site's favicon itself (fetched as an anonymous visitor would get it; a redirect only when that is not possible), or draws the initials | `adminMeta: { icons: false }`; your `admin.meta.icons` win |
|
||||
| icon | `GET /api/ipal/admin-icon` — answers with the site's favicon itself (fetched as an anonymous visitor would get it, at most 512 KB, sent with the upload security headers: sandbox policy and `nosniff`, so an SVG is shown but cannot run script; a redirect only when fetching is not possible), or draws the initials | `adminMeta: { icons: false }`; `adminMeta: { serveIcon: false }` = always the redirect to the media file; your `admin.meta.icons` win |
|
||||
| everything | on | `adminMeta: false` = Payload's defaults |
|
||||
|
||||
- **How:** Payload builds every panel page's metadata from `config.admin.meta`. The plugin sets the
|
||||
|
||||
Reference in New Issue
Block a user