diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index e5e00ae..cc8c1e0 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -8,7 +8,48 @@ 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 — 2FA setup required (version to be set at release) +## 1.16.6 + +> **Read before upgrading — this is not a routine patch.** It turns on a new default for every site with 2FA: an +> account that has not set 2FA up can do nothing but set it up, and is **blocked after 72 hours** until an +> administrator reopens it. On Postgres / SQLite it also needs a **migration in the same deploy, or nobody can log +> in**. Work through the list below, and agree the deploy day with the owner. + +### Requires project changes (what projects must update) +**Every site with 2FA on. Do all of it in ONE deploy.** +- **Before upgrading a live site:** `pnpm exec ipal-doctor --url ` → accounts without 2FA. Each sets 2FA up + now, or is removed. At least one administrator (better two) must have 2FA set up, or nobody can reopen setup + from the panel. +- **Agree the day 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. +- **In the same deploy:** the update, `pnpm payload generate:types`, `pnpm payload generate:importmap` (commit + `importMap.js`; new: `TwoFactorStatusField`, `TwoFactorAlert`), `rm -rf .next`, redeploy. Run + `pnpm exec ipal-doctor` before deploying: it reports a map without the new entries (then the panel has no "Reopen + setup"). Coming from before 1.16.5, the map must also have `SafeTotpView`, or the 2FA screens have no code form. +- **Postgres / SQLite — required, in the same deploy: `pnpm payload migrate:create`, commit, and the migration + applied when the new container starts** (`prodMigrations`, or `pnpm payload migrate && pnpm start` — + [deployment.md §4.3](./deployment.md#43-database-migrations-postgres); not Coolify's Pre-deployment command, + which runs in the old container). 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 === '…' }`. +- **Own code** calling `payload.find({ …, user, overrideAccess: false })` with a user fetched by id: refused for + every account of the 2FA collection now (before: only accounts with TOTP set up). Use `payload.auth({ headers })`. +- **A reset by an administrator logs that account out everywhere** and needs the administrator's own TOTP code. A + script on an API key needs `twoFactor.resetAccess`. After a suspected compromise change the password too. +- **Options:** `windowHours` is a number (0 or more) or `false`; `exempt` is a plain function returning exactly + `true`, never `async`. A wrong value stops the build and the start with a clear error. +- **After deploy:** read the log line `[ipal] 2FA: N existing account(s) without two-step verification…` and tell + the owner; after 72 hours such an account needs "Reopen setup" from an administrator. Tell the staff: a new account has + 72 hours to set 2FA up. `pnpm ipal:skills`. +- **An SVG favicon** has no tab icon on the 2FA screens (use a PNG if that matters). +- **Every administrator is blocked:** security.md "Every administrator is blocked" (a script, or + `{ windowHours: false }` and a redeploy). +- **Not wanted on a site:** `twoFactor.requireSetup: false` (the previous behaviour), or + `{ windowHours: false }` to keep the lock without the time limit. Sites with `twoFactor: false` are not affected. ### Changed - **An account without two-step verification can only set it up** (`twoFactor.requireSetup`, on by default with @@ -42,7 +83,7 @@ once there are more than 20. `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 + `publicImageDataUri`, `rasterImageType`, `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. @@ -56,30 +97,22 @@ once there are more than 20. - 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. -### Requires project changes -- **Before upgrading a live site:** `pnpm exec ipal-doctor --url ` → 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). `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 — required, in the same deploy: `pnpm payload migrate:create`, commit, and the migration - applied when the new container starts** (`prodMigrations`, or `pnpm payload migrate && pnpm start` — - [deployment.md §4.3](./deployment.md#43-database-migrations-postgres); not Coolify's Pre-deployment command, - which runs in the old container). 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 === '…' }`. -- **Own code** calling `payload.find({ …, user, overrideAccess: false })` with a user fetched by id: refused for - every account of the 2FA collection now (before: only accounts with TOTP set up). Use `payload.auth({ headers })`. -- **After deploy:** read the log line `[ipal] 2FA: N existing account(s) without two-step verification…` and tell - the owner; after 72 hours such an account needs "Reopen setup" from an administrator. -- **Not wanted on a site:** `twoFactor.requireSetup: false` (the previous behaviour), or - `{ windowHours: false }` to keep the lock without the time limit. Sites with `twoFactor: false` are not affected. +### Known limitations +- **Inside the window** someone who knows the password of an account without 2FA can still set it up with their own + authenticator; the owner is then refused ("already set") and has to ask an administrator. Set 2FA up at once. +- A session without 2FA keeps what Payload gives any session about itself: `/api/access`, token refresh, logout, its own + panel preferences. +- **An exempt account** works on its password alone, with everything its role allows: give it the lowest role. +- A second staff collection (`access.staffCollections`) is outside 2FA and outside this mode, as before. With + `twoFactor.guard: false` the mode is off and the reset endpoint does not exist. +- With `auth.useSessions: false` a reset has no sessions to end: tokens live until they expire. The 2FA package's own + remove / reset endpoints do not end sessions. +- The `ipal-doctor` migration check is a text search in `src/migrations` and `migrations`. +- A site that does not use `buildUploadSecurityHeaders()` still serves a scripted SVG from its media URL as before. +- **Not run for this release:** a generated migration, `prodMigrations` and a real Coolify deploy (the missing and the + added column were tested on Postgres 17 and SQLite); an upgrade of a real site; two containers; media on R2 / S3; + `useSessions: false`; the reset by an API-key admin over HTTP; payload-2fa beta.1 and the Polish notices in a + browser; Firefox / WebKit; a Docker image; a Next `basePath`; Payload below 3.94.1. ## 1.16.5 diff --git a/package.json b/package.json index 721209e..b6b3ba3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@intecion/ipal-kit", - "version": "1.16.5", + "version": "1.16.6", "description": "Intecion Payload Advanced Library — a Payload CMS 3 plugin: i18n, SEO, forms, consent, analytics, blog/archives.", "license": "MIT", "repository": {