Files
mtusi2026lab7/contracts/trust-matrix.md

35 lines
4.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Матрица доверия — lab7 (заполнено)
CA: локальный `certs/ca.crt` (публичный, можно распространять), закрытый ключ CA —
`certs/private/ca.key` (вне Git). Отдельный `certs/mesh-ca.crt` выпускает **только**
client-identity `lb` для mTLS LB→API. Сертификаты создаются `scripts/generate_certs.py`.
| Связь | Реализация на уровне 3 | Доказательство |
| --- | --- | --- |
| Клиент → ingress/LB | `https://localhost:8443`, сертификат `ingress.crt` с SAN `localhost`/`127.0.0.1`, CA клиента — `certs/ca.crt`; Bearer | `tests/security.py`, `tests/smoke.py` |
| LB → API (api1, api2) | mTLS: `proxy_ssl_certificate=lb.crt`, `proxy_ssl_verify on` к CA, API требует client cert цепочки `mesh-ca`; identity `lb` — единственная выпущенная | `scripts/verify_security.py`: нет серта → отказ; trusted-CA, но чужой SAN → отказ |
| API/worker → PostgreSQL | `sslmode=verify-full`, `sslrootcert=/certs/ca.crt`, сервер `db.crt` (SAN `db`); роль `messenger` | `app/db.py`, `compose.yaml`, smoke |
| API/worker → S3 (MinIO) | `https://minio:9000`, boto3 `verify=/certs/ca.crt`, сертификат `minio.crt` (SAN `minio`), scoped key; bucket приватен | `app/s3.py`, smoke (SHA-256 оригинала) |
| API/worker → broker (Redis) | TLS `6379`, `ssl_cert_reqs=CERT_REQUIRED`, `redis.crt` (SAN `redis`), пароль из OpenBao | `app/broker.py`, `compose.yaml` |
| API/worker → OTel Collector | OTLP/HTTP `https://otel-collector:4318`, `certificate_file=/certs/ca.crt`, сертификат `otel-collector.crt` (SAN) | `app/telemetry.py`, `verify_telemetry.py` |
| Collector → Prometheus/Loki/Tempo | внутренняя сеть Compose, отдельные volume и identity; публичные порты админских интерфейсов — localhost | `docker compose ps`, `verify_telemetry.py` |
| Grafana → data sources | Prometheus/Loki/Tempo по внутренним именам сервисов, provisioning в `infra/grafana-datasources.yml` | Grafana API: 3 datasource, dashboard |
| API/worker → OpenBao | `https://openbao:8200` (`openbao.crt` SAN `openbao`,`localhost`), AppRole `messenger-app`, token TTL 1h / max 4h, policy только `secret/data/messenger/app` | `app/bao.py`, `scripts/verify_security.py` |
| Оператор → OpenBao/Grafana | localhost:8200 / localhost:3000; root token и unseal shares хранятся у оператора в `certs/private/bao-init.json` (вне Git) | `scripts/bootstrap_bao.py` |
| API → Redis/Valkey | см. строку broker; ACL/пароль минимальны | `app/broker.py` |
| Replication/кластерные каналы | N/A — репликация БД не добавлена | `REPORT.md` |
Отрицательные проверки (все воспроизводимы):
1. Доверенный CA/hostname → 200; пустой trust store → `ssl.SSLCertVerificationError` (`tests/security.py`).
2. mTLS: без client cert → handshake failure; trusted-CA, но SAN `evil-lb` → handshake failure (`verify_security.py`).
3. Посторонний не читает metadata/content чата → 404 (публичный smoke).
4. `X-User-Id` не переопределяет Bearer → 401/401 (публичный smoke).
5. OpenBao: свой path читается; запись и чужой path → 403 (`verify_security.py`).
6. Login rate limit: 5×401, 6-й → 429 + `Retry-After: 60` (`verify_security.py`).
Bootstrap/эксплуатация: `python scripts/generate_certs.py` → `docker compose up -d` →
`python scripts/bootstrap_bao.py` (init/unseal вручную, ключи у оператора). При рестарте
OpenBao остаётся запечатанным до unseal оператором; обычный рестарт API не требует unseal.
Root token и unseal keys не попадают ни в образ, ни в приложение, ни в telemetry.