Files
mtusi2026lab7/infra/postgres/start.sh
T
zemiles 9cc80d2529 ЛР 7 — БПИ2303 — Лазарев — на 3
Перенесена реализация 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.
2026-11-18 23:59:35 +03:00

18 lines
988 B
Bash
Executable File
Raw 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.
#!/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