test: verify security boundaries and recovery
This commit is contained in:
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -eu
|
||||
|
||||
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
||||
. "$script_dir/openbao-common.sh"
|
||||
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo "usage: $0 <api|worker> <replacement-secret-json>" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
service=$1
|
||||
secret_file=$2
|
||||
|
||||
case "$service" in
|
||||
api|worker) ;;
|
||||
*) fail "service must be api or worker" ;;
|
||||
esac
|
||||
|
||||
require_command "$BAO_BIN"
|
||||
require_command python3
|
||||
require_runtime_path "$secret_file"
|
||||
require_private_file "$secret_file"
|
||||
require_unsealed
|
||||
load_operator_token
|
||||
|
||||
python3 - "$secret_file" <<'PY'
|
||||
import json
|
||||
import sys
|
||||
|
||||
with open(sys.argv[1], encoding="utf-8") as source:
|
||||
value = json.load(source)
|
||||
if not isinstance(value, dict) or not value:
|
||||
raise SystemExit("replacement secret must be a non-empty JSON object")
|
||||
PY
|
||||
|
||||
"$BAO_BIN" kv put -mount=secret "messenger/$service" @"$secret_file" >/dev/null
|
||||
"$script_dir/openbao-issue-approle.sh" "$service" "$openbao_runtime_dir/approle/$service"
|
||||
|
||||
echo "$service secret rotated; OpenBao Agent will render the new KV version"
|
||||
|
||||
Reference in New Issue
Block a user