feat: add TOTP 2FA with recovery codes and upload gating - #146
Open
NTBBloodbath wants to merge 2 commits into
Open
NTBBloodbath wants to merge 2 commits into
NTBBloodbath wants to merge 2 commits into
Conversation
- opt-in enrollment in settings via QR code (PNG, EC level Q) + code confirm - 10 single-use hashed recovery codes, shown once on enrollment - login gate: enrolled users pass a `/login/totp` challenge after OAuth - API upload gate (#101): enrolled users must exchange a TOTP code for a 10-minute TFA token (LuaRocks `verify_tfa` protocol, `X-TFA-Token` header) on both `/api/1/:key/upload` and `/api/releases` - rate-limit TOTP verification attempts (10/hr) - verify_totp accepts the previous 30s window to avoid boundary flakes closes #101
NTBBloodbath
marked this pull request as ready for review
September 20, 2026 20:51
NTBBloodbath
marked this pull request as draft
September 20, 2026 21:04
… codes The 2FA feature assumed the database was trusted, which left it exposed if the database were ever exfiltrated. TOTP secrets were stored in plaintext, so a leaked dump would let an attacker mint valid codes indefinitely, and recovery codes were hashed with sha256 over only 40 bits of entropy, making them brute-forceable offline in hours. This encrypts users.totp_secret with Cloak AES-GCM, sourcing the key from the LUANOX_FIELD_ENCRYPTION_KEY environment variable so it never lives alongside the data it protects, and switches recovery codes to argon2id with 96 bits of entropy. Since argon2 is salted and non-deterministic, recovery codes are now verified by iterating the user's hashes rather than a direct code_hash lookup. The unused bcrypt_elixir dependency is also dropped. Requires migration 20260920220434 (totp_secret varchar -> bytea) and the LUANOX_FIELD_ENCRYPTION_KEY variable in production once deployed :)
NTBBloodbath
marked this pull request as ready for review
September 20, 2026 22:22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
/login/totpchallenge after OAuthverify_tfaprotocol,X-TFA-Tokenheader) on both/api/1/:key/uploadand/api/releasescloses #101