Admin Two-Factor
Warn or require two-factor authentication for platform admins with requireAdminTwoFactor, and the closed-admin case.
A compromised admin account can ban users, change roles and impersonate. Two-factor authentication (how it works) is the protection, and the admin follows one flag in apps/web/config/admin.config.ts:
export const adminConfig = { requireAdminTwoFactor: false,};requireAdminTwoFactor | Admin without two-factor |
|---|---|
false (default) | Opens /admin and sees a warning |
true | Is sent to /settings/security until they turn it on |
requireAdmin enforces it as well as the middleware, so a direct POST can't skip it.
The warning above the page heading shows its full security explanation and setup link.
Needs AUTH_TWO_FACTOR
With requireAdminTwoFactor: true and AUTH_TWO_FACTOR off, nobody can turn two-factor on, so the admin is closed: it answers 404 and logs an error. pnpm kit:doctor flags this combination. Turn AUTH_TWO_FACTOR on, or the flag off.
Sessions Before Enrollment
Turning two-factor on signs out the user's other sessions (every user, not only admins), so a session stolen before enrollment stops working. The session that enrolled stays signed in.