Files
mtusi2026lab7/migrations/006_login_rate_limit.sql
T
allerg1q c188a3beca
Skeleton contracts / contracts (pull_request) Blocked by required conditions
feat(lab7): implement secure messenger infrastructure with TLS, OpenBao and observability
2026-11-29 18:06:02 +03:00

16 lines
470 B
SQL

-- Shared login rate limiter for both API replicas.
-- One bucket per normalized username.
-- Only SHA-256 of the bucket identity is stored.
CREATE TABLE IF NOT EXISTS login_attempt_buckets (
bucket_key TEXT PRIMARY KEY,
window_started_at TIMESTAMPTZ NOT NULL,
attempts INTEGER NOT NULL DEFAULT 0
CHECK (attempts >= 0)
);
CREATE INDEX IF NOT EXISTS
idx_login_attempt_buckets_window
ON login_attempt_buckets (window_started_at);