Skip to content

Instantly share code, notes, and snippets.

@tristanmorgan
Last active February 22, 2021 03:25
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tristanmorgan/af6f82c58196481fc77915abbe83e931 to your computer and use it in GitHub Desktop.
Save tristanmorgan/af6f82c58196481fc77915abbe83e931 to your computer and use it in GitHub Desktop.
HashiCorp Vault Token Helper (save into macOS keychain)
#!/bin/sh
set -e
[ -z "$VAULT_ADDR" ] && VAULT_ADDR="https://127.0.0.1:8200"
case $1 in
store)
security add-generic-password -U -a "VAULT-$USER" -c "hvlt" -C "hvlt" -D "Hashicorp Vault" -s "$VAULT_ADDR" -w "$(cat)"
;;
get)
/bin/echo -n $(security find-generic-password -g -a "VAULT-$USER" -s "$VAULT_ADDR" -w)
;;
erase)
security delete-generic-password -a "VAULT-$USER" -s "$VAULT_ADDR"
;;
*)
echo "Usage: $0 get|erase|store"
;;
esac
# then set in your ~/.vault
# token_helper = "/path/to/script/vault-token-helper.sh"
# updated to reflect Vault 1.0.x token format (26 chars) output without a trailing new-line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment