Исправить logout при сбое записи в кэш сессий

This commit is contained in:
Ilya
2026-10-15 14:00:24 +03:00
parent 13fa1852cb
commit a8b160346d
5 changed files with 91 additions and 9 deletions
+3 -2
View File
@@ -14,7 +14,7 @@ from starlette.concurrency import run_in_threadpool
from app import config
from app.cache import REVOKED, SessionCache
from app.errors import BASIC_CHALLENGE, unauthorized
from app.errors import BASIC_CHALLENGE, ApiError, unauthorized
from app.storage import Store, fmt_ts, user_row
_hasher = PasswordHasher()
@@ -109,4 +109,5 @@ async def logout(store: Store, cache: SessionCache, header: Optional[str]) -> No
if expires_at is None:
raise unauthorized("session expired or revoked")
remaining = int((expires_at - datetime.now(timezone.utc)).total_seconds()) + 1
await cache.revoke(digest, remaining)
if not await cache.revoke(digest, remaining):
raise ApiError(503, "unavailable", "logout not confirmed by session cache, retry later")