feat(auth): trusted devices, recovery codes, and admin MFA management #93
Reference in New Issue
Block a user
No description provided.
Delete Branch "feature/trusted-devices-mfa"
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?
What & why
Reduces 2FA friction without weakening the second-factor boundary, and closes the 2FA-lockout gap. Four deliverables (design:
docs/website/TRUSTED_DEVICES_MFA.md, docs PR: RunicGateway/docs#trusted-devices-mfa):currentPasswordpattern for recovery-code regeneration; disabling TOTP keeps its current-code requirement.Key design points:
token_hashunique index); recovery codes are bcrypt (human-typed, verified against the user's ≤10 rows like a password).rg_trusthttpOnly cookie is a server-side, per-row-revocable record (never a JWT claim), so the stateless session JWT is unchanged and trust stays revocable. It gates only the 2nd factor, survives logout, and is cleared on untrust / password change / password reset / TOTP disable.409 {error:'trusted_device_limit', devices}(ortrustLimitReachedat login); the web client shows a TOTP-styled revoke-to-continue / cancel modal.New tables (
trusted_devices,recovery_codes) are additive/idempotent. Fully backwards-compatible: with norg_trustcookie behavior is exactly today's (TOTP every login).How it was tested
cd server && DB_HOST=127.0.0.1 DB_PORT=59999 node --test→ 414 pass / 0 fail (33 new tests: trusted-device login skip, token mint/hash, recovery-code single-use consume + wrong-code backoff, cap 409, self + admin revocation, invalidation on password change / TOTP disable, and permission/ownership scoping).cd client && npm test→ 43 pass;npm run buildclean.npm run swagger); new endpoints + schemas verified present.Checklist
AI-assisted contributions (required)
Claude Code (Opus 4.8). I have reviewed and understand every change, and take responsibility for it. AI-authored commits are marked with aCo-Authored-Bytrailer.License