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.
| Method | Role in sign-in | Requires TORQ_BASE_URL? | Notes |
|---|---|---|---|
| Authenticator app (TOTP) | 2nd step after password | No | 6-digit codes every 30 s; works offline |
| Passkey | Passwordless (both factors) or 2nd step | Yes | Fingerprint, face, or device PIN; bound to server URL |
| Recovery codes | One-time backup for 2nd step | No | 10 single-use codes generated on first setup |
Setup
- Authenticator app (TOTP)
- Passkey (WebAuthn)
- Open Settings → Sign-in & security and click Set up under Authenticator app.
- Scan the QR code with an authenticator app (Aegis, 2FAS, Google Authenticator, Microsoft Authenticator, or a password manager) or enter the setup key manually.
- 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.
- Ensure
TORQ_BASE_URLis configured with your HTTPS URL (e.g.https://torq.example.com). - Under Settings → Sign-in & security, click Add passkey, give it a name (e.g.
iPhoneorLaptop), and confirm with your device's biometrics or PIN. - You can register multiple passkeys, rename them, or remove them at any time.
TORQ_BASE_URL requirementPasskeys are cryptographically bound to the server's origin. Without TORQ_BASE_URL set, passkeys are unavailable (authenticator apps still work). If you change your domain later, existing passkeys stop working — sign in with your password and re-register them.
A passkey on a hardware security key without user verification (PIN/biometrics) can act as a second step after your password, but cannot be used for passwordless sign-in.
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
secret.key with your databaseAuthenticator 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 minutesor5wrong attempts. - In
TORQ_DEMO_MODE=true, two-factor sign-in cannot be configured.