Skip to content

two factor authentication implementation#505

Merged
Devsol-01 merged 1 commit intoDevsol-01:mainfrom
Joewizy:feat/two-factor-authentication
Mar 29, 2026
Merged

two factor authentication implementation#505
Devsol-01 merged 1 commit intoDevsol-01:mainfrom
Joewizy:feat/two-factor-authentication

Conversation

@Joewizy
Copy link
Copy Markdown
Contributor

@Joewizy Joewizy commented Mar 29, 2026

Closes #464

Summary

  • Implement TOTP 2FA using Node.js crypto (RFC 6238 compliant, no external deps)
  • Add POST /auth/2fa/enable returning secret, otpauth:// URL for QR codes, and 8 backup codes
  • Add POST /auth/2fa/verify to activate 2FA after confirming a valid token
  • Login flow returns requiresTwoFactor: true when 2FA is active; complete via POST /auth/2fa/validate
  • Backup codes are single-use and consumed on login
  • Admin endpoint to disable 2FA for locked accounts (role-gated)
  • Status check endpoint at GET /auth/2fa/status

Test plan

  • Enable 2FA returns secret, otpauth URL, and 8 backup codes
  • Verify with valid TOTP token activates 2FA
  • Verify with invalid token returns 401
  • Login with 2FA enabled returns requiresTwoFactor: true instead of JWT
  • Validate with correct TOTP returns JWT
  • Validate with backup code returns JWT and consumes the code
  • Validate with invalid token returns 401
  • Disable 2FA clears secret and backup codes
  • Admin disable works for ADMIN role, rejected for USER role
  • Clock drift tolerance (±30s) works correctly

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nestera Ready Ready Preview, Comment Mar 29, 2026 11:26am

@Devsol-01 Devsol-01 merged commit 2a38542 into Devsol-01:main Mar 29, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Two-Factor Authentication (2FA) Support

2 participants