Skip to content

feat(auth): add TOTP two-factor authentication (#495) - #772

Open
chbndrhnns wants to merge 1 commit into
oblien:mainfrom
chbndrhnns:feature/totp-2fa
Open

feat(auth): add TOTP two-factor authentication (#495)#772
chbndrhnns wants to merge 1 commit into
oblien:mainfrom
chbndrhnns:feature/totp-2fa

Conversation

@chbndrhnns

Copy link
Copy Markdown
Contributor

Fixes #495

Summary

Adds TOTP-based two-factor authentication (2FA) for user accounts using Better Auth's twoFactor plugin, including TOTP verification, backup recovery codes, database schema migrations, export/import secret handling, and dashboard account security settings.

Key Changes

  • Backend & Auth Configuration (apps/api):

    • Enabled Better Auth twoFactor plugin in apps/api/src/lib/auth.ts.
    • Added secret codec support and registry integration for two_factor.secret and two_factor.backup_codes in system data-transfer.
    • Added tests for 2FA lifecycle and secret encryption/export/import in apps/api/test/lib/two-factor-auth.test.ts and apps/api/src/modules/system/data-transfer/secret-codec.test.ts.
  • Database Schema & Migrations (packages/db):

    • Added twoFactorEnabled column to user table and defined twoFactor table in packages/db/src/schema/auth.ts.
    • Added Drizzle migration 0117_mature_wasp.sql and updated snapshot meta and database dump definitions.
  • Dashboard UI & Auth Flow (apps/dashboard):

    • Added Account Security section in Settings (/settings) to enable/disable 2FA, display QR code / manual setup key, and generate/view backup codes.
    • Added 2FA challenge page (/two-factor) with support for TOTP code input and backup code fallback.
    • Updated login flow (/login) to route to two-factor challenge when required.
    • Added English locale translations (en/auth.json, en/settings.json) and tests for login redirection, two-factor next routing, and i18n parity.

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.

MFA for server accounts

1 participant