Implement Lab 7 security and infrastructure
Skeleton contracts / contracts (pull_request) Canceled after 0s

This commit is contained in:
sinveria
2026-11-22 11:55:09 +03:00
parent 20afc2c790
commit 6b5461a6b4
83 changed files with 8072 additions and 53 deletions
+22 -4
View File
@@ -1,7 +1,25 @@
# OpenBao — реализовать конфигурацию и политики
# OpenBao bootstrap (non-dev, persistent)
Добавьте non-dev конфигурацию listener/storage/TLS, API/worker policies, bootstrap и rotation scripts. Credentials и unseal material создаются локально; здесь нет готового root token или private key.
OpenBao uses file storage in the `openbao_data` volume and HTTPS on 8200. The operator owns initialization, unseal shares and the initial root token. They are never stored in Git, `.env`, images or application configuration.
Решение должно показать реальную сервисную аутентификацию и получение нужного secret по ограниченной policy; просто работающий контейнер OpenBao не засчитывается. На 3 статический KV secret допустим. На 4 покажите expiry/renewal/rotation и allow/deny. Путь KV v2 data/metadata и ACL должен соответствовать фактическому mount; не копируйте широкое `path "*"` для приложения.
## First initialization (PowerShell)
Документируйте шаги оператора init/unseal и восстановление после restart. Скрипт не должен печатать tokens/shares или хранить их в Git. См. contracts/trust-matrix.md и REPORT.md.
1. Generate local TLS files with `scripts/bootstrap-certs.ps1`.
2. Start only OpenBao: `docker compose up -d openbao`.
3. Initialize once and save the output securely offline:
`docker compose exec openbao bao operator init -key-shares=3 -key-threshold=2`
4. Unseal using two distinct shares:
`docker compose exec openbao bao operator unseal`
Repeat with the second share. Never put shares in scripts or source control.
5. Run `scripts/bootstrap-openbao.ps1`. It prompts for the root token without echoing it, creates KV v2, policies and AppRole roles, then writes short-lived SecretIDs and RoleIDs to ignored local files under `secrets/bao/`.
6. Start API/worker after bootstrap. Each service authenticates with its own AppRole and reads only its own KV path. The application never receives the root token or unseal material.
## Restart
The storage volume persists. After an ordinary restart, check `bao status`. If sealed, an operator must unseal with two shares. Do not automate unseal by placing shares beside the container.
KV v2 secrets are static for this lab-3 baseline. Rotate AppRole SecretIDs by generating new IDs, updating the local files and restarting the affected service. Dynamic credentials and zero-downtime rotation are outside the selected grade.
+3
View File
@@ -0,0 +1,3 @@
path "secret/data/messenger/api" {
capabilities = ["read"]
}
+16
View File
@@ -0,0 +1,16 @@
ui = false
api_addr = "https://openbao:8200"
cluster_addr = "https://openbao:8201"
storage "file" {
path = "/openbao/data"
}
listener "tcp" {
address = "0.0.0.0:8200"
cluster_address = "0.0.0.0:8201"
tls_disable = 0
tls_cert_file = "/run/tls/openbao.crt"
tls_key_file = "/run/tls/openbao.key"
tls_min_version = "tls12"
}
+3
View File
@@ -0,0 +1,3 @@
path "secret/data/messenger/outbox" {
capabilities = ["read"]
}
+3
View File
@@ -0,0 +1,3 @@
path "secret/data/messenger/worker" {
capabilities = ["read"]
}
+78
View File
@@ -0,0 +1,78 @@
foreground = yes
pid =
output = /dev/stdout
debug = 4
sslVersionMin = TLSv1.2
[postgres]
accept = 0.0.0.0:15432
connect = postgres:5432
protocol = pgsql
cert = /cert.crt
key = /private.key
[redis]
accept = 0.0.0.0:16379
connect = redis:6379
cert = /cert.crt
key = /private.key
[rabbitmq]
accept = 0.0.0.0:15672
connect = rabbitmq:5672
cert = /cert.crt
key = /private.key
[s3]
accept = 0.0.0.0:18333
connect = seaweedfs:8333
cert = /cert.crt
key = /private.key
[s3-public]
accept = 0.0.0.0:18443
connect = seaweedfs:8333
cert = /cert.crt
key = /private.key
[otlp]
accept = 0.0.0.0:14318
connect = otel-collector:4318
cert = /cert.crt
key = /private.key
[loki]
accept = 0.0.0.0:13100
connect = loki:3100
cert = /cert.crt
key = /private.key
[tempo]
accept = 0.0.0.0:14320
connect = tempo:4318
cert = /cert.crt
key = /private.key
[prometheus]
accept = 0.0.0.0:19090
connect = prometheus:9090
cert = /cert.crt
key = /private.key
[otel-metrics]
accept = 0.0.0.0:18889
connect = otel-collector:8889
cert = /cert.crt
key = /private.key
[grafana]
accept = 0.0.0.0:13001
connect = grafana:3000
cert = /cert.crt
key = /private.key
[tempo-query]
accept = 0.0.0.0:13200
connect = tempo:3200
cert = /cert.crt
key = /private.key