Skip to content

Commit d52e530

Browse files
authored
doc: Add an example of templated policy using k8s metadata (#9101)
1 parent 2b8cac7 commit d52e530

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

website/pages/docs/concepts/policies.mdx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,29 @@ unique to the user, whereas names can change over time and can be reused. This
295295
ensures that if a given user or group name is changed, the policy will be
296296
mapped to the intended entity or group.
297297

298+
If you want to use the metadata associated with an authentication plugin in your
299+
templates, you will need to get its _mount accessor_ and access it via the
300+
`aliases` key.
301+
302+
You can get the mount accessor value using the following command:
303+
304+
```shellsession
305+
$> vault auth list
306+
Path Type Accessor Description
307+
---- ---- -------- -----------
308+
kubernetes/ kubernetes auth_kubernetes_xxxx n/a
309+
token/ token auth_token_yyyy token based credentials
310+
```
311+
312+
The following templated policy allow to read the path associated with the
313+
Kubernetes service account namespace of the identity:
314+
315+
```ruby
316+
path "secrets/data/{{identity.entity.aliases.auth_kubernetes_xxxx.metadata.service_account_namespace}}/*" {
317+
capabilities = ["read"]
318+
}
319+
```
320+
298321
## Fine-Grained Control
299322

300323
In addition to the standard set of capabilities, Vault offers finer-grained

0 commit comments

Comments
 (0)