ЛР 2 — БВТ2304 — Черников

PostgreSQL с версионируемыми миграциями, вход по Basic и Bearer-сессии в Valkey
(AOF), Argon2id, compose-стенд с секретами в файлах. Собственные тесты в
student-tests/, проверки инфраструктуры и EXPLAIN в scripts/, отчёт в REPORT.md,
результаты в evidence/, команды для показа в DEMO.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-15 12:49:28 +03:00
co-authored by Claude Opus 5.5
parent 65003b6119
commit 64b4d00204
42 changed files with 3916 additions and 24 deletions
+25
View File
@@ -0,0 +1,25 @@
"""Хеширование паролей: Argon2id из библиотеки argon2-cffi.
Хеш хранит алгоритм, параметры и соль в одной строке вида $argon2id$v=19$m=...,t=...,p=...$соль$хеш.
"""
import secrets
from argon2 import PasswordHasher
from argon2.exceptions import InvalidHashError, VerificationError
_hasher = PasswordHasher(time_cost=2, memory_cost=19 * 1024, parallelism=1)
_DUMMY_HASH = _hasher.hash(secrets.token_hex(16))
def hash_password(password):
return _hasher.hash(password)
def verify_password(password_hash, password):
"""True, если пароль подходит к хешу; при password_hash=None всегда False за то же время."""
try:
_hasher.verify(password_hash or _DUMMY_HASH, password)
except (VerificationError, InvalidHashError):
return False
return password_hash is not None