ЛР 7 — БПИ2303 — Лазарев — на 3
Application / app (pull_request) Canceled after 0s
Skeleton contracts / contracts (pull_request) Canceled after 0s

Перенесена реализация lab6; бизнес-API без изменений, транспорт — HTTPS.

- Внешний HTTPS (public-ca) на 127.0.0.1:8443; HSTS, TLS >= 1.2.
- Обязательное mTLS LB -> каждая API-реплика: API проверяет цепочку
  internal-ca и SAN клиента (allowlist: lb); health только на 127.0.0.1.
- TLS с проверкой сервера ко всем зависимостям: PostgreSQL verify-full
  (pg_hba только hostssl), HTTPS S3, AMQPS, OTLP/HTTPS с client cert,
  mTLS Collector -> Prometheus/Loki/Tempo, Grafana -> datasources, scrape.
- OpenBao 2.7.2 не в dev-mode: Raft на volume, init/unseal оператором,
  auth/cert с ролью и policy на сервис, TTL 15 мин + renew/re-login.
- Отдельные роли PostgreSQL с грантами по таблицам; разные ключи S3 и
  пользователи брокера выдаются из OpenBao.
- Argon2id (m=19 MiB, t=2, p=1, замер на стенде) и rehash при входе.
- Случайный X-Instance-Id; hardening контейнеров (non-root, cap_drop ALL,
  no-new-privileges, read-only, лимиты); TCP_NODELAY на сокете API.
- Модель угроз, trust matrix, отрицательные тесты TLS/mTLS, API, OpenBao,
  hardening; evidence, в т.ч. прогон из чистого clone.
This commit is contained in:
2026-11-18 23:59:35 +03:00
parent 20afc2c790
commit 9cc80d2529
146 changed files with 21935 additions and 85 deletions
+12
View File
@@ -0,0 +1,12 @@
# Lab7: только TLS. Локальный сокет внутри контейнера — peer (ОС-пользователь postgres = роль
# postgres: initdb-скрипты образа, pg_isready, оператор через docker compose exec).
# TYPE DATABASE USER ADDRESS METHOD
local all postgres peer
local all all reject
# Сеть: только hostssl + SCRAM-SHA-256. Любое подключение без TLS отвергается.
hostssl messenger postgres 0.0.0.0/0 scram-sha-256
hostssl messenger api_svc,worker_svc,relay_svc,janitor_svc,ops_svc 0.0.0.0/0 scram-sha-256
hostnossl all all 0.0.0.0/0 reject
hostnossl all all ::/0 reject
host all all 0.0.0.0/0 reject
host all all ::/0 reject
+17
View File
@@ -0,0 +1,17 @@
#!/bin/sh
# Lab7: PostgreSQL требует, чтобы ключ TLS принадлежал postgres (или root) с правами 0600/0640,
# а Docker secret — bind mount с правами хоста. Копируем сертификат/ключ в tmpfs /run/pgtls с
# нужными правами (выполняется root-ом entrypoint-а, затем образ сам переходит на uid postgres).
set -eu
install -d -m 0700 -o postgres -g postgres /run/pgtls
install -m 0600 -o postgres -g postgres /run/secrets/service.key /run/pgtls/server.key
install -m 0644 -o postgres -g postgres /run/secrets/service.crt /run/pgtls/server.crt
exec docker-entrypoint.sh postgres \
-c ssl=on \
-c ssl_cert_file=/run/pgtls/server.crt \
-c ssl_key_file=/run/pgtls/server.key \
-c ssl_min_protocol_version=TLSv1.2 \
-c password_encryption=scram-sha-256 \
-c hba_file=/etc/postgresql/pg_hba.conf \
-c log_connections=on \
-c log_hostname=off