feat: harden authentication (Argon2id by measurement, login limits, body limit)

Apply auth-hardening up to the bench_login label: Argon2id parameters
from [auth] chosen by driver.py argon2-params (m=64 MiB, t=2, p=1),
rehash on login, per-process KDF budget with 429, shared login failure
limit in Valkey with a local fallback, X-Forwarded-For from HAProxy,
64 KiB body limit (400) in LB and middleware, bench login profile,
tests, threat model and trust matrix rows. Hypotheses H1-H4 are
committed here before the baseline label.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 17:52:48 +03:00
co-authored by Claude Opus 5.5
parent 5573973670
commit 13fdd187c6
57 changed files with 4184 additions and 175 deletions
+16 -2
View File
@@ -33,6 +33,9 @@ CAPABILITIES = (
"message-broker",
# с change track1-queue-overload
"queue-overload",
# с лабы 7 (change auth-hardening, design, решение 10): до archive файла
# спека нет — сценарии пусты, маркеры — «unknown scenario»
"login-protection",
)
SCENARIO_RE = re.compile(r"^#### Scenario: (.+?)\s*$", re.MULTILINE)
@@ -157,6 +160,13 @@ EXCLUDED: dict[Scenario, Exclusion] = {
"разные хэши одинаковых паролей, пароля нет в pg_dump базы — "
"evidence/auth/passwords-and-tokens.md",
),
("users", "Замер на стенде"): Exclusion(
reason="замер времени и памяти хэша в образе API под лимитами "
"реплики, а не поведение по HTTP (change auth-hardening, решение 1)",
check="driver.py argon2-params: методика, сетка, правило выбора и "
"строка «Выбрано» (её сверяет test_settings.py с умолчаниями) — "
"evidence/auth/argon2-params.md",
),
("message-broker", "Сервис брокера запущен"): Exclusion(
reason="образ, volume и порты контейнера видны только в Docker",
check="driver.py --port <LB> broker-check: образ с тегом и digest, "
@@ -234,8 +244,12 @@ COLLECTED = pytest.StashKey[Collected]()
def spec_scenarios(capability: str, specs_dir: Path = SPECS_DIR) -> list[str]:
text = (specs_dir / capability / "spec.md").read_text(encoding="utf-8")
return SCENARIO_RE.findall(text)
"""Сценарии основного спека; новой capability до archive change спека
ещё нет — пустой список, а не падение сверки."""
path = specs_dir / capability / "spec.md"
if not path.is_file():
return []
return SCENARIO_RE.findall(path.read_text(encoding="utf-8"))
def all_scenarios(