Перенесён минимум lab6 (API без изменений), добавлена защита на границах доверия: - внешний HTTPS; обязательный mTLS LB -> API с allowlist identity и отзывом по serial; - TLS на всех связях: PostgreSQL verify-full, MinIO HTTPS, RabbitMQ AMQPS mTLS (EXTERNAL), Valkey TLS + ACL, Collector и хранилища телеметрии через mTLS с отдельными CA; - OpenBao в server mode: cert auth, токены 15 мин, политики только на свой путь; - роли БД, S3-политики и права брокера по принципу минимальных прав; - Argon2id с замером, rehash, общий лимит входа, бюджет защиты от login DoS; - hardening всех контейнеров, scan образов с разбором, модель угроз, матрица доверия; - отрицательные тесты: TLS-аудит (135 проверок), ACL, ротации, sealed OpenBao.
35 lines
1.6 KiB
Bash
Executable File
35 lines
1.6 KiB
Bash
Executable File
#!/bin/sh
|
|
# Operator step 1 (after scripts/pki.sh init): local .env and random bootstrap credentials in secrets/bootstrap/.
|
|
# Nothing is printed. Existing files are kept, so a re-run never changes the passwords of a live stand.
|
|
#
|
|
# Who gets what:
|
|
# stores (postgres, minio, valkey, grafana) read their OWN admin/ACL material from Docker secrets;
|
|
# API and worker get NO password files at all: scripts/bao.sh bootstrap copies their credentials into OpenBao
|
|
# and the services read them there after authenticating with their client certificate.
|
|
set -eu
|
|
cd "$(dirname "$0")/.."
|
|
[ -f .env ] || cp .env.example .env
|
|
umask 077
|
|
mkdir -p secrets/bootstrap
|
|
cd secrets/bootstrap
|
|
|
|
put() { [ -f "$1" ] || printf '%s' "$2" > "$1"; }
|
|
random() { python3 -c "import secrets;print(secrets.token_urlsafe(24),end='')"; }
|
|
|
|
put postgres_password "$(random)" # superuser `messenger`: migrations and operator only
|
|
put db_api_password "$(random)" # role app_api
|
|
put db_worker_password "$(random)" # role app_worker
|
|
put minio_root_user messenger_root
|
|
put minio_root_password "$(random)"
|
|
put s3_api_access_key messenger-api
|
|
put s3_api_secret_key "$(random)"
|
|
put s3_worker_access_key messenger-worker
|
|
put s3_worker_secret_key "$(random)"
|
|
put valkey_api_password "$(random)" # ACL user `api`
|
|
put grafana_admin_password "$(random)"
|
|
put migrate_database_url "postgresql://messenger:$(cat postgres_password)@postgres:5432/messenger"
|
|
chmod 644 ./* # read by container users through Docker secrets; the directory itself is 700
|
|
cd ..
|
|
chmod 700 . bootstrap
|
|
echo "bootstrap credentials ready in secrets/bootstrap/ (.env present)"
|