feat(auth): add single-use totp recovery codes

Codes are stored as SHA-256 hashes and consumed with one conditional
update, so concurrent use of the same code succeeds at most once.

Refs #40

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-22 00:35:20 +01:00
1 parent 3f21361995
commit dbea42e7a5
9 files changed
+248

No files matched your search

@@ -0,0 +1,13 @@
-- +goose Up
-- Like users, these rows belong to a person rather than an organization and
-- are not under row-level security.
CREATE TABLE recovery_codes (
user_id uuid NOT NULL REFERENCES users (id) ON DELETE CASCADE,
code_hash bytea NOT NULL,
used_at timestamptz,
created_at timestamptz NOT NULL DEFAULT now(),
PRIMARY KEY (user_id, code_hash)
);
-- +goose Down
DROP TABLE recovery_codes;