Complete lab 7 security implementation
This commit is contained in:
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
|
||||
if [[ ! -f "${ROOT}/security/openbao-init.json" ]]; then
|
||||
echo "ERROR: security/openbao-init.json not found" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BAO() {
|
||||
docker compose --env-file "$ROOT/.env" exec -T \
|
||||
-e BAO_ADDR=https://127.0.0.1:8200 \
|
||||
-e BAO_CACERT=/openbao/certs/ca.crt \
|
||||
openbao bao "$@"
|
||||
}
|
||||
|
||||
SEALED=$(BAO status -format=json 2>/dev/null | jq -r '.sealed // "error"' || echo "error")
|
||||
if [[ "$SEALED" == "false" ]]; then
|
||||
echo "OpenBao already unsealed"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "==> Unsealing OpenBao (2 of 3 keys)"
|
||||
for i in 0 1; do
|
||||
KEY=$(jq -r ".unseal_keys_b64[$i]" "${ROOT}/security/openbao-init.json")
|
||||
BAO operator unseal "$KEY" >/dev/null
|
||||
done
|
||||
echo "==> OpenBao unsealed"
|
||||
BAO status -format=json 2>/dev/null | jq '{sealed, initialized}'
|
||||
Reference in New Issue
Block a user