diff --git a/CHANGELOG.md b/CHANGELOG.md index b796e94..ff0912a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ orchestration code; see each submodule's own `CHANGELOG.md` [sso-manager-node](https://github.com/theta42/sso-manager-node/blob/master/CHANGELOG.md)) for what changed inside the apps it composes. +## [v1.26.0] - 2026-08-01 + +- Made OpenBao production-ready by using a persistent file backend, enabling `IPC_LOCK`, and dynamically generating a robust config file. +- Automated OpenBao initialization, unsealing, and secrets seeding via `setup.sh`. + ## [v1.25.0] - 2026-08-01 - Added OpenBao (Vault) container for secrets management and native UI proxying. diff --git a/docker-compose.yml b/docker-compose.yml index e376c5b..e1beadf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,6 +44,8 @@ services: NO_PROXY: ${CFG_NO_PROXY:-} container_name: sso-manager restart: unless-stopped + depends_on: + - openbao networks: [theta-net] ports: # SSO web UI. Bind address is configurable via SSO_BIND (default 0.0.0.0 so @@ -64,6 +66,7 @@ services: - NODE_PORT=3001 - LDAP_SERVER_ID=${LDAP_SERVER_ID:-} - LDAP_REPLICATION_HOSTS=${LDAP_REPLICATION_HOSTS:-} + - VAULT_TOKEN=${VAULT_TOKEN:-} # Optional upstream HTTP(S) proxy for outbound calls (SMTP, etc.) at # runtime. See the build args above for the same setting during build. - HTTP_PROXY=${CFG_HTTP_PROXY:-} @@ -214,6 +217,22 @@ services: - ./config/ldap-test-host.vars:/config/ldap.vars:ro - ./config/ldap-ca.crt:/config/ldap-ca.crt:ro + openbao: + image: quay.io/openbao/openbao:latest + container_name: openbao + restart: unless-stopped + cap_add: + - IPC_LOCK + command: server -config=/vault/config/openbao.hcl + environment: + - BAO_ADDR=http://127.0.0.1:8200 + ports: + - "8080:8200" + volumes: + - ./config/openbao.hcl:/vault/config/openbao.hcl:ro + - openbao-data:/vault/data + networks: + - theta-net networks: theta-net: driver: bridge @@ -226,4 +245,5 @@ volumes: proxy-cache: proxy-logs: jump-data: - jump-redis-data: \ No newline at end of file + jump-redis-data: + openbao-data: \ No newline at end of file diff --git a/setup.sh b/setup.sh index 5adade9..42ca693 100755 --- a/setup.sh +++ b/setup.sh @@ -392,6 +392,23 @@ PROXYEOF } ensure_config() { + if [[ ! -f "$CONFIG_DIR/openbao.hcl" ]]; then + info "Generating $CONFIG_DIR/openbao.hcl ..." + mkdir -p "$CONFIG_DIR" + cat > "$CONFIG_DIR/openbao.hcl" </dev/null 2>&1 || [[ $? -eq 2 ]]; then + info "openbao is reachable."; break + fi + if (( i == 30 )); then die "openbao did not become reachable in 60s. Check: ${COMPOSE[*]} logs openbao"; fi + sleep 2 +done + +if ! docker exec openbao bao status -format=json 2>/dev/null | grep -q '"initialized": true' || true; then + status_json=$(docker exec openbao bao status -format=json 2>/dev/null || true) + if ! echo "$status_json" | grep -q '"initialized": true'; then + info "Initializing openbao for the first time..." + docker exec openbao bao operator init -key-shares=1 -key-threshold=1 -format=json > "$CONFIG_DIR/bao-init.json" + chmod 600 "$CONFIG_DIR/bao-init.json" + info "Openbao initialized. Keys saved to $CONFIG_DIR/bao-init.json" + fi +fi + +status_json=$(docker exec openbao bao status -format=json 2>/dev/null || true) +if echo "$status_json" | grep -q '"sealed": true'; then + info "Unsealing openbao..." + UNSEAL_KEY=$(grep -A1 '"unseal_keys_b64":' "$CONFIG_DIR/bao-init.json" | tail -n1 | cut -d'"' -f2) + docker exec openbao bao operator unseal "$UNSEAL_KEY" >/dev/null +fi + +export VAULT_TOKEN +VAULT_TOKEN=$(grep '"root_token":' "$CONFIG_DIR/bao-init.json" | cut -d'"' -f4) +env_upsert VAULT_TOKEN "$VAULT_TOKEN" + +if ! docker exec -e BAO_TOKEN="$VAULT_TOKEN" openbao bao secrets list -format=json 2>/dev/null | grep -q '"secret/":'; then + info "Enabling kv-v2 secrets engine at secret/..." + docker exec -e BAO_TOKEN="$VAULT_TOKEN" openbao bao secrets enable -path=secret kv-v2 >/dev/null +fi + # ── 4. Start SSO Manager, wait for health ───────────────────────────────────── # SSO_GIT_COMMIT: sso-manager-node is a git submodule here, so its .git is a # pointer file (not a real repo) -- the image can't resolve its own commit @@ -670,6 +727,13 @@ for i in $(seq 1 60); do sleep 2 done +if ! docker exec -e BAO_TOKEN="$VAULT_TOKEN" openbao bao kv get secret/sso-manager/conf >/dev/null 2>&1; then + info "Seeding sso-manager/conf into Openbao..." + docker exec sso-manager node -e "console.log(JSON.stringify(require('/config/sso-secrets.js')))" > "$CONFIG_DIR/seed-conf.json" + cat "$CONFIG_DIR/seed-conf.json" | docker exec -i -e BAO_TOKEN="$VAULT_TOKEN" openbao bao kv put secret/sso-manager/conf - + rm -f "$CONFIG_DIR/seed-conf.json" +fi + # Read the summary values (hosts, admin, base DN) back from ./config via the # running container's node — works whether ./config was generated or pre-existing. read_config_kv() {