I created the policy with the following command:
vault policy write my-policy -<<EOF
path “secret/data/myproj/*” {
capabilities = [“read”,“list”]
}
EOF
Result:
Success! Uploaded policy: my-policy
Then I did:
vault token create -policy=my-policy
Result:
Key Value
token hvs.CAESIAzkUstjxJI7oY_NVVywwIhWGbgmd8HljnPSeAbCpXVAGh4KHGh2cy41e
token_accessor YxDVCl612n9IjujX9Zp
token_duration 768h
token_renewable true
token_policies [“default” “my-policy”]
identity_policies
policies [“default” “my-policy”]
Subsequently, I logged in with the new token
vault login hvs.CAESIAzkUstjxJI7oY_NVVywwIhWGbgmd8HljnPSeAbCpXVAGh4KHGh2cy41e
Result:
`Success! You are now authenticated. The token information displayed below is already stored in the token helper. You do NOT need to run "vault login" again. Future Vault requests will automatically use this token.
Key Value
token hvs.CAESIAzkUstjxJI7oY_NVVywwIhWGbgmd8HljnPSeAbCpXVAGh4KHGh2cy41e
token_accessor YxDVCl612n9IjujX9Zp token_duration 768h
token_renewable true
token_policies ["default" "my-policy"] identity_policies [ ]
policies ["default" "my-policy"]
But trying to read the policy with the following command:
vault policy read my-policy
I get:
Error reading policy named my-policy: Error making API request.
URL: GET https://127.0.0.1:8200/v1/sys/policies/acl/my-policy Code: 403. Errors:
* 1 error occurred: * permission denied"