Two-factor authentication (TOTP)
Add a second factor to your account login so a leaked password alone can never take over your Hoopoe. TOTP is optional and per-user — each account decides for itself whether to enrol, and the extra step only appears at sign-in for the accounts that opted in.
Hoopoe's 2FA uses the RFC 6238 TOTP standard: a 6-digit code that rotates every 30 seconds, generated by any authenticator app you already use (Google Authenticator, Aegis, 1Password, Bitwarden, Ente Auth, …). No SMS, no email, no push — just the app on your phone (or a hardware key that emulates one).
When to enrol
The single-user home-server setup on a trusted LAN is already tolerable without 2FA: physical access controls the perimeter and Hoopoe is not exposed to the public internet. Enrol if any of the following apply:
- You reused the Hoopoe password anywhere else (a breach elsewhere then hands the attacker a working login here).
- Someone on the LAN could get a look at a written or saved password.
- You exposed Hoopoe beyond the LAN (a reverse tunnel, a Tailscale/VPN bridge, an nginx port-forward on your router).
- You just want the extra assurance — enrolment takes about a minute and disabling it later is a few clicks.
Enrolling
Réglages → Sécurité → Double authentification (2FA) → Activer.
- Confirm your password. Hoopoe asks for your current account password before generating the secret. This defends against a stolen session silently enrolling a factor an attacker controls and locking you out of your own account.
- Scan the QR code. Open your authenticator app, add a new account, and scan the QR. If the app can't read a QR (a hardware authenticator, a headless setup), the manual key below the QR is the same secret in base32 — type it into the app instead.
- Enter the current 6-digit code shown by the app and click Vérifier. This proves the secret made it into the app before Hoopoe flips the account into "2FA active" state.
- Save your recovery codes. Ten single-use codes are shown once, right after the verify step. Print them, paste them into your password manager, save them to an encrypted file — anywhere that survives losing your phone. You cannot see them again after closing the modal, but you can regenerate a fresh set at any time (which invalidates the previous ones).
Closing the modal before the final step abandons the enrolment: the pending secret is discarded and 2FA stays off. Nothing to clean up.
Signing in with 2FA
Once enrolled, the login flow gains a second step:
- Type your username and password on the login screen, as usual.
- When the password is correct, the screen swaps to a 6-digit code field. Open your authenticator app and type the current code for Hoopoe.
- If you don't have the app to hand (lost phone, out of battery), click Utiliser un code de récupération and type one of the codes you saved at enrolment. Codes are single-use — the count in Settings drops by one each time you burn one.
- The Se déconnecter link at the bottom returns you to step 1 without completing the second factor — useful if you started to log in on the wrong account.
The 6-digit code has ±30 s of slop, so a small clock drift between your phone and the Hoopoe server does not fail the check.
Recovery codes
- 10 codes, single-use each. Once a code is used to sign in, it cannot be used again. The count of remaining codes is shown in Réglages → Sécurité → Double authentification.
- They are hashed at rest (argon2id, same parameters as your password). Even someone with database access cannot recover the original codes.
- When you run out, TOTP still works — only the recovery path is gone. Regenerate a fresh set from the Security page.
- Regenerating invalidates every previous code immediately and requires re-entering your account password. You'll see the same "save them once" modal you saw at enrolment.
Losing your phone and your recovery codes at the same time locks you out of the account permanently — the secret is encrypted at rest and cannot be reset without server-side access. Keep the codes somewhere separate from the device that generates the TOTP codes.
Disabling
Réglages → Sécurité → Double authentification → Désactiver.
Disabling requires both your current account password and a valid TOTP or recovery code. Neither alone is enough — this way a leaked password can't turn 2FA off on its own, and a stolen unlocked device can't disable it either.
On success, both the encrypted secret and every recovery code are deleted from the database. Re-enrolling later goes through the same flow from scratch and generates a fresh secret + fresh codes.
Backups and moving Hoopoe to a new machine
TOTP is deliberately not included in backups. The account is tied to the specific Hoopoe installation that generated the secret, in the same way a browser session cookie is tied to a specific browser. Restoring a JSON dump into a fresh Hoopoe install carries over your transactions, accounts, categories, rules, budgets, and attachments — but the 2FA state is left off.
The consequence: after restoring to a new install, log in with your password only and re-enrol 2FA from scratch. Delete the old codes from your authenticator app once the new secret is confirmed.
This is intentional — treating 2FA as portable would mean that anyone who got a copy of a backup could clone the secret and generate valid codes for your account. Keeping it per-install requires the physical Hoopoe machine to be part of the compromise.
Where the secret lives
Your TOTP secret is stored encrypted at rest in the user_totp
table: AES-256-GCM with a key derived from your SESSION_SECRET
(HKDF-SHA256), and the user id is bound as additional authenticated
data. The plaintext secret only ever exists in memory long enough to
verify a submitted code.
Rotating SESSION_SECRET therefore invalidates every enrolled TOTP —
after a rotation, users see "Code invalide" until they re-enrol. This
is the same behaviour that already applies to session cookies and
bank-sync credentials; see the SECURITY.md notes for the rotation
runbook.
What 2FA does — and does not — protect against
Protects against:
- A leaked or reused password. Someone with only the password cannot pass step 2.
- Silent 2FA hijack from a stolen session cookie. Enrolling, disabling, and regenerating codes all require the account password — a cookie alone cannot pivot into persistent access.
Does not protect against:
- A compromise of the server itself. Anyone with shell on the
machine can read every user's
SESSION_SECRETand decrypt every TOTP secret. Same story as bank-sync credentials — inherent to any self-hosted-with-server-side-secrets design. - Real-time phishing or MitM inside the LAN. A live proxy could relay both the password and the current 6-digit code within its 30-second window. HTTPS terminated by nginx is the mitigation for the MitM path.
- A stolen phone with the authenticator unlocked. Same class as "stolen password + stolen phone" — orthogonal to TOTP. Use a passcode on your phone and your authenticator app.
See also
- Security and privacy — Hoopoe's overall security model.
- Encryption at rest — how the database file itself is protected.
- Backup and recovery — what backups do and do not carry (including this feature).