Лаба 2: PostgreSQL-хранилище и Redis-сессии (оценка 4)

FastAPI + asyncpg + Redis/argon2id. Пользователи/чаты/участники/сообщения
в Postgres с версионируемой миграцией и keyset-пагинацией. Basic-вход,
Bearer-сессии в Redis с TTL и AOF-персистентностью. make check/test/
test-persistence/validate зелёные; evidence по EXPLAIN ANALYZE, короткому
TTL и падению Redis приложены в REPORT.md.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-10-30 00:23:26 +03:00
co-authored by Claude Sonnet 5
parent 65003b6119
commit d12159a8cc
13 changed files with 886 additions and 15 deletions
+16
View File
@@ -0,0 +1,16 @@
"""Password KDF (Argon2id) — never store or compare plaintext passwords."""
from argon2 import PasswordHasher
from argon2.exceptions import VerifyMismatchError, InvalidHashError
_hasher = PasswordHasher()
def hash_password(password: str) -> str:
return _hasher.hash(password)
def verify_password(password: str, password_hash: str) -> bool:
try:
return _hasher.verify(password_hash, password)
except (VerifyMismatchError, InvalidHashError):
return False