fix(auth): make admin 2FA optional via OPUS_REQUIRE_ADMIN_MFA flag #23
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/admin-mfa-optional"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
After creating the admin account, the user is hard-gated behind a mandatory 2FA enrollment page with no skip option. Every API call returns 403 (
mfa_enrollment_required) until 2FA is set up. This contradicts the original design spec (docs/superpowers/specs/2026-09-08-admin-mfa-design.md), which explicitly listed mandatory enforcement as a non-goal:The security checklist (
docs/security-testing-checklist.md:953) also documents it as "opt-in rather than mandatory, which is a documented, deliberate scope decision."Also fixes a typo: "Enrol" → "Enroll" in the MFA setup page.
Solution
Add
OPUS_REQUIRE_ADMIN_MFAenv flag (default:false) to control enforcement mode.When
false(default — opt-in, matches original spec)When
true(mandatory — current behavior preserved)Changes
app/routes/api/utils.py_mfa_enrollment_block()checksOPUS_REQUIRE_ADMIN_MFAapp/routes/api/auth.py/meexposesrequire_admin_mfafrontend/src/context/AuthContext.jsxmfaDismissedper-session state (resets on login/logout)frontend/src/components/ProtectedRoute.jsxfrontend/src/pages/MfaSetup.jsxfrontend/src/components/TwoFactorSettings.jsxcanDisablerespects the flag for admin self-disabletests/test_admin_mfa_required.pyTesting
OPUS_REQUIRE_ADMIN_MFA=1via amandatory_mfafixturerequire_auth/require_adminroutes, go2rtc verify,/mereports the flag, admin can self-disablerequire_admin_mfaNo migration needed
No DB schema changes, no new routes, no new dependencies.