Перевести пароли на Argon2id и читать секреты через AppRole.

Лимит входа общий для реплик, размер тела ограничен, исходящие клиенты проверяют TLS, если задан CA.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-26 19:40:28 +03:00
co-authored by Cursor
parent 54b4b9e509
commit fb566d874c
19 changed files with 445 additions and 20 deletions
+21 -1
View File
@@ -1,7 +1,20 @@
import os
from argon2 import PasswordHasher
from argon2.exceptions import InvalidHashError, VerifyMismatchError
hasher = PasswordHasher(time_cost=2, memory_cost=8192, parallelism=1)
# 19 MiB is the lab floor. Salt and parameters live inside the PHC string.
MEMORY_KIB = int(os.environ.get("ARGON2_MEMORY_KIB") or "19456")
ITERATIONS = int(os.environ.get("ARGON2_ITERATIONS") or "2")
PARALLELISM = int(os.environ.get("ARGON2_PARALLELISM") or "1")
hasher = PasswordHasher(
time_cost=ITERATIONS,
memory_cost=MEMORY_KIB,
parallelism=PARALLELISM,
hash_len=32,
salt_len=16,
)
_dummy = None
@@ -21,3 +34,10 @@ def verify_password(password_hash: str, password: str) -> bool:
return hasher.verify(password_hash, password)
except (VerifyMismatchError, InvalidHashError, TypeError, ValueError):
return False
def needs_rehash(password_hash: str) -> bool:
try:
return hasher.check_needs_rehash(password_hash)
except (InvalidHashError, TypeError, ValueError):
return False