Skip to main content

Two-Factor Authentication

Enrolment is two steps on purpose: setup stores the secret unconfirmed, and enable only trusts it once a generated code proves the authenticator holds it — so an abandoned setup cannot lock anyone out.

Setup

Generates a TOTP secret and returns an otpauth:// URI for scanning with an authenticator app. Requires an active session_token.

Idempotent Behavior

Calling setup twice returns the same secret rather than generating a new one. This prevents a QR already scanned into a phone from silently stopping to match. Pass ?regenerate=true as a query parameter to force a fresh secret.

Responses

Errors


Enable

Confirms the TOTP secret generated by /api/v1/auth/2fa/setup by requiring a valid code from the authenticator. Once confirmed, two-factor is enforced on all future logins.

Request

Parameters

Responses

Behavior

  • Activates two-factor authentication on the account.
  • Signs out every other active session (bumps tokenVersion), then reissues the caller’s cookie.
  • Returns 10 single-use recovery codes — shown exactly once. The server stores only their hashes.
  • The clock-drift message is returned when the code matches a step several windows away, indicating a time sync problem rather than a wrong secret.

Errors


Disable

Removes two-factor authentication from the operator account. Requires both the current password and a valid TOTP or recovery code — both factors to remove a factor, so a borrowed session cannot quietly strip the protection.

Request

Parameters

Responses

Behavior

  • Disables two-factor authentication.
  • Clears the TOTP secret and all stored recovery code hashes.
  • Signs out every other active session (bumps tokenVersion), then reissues the caller’s cookie.

Errors