forked from mtusi2026/mtusi2026lab7
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:
@@ -22,6 +22,7 @@ from src.core.ports.attachment_variant import (
|
||||
)
|
||||
from src.core.ports.chat import AbstractChatRepository
|
||||
from src.core.ports.idempotency import AbstractIdempotencyRepository
|
||||
from src.core.ports.login_limit import AbstractLoginLimiter
|
||||
from src.core.ports.message import AbstractMessageRepository
|
||||
from src.core.ports.session import AbstractSessionRepository
|
||||
from src.core.ports.user import AbstractUserRepository
|
||||
@@ -40,6 +41,7 @@ from src.core.repos.session import SqlAlchemySessionRepository
|
||||
from src.core.repos.user import SqlAlchemyUserRepository
|
||||
from src.infra.broker import JobPublisher
|
||||
from src.infra.cache import Cache
|
||||
from src.infra.login_limit import ValkeyLoginLimiter
|
||||
from src.infra.render import ImageRenderer
|
||||
from src.infra.s3 import ObjectStorage
|
||||
from src.infra.s3.client import StoredObject
|
||||
@@ -92,10 +94,17 @@ REPOSITORIES = (
|
||||
SqlAlchemyAttachmentJobReplayRepository,
|
||||
fakes.FakeAttachmentJobReplayRepository,
|
||||
),
|
||||
# предел неудачных входов (change auth-hardening, решение 3): порт в
|
||||
# src/core/ports, реализация в src/infra
|
||||
(
|
||||
AbstractLoginLimiter,
|
||||
ValkeyLoginLimiter,
|
||||
fakes.FakeLoginLimiter,
|
||||
),
|
||||
)
|
||||
|
||||
CLIENTS = (
|
||||
(Cache, fakes.FakeCache, ("get", "set", "aclose")),
|
||||
(Cache, fakes.FakeCache, ("get", "set", "run_script", "aclose")),
|
||||
(
|
||||
ObjectStorage,
|
||||
fakes.FakeObjectStorage,
|
||||
@@ -125,6 +134,7 @@ FORBIDDEN_MODULES = (
|
||||
"asyncpg",
|
||||
"src.infra.db",
|
||||
"src.infra.upload_slots",
|
||||
"src.infra.login_limit",
|
||||
"src.infra.cache.instance",
|
||||
"src.infra.s3.instance",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user