Hi,
This one should be rather simple. So I am using a file
storage backend with userpass
authentication.
For some reason I can’t read from kv/data/shared/*
even though my policy expressly permits it.
So I’ve logged in as my root token.
Enabled v2 kv secrets engine:
vault secrets enable -version=2 kv
Now I’ve created a policy 1000.hcl
path "kv/data/users/1000/*" {
capabilities = ["create", "update", "read"]
}
path "kv/delete/users/1000/*" {
capabilities = ["delete", "update"]
}
path "kv/undelete/users/1000/*" {
capabilities = ["update"]
}
path "kv/destroy/users/1000/*" {
capabilities = ["update"]
}
path "kv/metadata/users/1000/*" {
capabilities = ["list", "read", "delete"]
}
path "kv/metadata/" {
capabilities = ["list"]
}
path "kv/metadata/users/" {
capabilities = ["list"]
}
# I would have thought this would have worked
path "kv/data/shared/*" {
capabilities = ["read"]
}
path "kv/metadata/shared/" {
capabilities = ["list"]
}
Write the policy:
vault policy write 1000 1000.hcl
Success! Uploaded policy: 1000
Enable userpass and create a user:
vault auth enable userpass
Success! Enabled userpass auth method at: userpass/
vault write auth/userpass/users/1000 \
password='mypass' \
policies=admins,1000
Success! Data written to: auth/userpass/users/1000
I wrote some values to kv/data/shared
as the root user:
vault kv put kv/data/shared foo=bar
And able to read them:
vault kv get kv/data/shared
====== Metadata ======
Key Value
--- -----
created_time 2021-11-09T14:05:06.80154004Z
deletion_time n/a
destroyed false
version 1
=== Data ===
Key Value
--- -----
foo bar
Then I login as the user:
vault login -method=userpass username=1000
Password (will be hidden):
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 s.Sgxvzg5iQ71xY4jh1oVWLnYK
token_accessor l6PzfE9EDwMOGCGDivzjpPl0
token_duration 768h
token_renewable true
token_policies ["1000" "admins" "default"]
identity_policies []
policies ["1000" "admins" "default"]
token_meta_username 1000
Now the problem seems to be I can’t read from kv/data/shared
$ vault kv get kv/data/shared
Error reading kv/data/data/shared: Error making API request.
URL: GET https://vault.example.com/v1/kv/data/data/shared
Code: 403. Errors:
* 1 error occurred:
* permission denied
What am I doing wrong? The intention is to have some vault secrets that all the users can read.
I can get reading and writing to kv/users/1000/foo
to work though.