lab7: OpenBao 2.7.3 (не dev, raft на volume, TLS, audit), AppRole и scoped policy для api/relay/worker, секреты только из OpenBao, скрипт оператора и проверка allow/deny

This commit is contained in:
Alexey Bodanyuk
2026-11-27 16:41:57 +03:00
parent 93f4ed1013
commit 876f610847
16 changed files with 623 additions and 45 deletions
+39
View File
@@ -0,0 +1,39 @@
# OpenBao 2.7 server of the lab 7 stand (compose service `openbao`). NOT dev mode:
# * persistent storage: integrated storage (Raft, ONE node - OpenBao 2.7 has no "file" backend
# any more) on the named volume baodata (/openbao/file). Everything in it is encrypted by the
# barrier key; it starts SEALED after every start and is unsealed by the operator
# (scripts/bao_operator.py unseal). Single node = no replication: losing the volume loses the
# secrets (they can be re-created from ./secrets by `bootstrap` on a fresh instance).
# * TLS listener only (internal CA, SAN openbao + localhost/127.0.0.1 for the operator CLI inside
# the container), TLS 1.2+; no plaintext listener, no UI, port not published on the host. The
# Raft cluster port 8201 uses OpenBao's own automatic TLS and has no peers here.
# * disable_mlock: the container runs without IPC_LOCK (no extra capabilities). The trade-off -
# memory pages could be swapped - is accepted on this single-host lab stand: the container has
# memswap_limit = memory limit (no swap). See docs/OPERATOR.md.
ui = false
disable_mlock = true
api_addr = "https://openbao:8200"
cluster_addr = "https://openbao:8201"
log_level = "warn"
storage "raft" {
path = "/openbao/file"
node_id = "openbao-1"
}
# Audit log of every request and response (secret values HMAC'ed, never in clear) to the container
# stdout: `docker compose logs openbao` shows who read what and every denied request.
audit "file" "stdout" {
description = "lab 7 audit log"
options {
file_path = "stdout"
}
}
listener "tcp" {
address = "0.0.0.0:8200"
cluster_address = "0.0.0.0:8201"
tls_cert_file = "/run/secrets/openbao.crt"
tls_key_file = "/run/secrets/openbao.key"
tls_min_version = "tls12"
}
+16
View File
@@ -0,0 +1,16 @@
# Policy of the AppRole `api` (API replicas). Exactly one secret path, read only:
# messenger/data/api = database_url (role messenger_api), cache_url (Valkey ACL user api),
# s3_access_key_id / s3_secret_access_key (identity messenger-api: Write staging + Read final).
# No metadata/list/write, no other service's path, no sys/*, no policy management. The token is
# created with token_no_default_policy=true, so self-management is granted explicitly below.
path "messenger/data/api" {
capabilities = ["read"]
}
path "auth/token/lookup-self" {
capabilities = ["read"]
}
path "auth/token/revoke-self" {
capabilities = ["update"]
}
+13
View File
@@ -0,0 +1,13 @@
# Policy of the AppRole `relay`: messenger/data/relay = database_url (role messenger_relay) and
# broker_url (RabbitMQ user relay: publish to the jobs exchange only). Read only, nothing else.
path "messenger/data/relay" {
capabilities = ["read"]
}
path "auth/token/lookup-self" {
capabilities = ["read"]
}
path "auth/token/revoke-self" {
capabilities = ["update"]
}
+14
View File
@@ -0,0 +1,14 @@
# Policy of the AppRole `worker`: messenger/data/worker = database_url (role messenger_worker),
# broker_url (RabbitMQ user worker: consume the jobs queue only), s3 key pair messenger-worker
# (staging + final, no List, no Admin). No admin credentials of the API, the database or S3.
path "messenger/data/worker" {
capabilities = ["read"]
}
path "auth/token/lookup-self" {
capabilities = ["read"]
}
path "auth/token/revoke-self" {
capabilities = ["update"]
}