Repository navigation
feat(auth): two-factor sign-in (TOTP) with a reminder until it's on (v0.472.0) - #909
Merged
Merged
Conversation
…v0.472.0) A magic link can leak (the recovery path DMs it to chat and logs it), so a member can now require an authenticator-app code as well. A link used by a 2FA member mints a pending session every gate refuses until POST /api/auth/2fa/verify swaps it for a fresh one. Recovery codes, admin reset, `agent-os 2fa-reset`, and a reminder dialog on every new sign-in and every N days (Settings → Governance). Zero new dependencies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Opt-in TOTP two-factor sign-in for console members, plus a reminder for everyone who hasn't turned it on — on every new sign-in and/or every N days (workspace setting, default both, 7 days).
Why
Login is magic-link and links leak: self-service recovery DMs them to Slack/Discord and writes them to
server.log. A second factor on the human's phone means a leaked link alone signs nobody in.How
auth_sessions.mfa_pending, 10 min).resolveSession/presenceignore it, so the member API, terminal proxy and nginxauth_requestall see "logged out"./api/auth/me401s withmfaRequiredso the console shows a code screen. PublicPOST /api/auth/2fa/verifyswaps it for a fresh sid. Wrong codes are capped at 5 per pending session (then it's destroyed) and 20 per IP per 15 min.agent-os 2fa-reset <email>is the last resort from the box.twoFactor.nagon/api/auth/meopens a dialog with "Set it up" / "Not now". "Not now" quiets it for the rest of that login and restarts the N-day clock. Cadence is set in Settings → Governance → Two-factor reminders, which also shows how many members have 2FA on.node:crypto. The QR code comes from a small server-side encoder (src/governance/qr.ts), checked bit-for-bit againstqrencode -l Mfor v1/v9/v13.Verification
scripts/two-factor-test.cjs: 59 assertions covering the RFC 6238 vectors, the QR matrix vs qrencode, at-rest storage, the pending-session gate, lockout, recovery-code burn, role rules for reset, the policy cadences, and cleanup on member removal. Added totest:governance.npm run test:governancepasses (conformance 159/159).Not in scope (follow-ups)
🤖 Generated with Claude Code