# Admin Two-Factor

> Warn or require two-factor authentication for platform admins with requireAdminTwoFactor, and the closed-admin case.

*Canonical: https://makerkit.dev/docs/void-cloudflare/admin/admin-two-factor*

---

A compromised admin account can ban users, change roles and impersonate. Two-factor authentication ([how it works](../authentication/two-factor)) is the protection, and the admin follows one flag in `apps/web/config/admin.config.ts`:

```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.
