Шхуна не тонет: security, infra и доки на русском.

Безопасность довёл до ума — Cursor-генерацию переписал руками.
IDOR закрыл, CSRF задушил, refresh rotation теперь как надо.
HSTS на staging, ENABLE_DOCS=false, install.env recovery протестил.

Backend:
- jwt_denylist + auth_epoch: мгновенный revoke access JWT (logout/block/reset)
- auth/admin/users: bump epoch, logout с Bearer, forgot_password skip для blocked
- install_secrets: путь всегда apps/api/data/secrets/ (bootstrap из корня не ломает Docker)
- seed: SEED_DEMO_USERS=false на prod/staging
- тесты: jwt revoke, integration, coverage gate 90%

Frontend:
- logout шлёт Bearer, обработка TOKEN_REVOKED
- guards TypeScript fix
- E2E: blocked user → 401 сразу после block

Infra:
- staging/prod compose, TLS nginx, deploy-скрипты
- k6 §17.2, backup/health/smoke scripts

Docs:
- docs/ на русском: project, security, deploy, release (старые md слили)
- README короткий + план ТЗ + стандартные логины dev

Код готов к плаванию. Капитан может идти писать фронт.
This commit is contained in:
влад
2026-07-15 00:06:13 +03:00
parent 86cc3fa541
commit 12c983c0fc
66 changed files with 2377 additions and 520 deletions
@@ -12,6 +12,31 @@ def _admin_headers(client) -> dict[str, str]:
return {"Authorization": f"Bearer {token}"}
def test_refresh_fails_for_pending_user(client):
client.post(
"/api/v1/auth/register",
json={"email": "pending-refresh@example.com", "password": "Valid123"},
)
login = client.post(
"/api/v1/auth/login",
json={"email": "pending-refresh@example.com", "password": "Valid123"},
)
assert login.status_code == 403
assert login.json()["detail"] == "EMAIL_NOT_VERIFIED"
# Simulate stale refresh cookie from an earlier active session edge case via direct token issue.
from app.modules.auth.service import issue_refresh_token
from app.modules.users.repository import get_user_by_email
user = get_user_by_email("pending-refresh@example.com")
refresh_token = issue_refresh_token(user.id)
client.cookies.set("refresh_token", refresh_token, path="/api/v1/auth")
refresh = client.post("/api/v1/auth/refresh", headers={"Origin": "http://localhost:5173"})
assert refresh.status_code == 403
assert refresh.json()["detail"] == "EMAIL_NOT_VERIFIED"
def test_refresh_fails_for_blocked_user(client):
register_and_verify(client, "blocked-refresh@example.com")
login = client.post(
@@ -32,7 +57,8 @@ def test_refresh_fails_for_blocked_user(client):
)
assert blocked.status_code == 200
refresh = client.post("/api/v1/auth/refresh", headers={"Origin": "http://localhost:5173"})
assert refresh.status_code == 401
assert refresh.status_code == 403
assert refresh.json()["detail"] == "ACCOUNT_BLOCKED"
def test_refresh_requires_origin_header_when_cookie_present(client):