Created
March 16, 2020 20:32
-
-
Save chrishoffman/0af43e43fb5281770127c6a392bda21a to your computer and use it in GitHub Desktop.
This file contains 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/bash | |
cat > policy1.hcl <<EOF | |
path "secret/data/nemo/dev-master/*" | |
{ | |
capabilities = ["read", "list", "create", "update", "delete"] | |
} | |
EOF | |
cat > policy2.hcl <<EOF | |
path "secret/*" | |
{ | |
capabilities = ["read", "list"] | |
} | |
EOF | |
export TMPTOKEN1=$(vault token create -format=json -policy=policy1 | jq -r .auth.client_token) | |
export TMPTOKEN2=$(vault token create -format=json -policy=policy1 -policy=policy2 | jq -r .auth.client_token) | |
echo "Should error:" | |
VAULT_TOKEN=$TMPTOKEN1 vault kv get secret/ab | |
## write date with root token | |
vault kv put secret/nemo/dev-master/abc a=b > /dev/null | |
echo "Should work:" | |
VAULT_TOKEN=$TMPTOKEN1 vault kv get secret/nemo/dev-master/abc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment