feat: PostgreSQL, Bearer-сессии (Valkey/PostgreSQL), Argon2id, миграции, compose
- схема и миграции (migrations/0001_init.sql, python -m messenger.migrate); - регистрация с паролем (Argon2id), вход по Basic, opaque Bearer, logout, expiry; - сессии: SESSION_STORE=valkey (AOF, appendfsync always) или postgres; - пул соединений, statement/lock timeout и клиентский дедлайн: отказ БД = 503; - keyset-пагинация по индексу (chat_id, created_at, id), два запроса без OR; - compose.yaml с закреплёнными образами, secrets, restart.sh. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
893beaa79a
commit
01524165dd
@@ -16,6 +16,9 @@ from .validation import UUID_RE
|
||||
B64_RE = re.compile(r"[A-Za-z0-9_-]{1,512}")
|
||||
TS_RE = re.compile(r"[0-9]{1,19}")
|
||||
|
||||
# Latest instant both Python datetime and PostgreSQL accept: 9999-12-31T23:59:59.999999Z.
|
||||
MAX_TS_US = 253402300799999999
|
||||
|
||||
MESSAGES = "m"
|
||||
CHATS = "c"
|
||||
|
||||
@@ -44,6 +47,8 @@ def decode(cursor: str, scope: str, owner_id: str) -> SortKey:
|
||||
if TS_RE.fullmatch(ts) is None or UUID_RE.fullmatch(item_id) is None or item_id != item_id.lower():
|
||||
raise bad
|
||||
key = (int(ts), item_id)
|
||||
if key[0] > MAX_TS_US:
|
||||
raise bad # out-of-range time must be 400, not an overflow (500) in datetime/SQL
|
||||
if encode(got_scope, got_owner, key) != cursor:
|
||||
raise bad # only the canonical form produced by the server is accepted
|
||||
if got_scope != scope or got_owner != owner_id:
|
||||
|
||||
Reference in New Issue
Block a user