feat: load process secrets from OpenBao via cert auth

OpenBao 2.7.3 (raft, TLS 1.3 with client certificates) holds the
PostgreSQL role passwords, the Valkey password and the S3 keys; each
process logs in with its own mTLS identity, reads only its paths and
renews its token in the background. Operator init, unseal, configure
and seed go through infra/openbao/bao.py and make bao_*; checks are
make bao_check and driver.py openbao-outage.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-26 13:55:09 +03:00
co-authored by Claude Opus 5.5
parent 4dd4a957be
commit 64210dace0
64 changed files with 6709 additions and 321 deletions
+29 -2
View File
@@ -42,7 +42,7 @@ import requests
from pydantic import ValidationError
from src.config import settings
from src.config.settings import BASE_DIR, Settings
from src.config.settings import BASE_DIR, Secrets, Settings
from src.config.settings import Telemetry as TelemetrySettings
from src.infra.tls import (
API_STORAGES,
@@ -64,6 +64,17 @@ TRACES_PATH = "/v1/traces"
ALLOWED_ROWS = ("api-client", "worker", "relay")
def _secrets_env(stand: Path) -> dict[str, str]:
"""OpenBao процесса (change `openbao-secrets`): действующие файлы identity,
чтобы дойти до проверяемого поля; адрес — имя, а не IP."""
return {
"SECRETS__ADDRESS": "https://openbao:8200",
"SECRETS__CERT_FILE": str(stand / "relay.crt"),
"SECRETS__KEY_FILE": str(stand / "relay.key"),
"SECRETS__CRL_FILE": str(stand / "crl.pem"),
}
def _openssl() -> str | None:
binary = os.environ.get("OPENSSL") or shutil.which("openssl")
if not binary:
@@ -420,6 +431,12 @@ def _settings(pki: Path, telemetry: TelemetrySettings) -> Settings:
},
),
telemetry=telemetry,
# OpenBao (change openbao-secrets): действующие файлы identity
secrets=Secrets(
cert_file=str(pki / "stand" / "relay.crt"),
key_file=str(pki / "stand" / "relay.key"),
crl_file=str(pki / "stand" / "crl.pem"),
),
)
@@ -509,6 +526,7 @@ def _run(
"TELEMETRY__CERT_FILE": str(stand / "relay.crt"),
"TELEMETRY__KEY_FILE": str(stand / "relay.key"),
"TELEMETRY__CRL_FILE": str(stand / "crl.pem"),
**_secrets_env(stand),
**env,
},
capture_output=True,
@@ -582,6 +600,14 @@ def _run_replay(pki: Path, **env: str) -> tuple[int, list[dict[str, Any]]]:
"TELEMETRY__CERT_FILE": "",
"TELEMETRY__KEY_FILE": "",
"TELEMETRY__CRL_FILE": "",
**_secrets_env(stand),
# с change openbao-secrets после проверки replay первым делом
# входит в OpenBao: закрытый порт и короткий срок ожидания — код 1
# за секунду, без стенда
"SECRETS__ADDRESS": "https://localhost:1",
"SECRETS__REQUEST_TIMEOUT_SECONDS": "0.5",
"SECRETS__STARTUP_TIMEOUT_SECONDS": "1",
"SECRETS__RETRY_SECONDS": "0.2",
**env,
},
capture_output=True,
@@ -599,7 +625,8 @@ def _run_replay(pki: Path, **env: str) -> tuple[int, list[dict[str, Any]]]:
def test_replay_does_not_check_telemetry(pki: Path) -> None:
"""Команда replay SDK не запускает (verify S2): при включённой телеметрии
без файлов `[telemetry]` проверка при старте их не называет, команда
доходит до PostgreSQL (закрытый порт — код 1, а не 2)."""
доходит до следующего шага (с change `openbao-secrets` — вход в OpenBao:
закрытый порт — код 1, а не 2)."""
code, records = _run_replay(pki)
refusal = [
r for r in records if r["event"] == "Invalid client TLS settings"