brew install vault
vault server -dev
docker run -p 8200:8200 --cap-add=IPC_LOCK -e 'VAULT_DEV_ROOT_TOKEN_ID=test' vault
export VAULT_ADDR='http://127.0.0.1:8200'
export VAULT_DEV_ROOT_TOKEN_ID="test"
export VAULT_TOKEN="test"
vault kv put secret/test user=test
vault kv get secret/test
vault auth enable approle
vault write auth/approle/role/test \
secret_id_ttl=10m \
token_num_uses=10 \
token_ttl=20m \
token_max_ttl=30m \
secret_id_num_uses=40
curl -X POST -H "X-Vault-Token:$VAULT_TOKEN" -d '{"rules": "{\"name\": \"dev\", \"path\": {\"secret/*\": {\"policy\": \"write\"}}}"}' http://127.0.0.1:8200/v1/sys/policy/dev
curl -X GET -H "X-Vault-Token:$VAULT_TOKEN" http://127.0.0.1:8200/v1/sys/policy/dev
curl \
--header "X-Vault-Token: test" \
--request POST \
--data '{"policies": "dev"}' \
http://127.0.0.1:8200/v1/auth/approle/role/test
vault read auth/approle/role/test/role-id
Example:
Key Value
--- -----
role_id 9400081d-cf6e-22de-19ea-6b86e0c0ed21
vault write -f auth/approle/role/test/secret-id
Example
Key Value
--- -----
secret_id 3883f832-20c1-2195-435e-53527a021d51
secret_id_accessor fde6adad-ee0e-2754-7c8e-22726a49d7f4
export VAULT_TOKEN=$VAULT_DEV_ROOT_TOKEN_ID
curl -X GET -H "X-Vault-Token:$VAULT_TOKEN" http://127.0.0.1:8200/v1/auth/approle/role/test/role-id
curl -X POST -H "X-Vault-Token:$VAULT_TOKEN" http://127.0.0.1:8200/v1/auth/approle/role/test/secret-id
curl -X POST -d '{"role_id":"role_id","secret_id":"secret_id"}' http://127.0.0.1:8200/v1/auth/approle/login
export APP_TOKEN=app_token
export VAULT_TOKEN=$APP_TOKEN
curl -X GET -H "X-Vault-Token:$VAULT_TOKEN" http://127.0.0.1:8200/v1/secret/data/test
https://gist.github.com/exAspArk/e210523a4bcb988cdfb24a114d46ddf0