2FA setup required: an account without TOTP reaches only setup, within a 72 h window
twoFactor.requireSetup (on by default with 2FA): an account of the 2FA collection that has not set TOTP up is refused by ipal-kit's second-factor check on every collection, global and plugin endpoint; the setup screen and /api/setup-totp are all it reaches. It has 72 hours from its creation or from an admin's reset (field totpSetupFrom, stamped by a hook); after that setup is refused too until an admin reopens it. Accounts that existed before get their window at the first start after the upgrade (backfill in onInit), so nobody is blocked when a site upgrades. Admin side: status and reset / 'Reopen setup' button on the account page (TwoFactorStatusField), POST /api/ipal/two-factor/reset, a dashboard notice (TwoFactorAlert), a notice on the setup screen; texts in English and Polish. ipal-doctor reports blocked accounts and a switched-off mode. Overridable: requireSetup false, windowHours (false / 0 = none), exempt for a service account, resetAccess; the per-entity second-factor opt-out applies. API keys, seeds, bearer-token routes and sites with twoFactor false are not affected. HTTP tests (REST, GraphQL, first admin on an empty database) run on SQLite, Postgres and MongoDB; a browser test on the reference site covers the first admin, a new editor and the admin's reset. Docs, guide, skills, changelog. Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
45d52c4690
commit
2aaaaa115a
+18
-1
@@ -1,4 +1,4 @@
|
||||
import type { CollectionSlug, Field, PayloadComponent, Plugin } from 'payload'
|
||||
import type { CollectionSlug, Field, PayloadComponent, PayloadRequest, Plugin } from 'payload'
|
||||
|
||||
/**
|
||||
* Factory shape of @clocklimited/payload-2fa's `payloadTotp` export — injected
|
||||
@@ -24,6 +24,7 @@ import type { RevalidatePathFn } from './modules/hooks/buildRevalidateHook.js'
|
||||
import type { I18nConfig } from './modules/i18n/types.js'
|
||||
import type { PagesOption } from './modules/pages/types.js'
|
||||
import type { SafeBackRule } from './modules/security/totp/safeBack.js'
|
||||
import type { RequireSetupOptions } from './modules/security/totp/setupRequired.js'
|
||||
import type { VerifyLimitOptions } from './modules/security/totp/verifyLimit.js'
|
||||
import type { SeoOption } from './modules/seo/types.js'
|
||||
import type { StatsOptions } from './modules/stats/collection.js'
|
||||
@@ -275,6 +276,22 @@ export type IpalOptions = {
|
||||
* (then set `x-pathname` on /admin yourself). Run generate:importmap.
|
||||
*/
|
||||
provider?: false | PayloadComponent
|
||||
/**
|
||||
* "Setup required", on by default: an account that has not set TOTP up
|
||||
* reaches nothing at the access level (REST, GraphQL, the panel's data) —
|
||||
* only the setup screen and its endpoint. It has `windowHours` (default 72)
|
||||
* from its creation, or from a reset by an admin, to set TOTP up; after that
|
||||
* it is blocked until an admin reopens setup (the account's page in the
|
||||
* panel, or POST /api/ipal/two-factor/reset). Accounts that existed before
|
||||
* the mode get the full window from the first start after the upgrade.
|
||||
* `{ windowHours: false }` = no time limit; `{ exempt: ({ user }) => … }` =
|
||||
* accounts that may work without TOTP on purpose (a service account);
|
||||
* `false` = the 2FA package's rule (the panel redirects, the API is open
|
||||
* until setup). Needs `guard` on. docs/security.md.
|
||||
*/
|
||||
requireSetup?: false | RequireSetupOptions
|
||||
/** Who may reset another account's TOTP / reopen its setup. Default: a staff admin. The second factor is always required. */
|
||||
resetAccess?: (args: { req: PayloadRequest }) => boolean | Promise<boolean>
|
||||
/**
|
||||
* Check on the `back` query value of the 2FA setup and verify screens. The
|
||||
* 2FA package sends the browser there after a valid code without looking at
|
||||
|
||||
Reference in New Issue
Block a user