I followed the instraction on [1] and [2] to generate a policy for kv secrets and the appropriate token for it. But I’m missing something, because the token doesn’t work.
because the policy only matches things with a slash after wia
Second, it looks like you may have explicit deny capabilities set in other policies not mentioned here, which may interfere. (Based on the output of the vault token capabilities command.)
Because you need to add the data in you path, needs to be like so:
path “secret/data/data/bmb/wia” {
capabilities = [“read”]
}
Notice double “data”
and it should work, data is added automatically, and you have created the secret with data as a parent.
doesn’t match the path used elsewhere in the post, since the vault kv ... series of commands inserts the extra path segment that is part of the KVv2 API.
That said, my read of the post is it’s more likely that the policy is correct, and the fix is to remove the data path segment from the vault kv commands.
thanks for all the answers. I had decided to start again from the beginning, but unfortunately it doesn’t work yet. I checked the “my-value” key from yesterday, it was still there. After that I disabled secret and enabled it again. As expected, the key was then not present.
# vault kv get -field=my-value secret/data/bmb/wia
s3cr3t
# vault secrets disable secret/
Success! Disabled the secrets engine (if it existed) at: secret/
# vault kv get -field=my-value secret/data/bmb/wia
Error making API request.
URL: GET https://localhost:8200/v1/sys/internal/ui/mounts/secret/data/bmb/wia
Code: 403. Errors:
* preflight capability check returned 403, please ensure client's policies grant access to path "secret/data/bmb/wia/"
Now I adjusted the policy (no wildcard and a sinlge “data” and activated kv again. It’s working, at least for the admin.
And now with this Token … after that I don’t understand. Because the user can read the previously set secret, but cannot write one. And the capabilities require the “data” in the path?
$ vault login
Token (will be hidden):
Success! You are now authenticated. The token information displayed below
.
.
.
$ vault kv get -field=my-value secret/bmb/wia
s3cr3t
$ vault token capabilities secret/data/bmb/wia
create, list, read
$ vault token capabilities secret/bmb/wia
deny
$ vault kv put secret/bmb/wia my-value2=s3cr3t
Error writing data to secret/data/bmb/wia: Error making API request.
URL: PUT https://localhost:8200/v1/secret/data/bmb/wia
Code: 403. Errors:
* 1 error occurred:
* permission denied
Now i’m at a loss. I’m still missing a piece of information somewhere
In addition to that, the list capability is inapplicable to the data/ subpath of KV v2 engines - the list operation is performed against the metadata/ subpath.
The URL layout of the KV v2 secrets engine confuses many people - if you’re going to be using them, it is good to take some time to carefully read through what operations exist on the various KV v2 subpaths.