Fix the 2FA setup loop: setup-totp?back=null redirected to itself
@clocklimited/payload-2fa's admin provider reads the current path from an x-pathname request header. Nothing sets it on /admin (the createProxy matcher skips /admin), so the path was null: every admin page, the setup screen too, redirected to /admin/setup-totp?back=null, forever. Every new admin on a site with 2FA got stuck. ipalKit now swaps that provider for its own TotpRedirectProvider (@intecion/ipal-kit/admin, client-side): it reads the path in the browser, never redirects away from the setup/verify screens or logout, and renders nothing while redirecting. twoFactor.provider takes a project component, or false to keep the package's. totpRedirectTarget / totpAdminPath export the rules. Projects run generate:importmap. Test: test/totpRedirect.test.ts (redirect walk, provider swap). Dev app: IPAL_DEV_2FA=1 turns 2FA on. Docs: security.md, CHANGELOG (Unreleased), AGENT.md, ipal-setup/-upgrade/-debug/-reference, PROGRAMISTA item 51. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
4e254057f9
commit
60f744e3ad
+12
-1
@@ -1,4 +1,4 @@
|
||||
import type { CollectionSlug, Field, Plugin } from 'payload'
|
||||
import type { CollectionSlug, Field, PayloadComponent, Plugin } from 'payload'
|
||||
|
||||
/**
|
||||
* Factory shape of @clocklimited/payload-2fa's `payloadTotp` export — injected
|
||||
@@ -200,6 +200,17 @@ export type IpalOptions = {
|
||||
* injected factory too. See docs/security.md.
|
||||
*/
|
||||
plugin: TotpPluginFactory
|
||||
/**
|
||||
* Admin provider that sends users to the TOTP setup / verify screens.
|
||||
* Default: ipal-kit's `@intecion/ipal-kit/admin#TotpRedirectProvider`
|
||||
* (reads the path in the browser). The package's own provider needs an
|
||||
* `x-pathname` request header on every /admin request; without it the
|
||||
* setup screen redirects to itself (`setup-totp?back=null`). Pass your
|
||||
* own component path (it gets clientProps `forceSetup` and the package's
|
||||
* serverProps `pluginOptions`), or `false` to keep the package's provider
|
||||
* (then set `x-pathname` on /admin yourself). Run generate:importmap.
|
||||
*/
|
||||
provider?: false | PayloadComponent
|
||||
}
|
||||
| false
|
||||
|
||||
|
||||
Reference in New Issue
Block a user