Skip to main content

Multi-Factor Authentication (MFA)

DocuTrust supports Time-Based One-Time Password (TOTP) MFA, compatible with any authenticator app that implements the TOTP standard (RFC 6238), including Google Authenticator, Authy, 1Password, and Microsoft Authenticator.

Setup Flow

Step 1: Initiate MFA Setup

Request a new TOTP secret and QR code for the authenticated user.
Response 200 OK
Display the qr_svg to your user so they can scan it with their authenticator app. Alternatively, provide the secret for manual entry.

Step 2: Confirm MFA Setup

After the user scans the QR code and generates their first code, confirm the setup by submitting the 6-digit code.
Request Body Response 200 OK
Store backup codes securely. They are only shown once at setup time and cannot be retrieved later. Each code can be used exactly once.

Step 3: Check MFA Status

Query the current MFA status for the authenticated user.
Response 200 OK

Step 4: Disable MFA

Disable MFA by providing a valid TOTP code from the authenticator app.
Request Body Response 200 OK
If account-level MFA enforcement is active (mfa_enforced setting), individual users cannot disable MFA. The request will return 403 Forbidden.

Login Flow with MFA

When MFA is enabled, the login flow becomes a two-step process:
  1. Password authentication: The user submits their email and password to POST /login. If the credentials are valid and MFA is enabled, the response returns a 302 redirect to /mfa/verify instead of completing the login.
  2. TOTP verification: The user is presented with a form to enter their 6-digit TOTP code (or a backup code). Upon successful verification, the session is created and the user is redirected to the dashboard.

Account-Level MFA Enforcement

Administrators can enforce MFA for all users in the account by enabling the mfa_enforced setting in Settings > Security. When MFA enforcement is active:
  • Users who have not set up MFA are redirected to the MFA setup page on login and cannot access any other admin pages until MFA is configured.
  • Users cannot disable their own MFA (the disable endpoint returns 403 Forbidden).
  • New users must configure MFA as part of their first login.

Backup Codes

Each user receives 8 backup codes when MFA is first enabled. Backup codes are:
  • Single-use: Each code can only be used once.
  • Shown once: Codes are only displayed at MFA setup time. They cannot be retrieved later.
  • Equivalent to TOTP codes: A backup code can be entered anywhere a TOTP code is requested (login, disable MFA, etc.).
  • Tracked: The backup_codes_remaining field on the status endpoint shows how many unused codes remain.
If a user runs out of backup codes and loses access to their authenticator app, an administrator must disable MFA for that user from the admin panel.

Error Responses