Files
uptimesebi/internal/migrations/sql/00008_recovery_codes.sql
T
Sebastian UnterschützandClaude Opus 5.5 dbea42e7a5 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
2026-11-22 00:35:20 +01:00

14 lines
420 B
SQL

-- +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;