Skip to content

Two-factor authentication (TOTP) for user accounts #65

Closed

Description

@JuansesDev

User accounts can only be protected by a password today. Add TOTP-based 2FA (Authy, Google Authenticator, 1Password, etc.) for all users, with the option for Team workspace owners to require it for every member.

What's needed

Backend

  • New columns: users.totp_secret (encrypted with the same key used for SMTP passwords), users.totp_enabled bool, users.totp_enabled_at timestamptz
  • New table: user_recovery_codes (id, user_id, code_hash, used_at) — 10 codes generated at enrollment, hashed at rest, single-use
  • Endpoints:
    • POST /api/v1/auth/totp/setup — returns provisioning URI + QR PNG + 10 recovery codes (only shown once)
    • POST /api/v1/auth/totp/verify — confirms the code and flips totp_enabled = true
    • POST /api/v1/auth/totp/disable — requires current password + valid TOTP code
    • POST /api/v1/auth/login — accepts an optional totp_code field; returns 403 with code: totp_required when 2FA is on and no code was supplied
  • Workspace setting: workspaces.require_totp — when true, members without 2FA can't access workspace endpoints (Team)

Frontend

  • Profile screen → Two-factor authentication section: enroll flow (QR + 6-digit confirm + recovery codes display + download)
  • Login flow: second screen for the TOTP code when the API returns totp_required
  • Members page (Team): owner toggle "Require 2FA for all members"; members without 2FA see a banner telling them to enable it

Audit

  • Log auth.totp_enabled, auth.totp_disabled, auth.totp_recovery_used to the audit log

Tier

  • Free / Pro: opt-in per user. Security shouldn't be paywalled.
  • Team: workspace owners can additionally require it for everyone.

Activity

  1. added
    enhancement
    roadmap
    on May 6, 2026
  2. added a commit that references this issue on Jun 12, 2026
  3. JuansesDev commented on Jun 17, 2026

    @JuansesDev
    MemberAuthor

    Shipped in v0.6.5.1 — TOTP two-factor authentication with recovery codes, plus new-device step-up. Closing as completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendenhancementfrontendroadmapsecurity

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions