Skip to main content

Two-Factor Sign-In and Passkeys

Available since v1.12.0 · Configured under Settings → Sign-in & security.

Two-factor authentication protects accounts even if a password is guessed or leaked. torq supports authenticator apps (TOTP), passkeys (WebAuthn), and single-use recovery codes. Passkeys can also replace passwords altogether for passwordless sign-in.

MethodRole in sign-inRequires TORQ_BASE_URL?Notes
Authenticator app (TOTP)2nd step after passwordNo6-digit codes every 30 s; works offline
PasskeyPasswordless (both factors) or 2nd stepYesFingerprint, face, or device PIN; bound to server URL
Recovery codesOne-time backup for 2nd stepNo10 single-use codes generated on first setup

Setup​

  1. Open Settings → Sign-in & security and click Set up under Authenticator app.
  2. Scan the QR code with an authenticator app (Aegis, 2FAS, Google Authenticator, Microsoft Authenticator, or a password manager) or enter the setup key manually.
  3. Enter the 6-digit code shown in the app and click Turn on.

If codes are rejected, verify that your phone's clock is set to automatic network time.

Recovery codes​

When you enable your first second factor, torq generates 10 single-use recovery codes and displays them once. Store them safely (for example in your password manager).

  • Choose Use a recovery code on the second sign-in step if you don't have your device.
  • Settings → Sign-in & security shows how many codes remain. Generate new codes replaces the entire set and invalidates any unused codes from the previous batch.

Requiring 2FA for users or roles​

Administrators can enforce two-factor sign-in:

  • Per role: Settings → Roles → edit role → tick Require two-factor sign-in (also supported on the Administrator role).
  • Per user: Settings → Users → Require 2FA.

Affected users without a second factor can still sign in with their password, but are restricted to Settings → Sign-in & security until they configure an authenticator app or passkey. Users cannot remove their last second factor while 2FA is required.

Lost phone or locked-out user​

(Forgot your password instead? See Password reset — resetting a password keeps your second factor intact.)

  • With a recovery code: Sign in using a recovery code, then reconfigure your authenticator app or add a new passkey.
  • Without a recovery code: Ask an administrator to open Settings → Users and click Reset two-factor sign-in. This removes the user's TOTP secret, passkeys, and recovery codes and signs them out everywhere.
Emergency recovery for the last administrator without a recovery code

Stop torq, back up /data, and remove the second factors for that account directly in SQLite (replace /data/torq.db and 'marek' with your path and username):

sqlite3 /data/torq.db "DELETE FROM user_totp WHERE user_id = (SELECT id FROM users WHERE username = 'marek');
DELETE FROM user_passkeys WHERE user_id = (SELECT id FROM users WHERE username = 'marek');
DELETE FROM user_recovery_codes WHERE user_id = (SELECT id FROM users WHERE username = 'marek');"

Security notes​

Back up secret.key with your database

Authenticator secrets are encrypted using secret.key in /data. Always back up the entire /data directory (see Data and backups); without secret.key, TOTP codes stop working and users must use recovery codes.

  • Recovery codes are stored only as hashes; passkeys are stored only as public keys.
  • Failed second-factor attempts are throttled like failed passwords; a pending 2FA challenge expires after 5 minutes or 5 wrong attempts.
  • In TORQ_DEMO_MODE=true, two-factor sign-in cannot be configured.