Last active
February 22, 2021 03:25
-
-
Save tristanmorgan/af6f82c58196481fc77915abbe83e931 to your computer and use it in GitHub Desktop.
HashiCorp Vault Token Helper (save into macOS keychain)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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