Two-Factor Authentication
Any member can add a second step to sign-in: after the password, a 6-digit code from an authenticator app (TOTP, RFC 6238). A stolen or guessed password is then not enough. Admins can require it for moderators and admins.
Trackarr has no e-mail: an account is a username and a password. Nothing can be "sent" to a member who lost their phone, so recovery relies on recovery codes, on an admin, or on a command run on the server. Read Lost device before turning the staff requirement on.
For members
User menu → Account security (/security).
- Set up: the page asks for your password again (an open session alone must not be enough to enrol an authenticator: whoever holds a stolen cookie does not hold the password), then shows a setup key (grouped in fours, with a copy button) and an
otpauth://link that opens an authenticator app on the same device. Any TOTP app works: Aegis, 2FAS, Google Authenticator, a password manager. Settings, if the app asks: time-based, SHA-1, 6 digits, 30 seconds. - Confirm with a first code. Until then nothing changes: a setup left unfinished does not lock anyone out. Turning it on signs every other session of the account out, so one opened with a stolen password does not outlive it.
- Store the recovery codes: ten codes, shown once. Each one signs in once in place of a code from the app. Only their hashes are stored, so they cannot be displayed again.
From then on the login page asks for the code after the password. A recovery code is accepted in the same field.
On the same page, with a current code:
- New recovery codes: replaces the list (the old codes stop working).
- Turn off: also accepts a recovery code. The secret and the recovery codes are erased.
A code works once: even inside its 30 seconds, it cannot be replayed. Wrong codes count as failed logins (see Login protection).
Requiring it for staff
Admin → Security → Two-factor authentication for staff. Off by default.
When on, every admin and moderation tool refuses a moderator or admin who has not turned two-factor on (403, data.code: "two_factor_setup_required"), and the site sends them to Account security instead of the panel. Until they set it up they are ordinary members everywhere: the staff powers of member pages (deleting someone's comment or forum post, editing someone's torrent) are withheld too, with a session or with an API key. Members are not concerned.
- An admin can only turn the requirement on once their own two-factor is on. Otherwise they would close the admin panel on themselves, this setting included.
- The card shows how many staff members already have it on. The others keep their account and lose the staff tools until they set it up: warn them first.
- The setting is cached for up to a minute on each app node.
Lost device
| Situation | Way back in |
|---|---|
| Phone lost, recovery codes kept | Sign in with a recovery code, then turn two-factor off and set it up again |
| Phone and recovery codes lost | An admin opens the member's profile: Moderation → Reset two-factor. The member is signed out everywhere and signs in with their password alone. The reset is recorded in the staff audit log |
| The only admin lost everything | The command below, on the server |
An admin resetting a member is trusting that the request comes from that member: there is no e-mail to check. Use whatever you know about them (private messages before the loss, a known contact).
Reset from the server
For an admin with no other admin to ask. Having a shell on the server is the proof of identity:
cd /opt/trackarr
sudo ./scripts/reset-2fa.sh USERNAMEIt turns two-factor off for that account, erases its secret and recovery codes, and signs it out everywhere. The password then signs in alone. Set two-factor up again right away: while the staff requirement is on, the admin panel stays closed until then.
The script runs one SQL statement in the postgres service of docker-compose.prod.yml. The database password is read inside the container, never passed on a command line. Without Docker, the same statement in psql:
UPDATE users
SET totp_secret = NULL, totp_enabled = false, totp_last_step = 0,
totp_recovery_codes = '{}', session_version = session_version + 1
WHERE username = 'USERNAME';What is stored
Column (users) | Content |
|---|---|
totp_secret | The shared secret (base32). Needed in clear to check codes, like in every TOTP implementation |
totp_enabled | Whether a first code confirmed the secret. A pending secret does not count |
totp_last_step | Last 30-second step a code was accepted for: an older or equal step is refused |
totp_recovery_codes | SHA-256 of the unused recovery codes |
The secret is as sensitive as a password verifier: keep database backups encrypted (Backup & Restore). Panic mode encrypts the secret and the recovery codes with the other credentials.