wip: apply auth-hardening (interrupted by session end)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 16:22:11 +03:00
co-authored by Claude Opus 5.5
parent f014f7bc0d
commit cf0f6256d3
26 changed files with 1728 additions and 64 deletions
+18 -1
View File
@@ -2,7 +2,7 @@ from collections.abc import Iterable
from dataclasses import asdict
from uuid import UUID
from sqlalchemy import select
from sqlalchemy import select, update
from sqlalchemy.dialects.postgresql import insert as pg_insert
from sqlalchemy.ext.asyncio import AsyncSession
@@ -55,6 +55,23 @@ class SqlAlchemyUserRepository(AbstractUserRepository):
password_hash=password_hash,
)
async def update_password_hash(
self,
*,
user_id: UUID,
old_hash: str,
new_hash: str,
) -> bool:
"""Условный UPDATE: безусловный затёр бы новый хэш параллельного
входа старым пересчётом."""
statement = (
update(User)
.where(User.id == user_id, User.password_hash == old_hash)
.values(password_hash=new_hash)
.returning(User.id)
)
return (await self._session.execute(statement)).first() is not None
async def get_existing_user_ids(
self,
*,