Rate limit account authentication attempts

This commit is contained in:
Hamza Ayed
2026-10-03 00:59:47 +03:00
parent f745bed0f7
commit 5430d4ac4b
6 changed files with 165 additions and 4 deletions
+8
View File
@@ -71,6 +71,14 @@ def initialize_database() -> None:
CREATE INDEX IF NOT EXISTS idx_auth_sessions_user
ON auth_sessions(user_id, expires_at);
CREATE TABLE IF NOT EXISTS auth_rate_limits (
scope TEXT NOT NULL,
fingerprint TEXT NOT NULL,
window_started_at INTEGER NOT NULL,
attempts INTEGER NOT NULL CHECK(attempts >= 0),
PRIMARY KEY(scope, fingerprint)
);
CREATE TABLE IF NOT EXISTS conversations (
id TEXT PRIMARY KEY,
user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,