Two isolated personal-credential backup options to evaluate, both excluded
from the admin policy (root-only break-glass):
- Scenario A: personal/ KV v2 (versioned) + personal-{put,get,list}.sh
- Scenario B: transit-personal/ key personal-backup + secret-{encrypt,decrypt}.sh
Plus an AppRole example of how a system should consume a secret:
- demo-app role/policy (read-only secret/demo-app/*), short-lived tokens
- scripts/app-get-secret.sh: login (role_id+secret_id) -> token -> read
All tokens/credentials live under ~/.config/openbao (outside the repo).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
20 lines
922 B
Bash
Executable File
20 lines
922 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# Scenario B: decrypt a transit blob produced by secret-encrypt.sh.
|
|
# secret-decrypt.sh <encfile> [outfile] (default outfile: <encfile> w/o .vaultenc, +.dec)
|
|
set -euo pipefail
|
|
ADDR="${BAO_ADDR:-http://127.0.0.1:8200}"
|
|
TOKF="$HOME/.config/openbao/personal-transit.token"
|
|
KEY="personal-backup"
|
|
in="${1:?usage: secret-decrypt.sh <encfile> [outfile]}"
|
|
out="${2:-${in%.vaultenc}.dec}"
|
|
[ -r "$TOKF" ] || { echo "no token at $TOKF" >&2; exit 1; }
|
|
[ -r "$in" ] || { echo "no input file: $in" >&2; exit 1; }
|
|
|
|
b64="$(cat "$in" \
|
|
| python3 -c 'import json,sys;print(json.dumps({"ciphertext":sys.stdin.read().strip()}))' \
|
|
| curl -sS -H "X-Vault-Token: $(cat "$TOKF")" --data @- "$ADDR/v1/transit-personal/decrypt/$KEY" \
|
|
| jq -r '.data.plaintext // empty')"
|
|
[ -n "$b64" ] || { echo "decrypt failed (wrong key/blob?)" >&2; exit 1; }
|
|
printf '%s' "$b64" | base64 -d > "$out"
|
|
echo "decrypted $in -> $out"
|