Policies not applied to Token

Hi I am new to Vault, I am authenticating LDAP users into Vault and now I am trying to set some policies for those users.

The result of applying the policies is as following

Key Value


token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
token_accessor xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
token_duration 768h
token_renewable true
token_policies [“amops” “default”]
identity_policies [“amops”]
policies [“amops” “default”]
token_meta_username jmalik

But when I check the token capabilities I get denied.
$ vault token capabilities cubbyhole
deny

My Policy is is as following

path “cubbyhole/*” {
capabilities = [“read”]
}

Your help in this regards will be highly appreciated thanks.

The reason you’re getting back deny is that the path you’re hitting is cubbyhole, but the path the policy specifies is cubbyhole/*. But there’s no real point in trying to access “cubbyhole” by itself, so I think the policy as written is fine, it’s the capabilities call that’s wrong-headed. You would need to run vault token capabilities cubbyhole/ to see the effect of the given policy.

The policy is unnecessary though, because everyone gets the default policy by default, which includes:

# Allow a token to manage its own cubbyhole
path "cubbyhole/*" {
    capabilities = ["create", "read", "update", "delete", "list"]
}

As far as I know the only reason you’d setup a cubbyhole policy is if you wanted to restrict access to it using the deny capability.

Thanks for your reply @ncabatoff I made a few changes to my Policy and this is what I am facing now;
New Policy

path “cubbyhole/OpenAM” {
capabilities = [“read”]
}

Result of token capabilities command

$ vault token capabilities cubbyhole/Open
read

When I log in to the Vault using with my ldap id this is what I get

$ vault login -method=ldap username=jmalik
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.****************************
token_accessor q****************************
token_duration 768h
token_renewable true
token_policies [“amops” “default”]
identity_policies [“amops”]
policies [“amops” “default”]
token_meta_username jmalik

When I log in via GUI I am unable to see the secrets

tried checking the secrets stored in the path;

$ vault kv get cubbyhole/OpenAM
No value found at cubbyhole/OpenAM

Where as I did create a few secrets using root token via GUI, shown below;

Can you please advise where have I made the mistake.

Where as I did create a few secrets using root token via GUI, shown below;

Hi @JawadKM - the cubbyhole backend only shows secrets that were created with the current token. So secrets created with the root token won’t be visible to anyone else (and vice versa).

This is explained in the Cubbyhole documentation:

The cubbyhole secrets engine is used to store arbitrary secrets within the configured physical storage for Vault namespaced to a token. In cubbyhole , paths are scoped per token. No token can access another token’s cubbyhole.

@sl1pm4t thanks for your quick reply I totally understand what you are trying to say and agree with you, but my problem is I do not see any “secret/” path when I log into my Vault all is see is as below. It is true for both when I log in with Root Token or with my ldap user id.

Ideally it should have a cubbyhole/ and secret/
How can I fix this issue now.

So there is no other place for me to create the secrets, except for cubbyhole

when I check secrets list I get this

$ vault secrets list
Path Type Accessor Description


cubbyhole/ cubbyhole cubbyhole_81b9edca per-token private secret storage
identity/ identity identity_afbdc178 identity store
sys/ system system_4fdcb57e system endpoints used for control, policy and debugging

You need to mount a secrets engine, e.g.

vault secrets enable kv

@ncabatoff thanks for you assistance and sorry for bothering you again and again but now I am in another road block. When use CLI to login and view the secret I can, but when I login to GUI using my ldap creds I cannot. Screenshots are as below;

$ vault login -method=ldap username=jmalik
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.G****************************
token_accessor B5************************
token_duration 768h
token_renewable true
token_policies [“amops” “default”]
identity_policies [“amops”]
policies [“amops” “default”]
token_meta_username jmalik
[fruser@server1 vault]$ vault kv get secret/OpenAM
=== Data ===
Key Value


am1 123456
am2 123456

My vault secrets list command gives me the below result

My new policy is

path “secret/OpenAM” {
capabilities = [“read”]
}

Thanks for all your assistance, looking forward to you reply.

Hello!

The KV backends (v1, v2, cubbyhole) are all folder-like in that you can nest paths. Currently in the UI, you need to have access from the root of the mount all the way to the path you want to read. Currently if you’ve got a v1 KV engine at secret/, you’ll need to add

path “secret*” {
   capabilities = [“list”]
}

to the policy you currently have. If it’s a v2 KV mount, then the paths are prefixed and the policy will look a little different:

path “secret/metadata*” {
  capabilities = [“list”, "read"]
}

path “secret/data/OpenAM” {
  capabilities = [“read”]
}

You can read more about the paths necessary for using v2 KV here: https://www.vaultproject.io/docs/secrets/kv/kv-v2.html#acl-rules

Hope this helps!

Thank you so much @meirish. My issue is resolved I really appreciate you assistance.

1 Like

The analogy of vault being folder-like applies alright to V1 KV. For V2 the documentations is not as comprehensible. Is there a blog post about this? The Learn site and the docs do not cover V2 very well.