Policies
- Vault policies permit or deny access to certain paths or actions within vault (RBAC).
- Provides granular control over who accesses what.
- Policies are default deny (Implicit deny), which means no policy no access.
- Policies are attached to tokens and tokens can have multiple policies attached.
- Policies are cumulative and capabilities are additive.
Managing Policies
Section titled “Managing Policies”| Command | Effect |
|---|---|
vault policy list | List all policies |
vault policy write POLICY_NAME POLICY_FILE_PATH | Create a policy |
vault policy read POLICY_NAME | Read a policy |
vault policy delete POLICY_NAME | Delete a policy |
vault policy fmt POLICY_FILE_PATH | Formats policy file according to syntax |
Anatomy of Policy
Section titled “Anatomy of Policy”- Structure of policy looks like:
path "PATH" { capabilities = ["LIST_OF_CAPABILITIES"]}path "PATH" { capabilities = ["LIST_OF_CAPABILITIES"]}path "PATH" { capabilities = ["LIST_OF_CAPABILITIES"]}...Example:
path "kv/data/apps/cicd" { capabilities = ["read", "update", "delete"]}path "sys/policies/*" { capabilities = ["create", "update", "list", "delete"]}path "aws/creds/webapp" { capabilities = ["read"]}- There are root protected paths which are available to only root user and must not be exposed to other users unless until required, some of them are here:
auth/token/create-orphanpki/root/sign-self-issuedsys/rotatesys/sealsys/step-down
- This is how to provide access to users to protected paths:
path "PROTECTED_PATH" { capabilities = ["sudo"]}Customizing paths
Section titled “Customizing paths”*
*is a wildcard and can only be used at the end of at the end of a path. It can be used to signify anything “after” a path or as a pattern. Ex:/.../.../...*or/.../.../*.- It also matches all the sub paths and sections beyond it as well.
+supports wildcard matching for single section in the path.- Can be used in between the path.
- Can be used multiple times. Ex:
/.../+/...or/.../+/+/.../+/....
ACL Templating
Section titled “ACL Templating”- Use variable replacement in some policy strings with values available to the token.
- Define policy paths using double curly brackets.
path ".../{{VARIABLE_REFERENCE}}/*" { capabilities = ["LIST_OF_CAPABILITIES"]}Capabilities
Section titled “Capabilities”create,list,read,update,deleteare capabilities that work as per their names.sudocapability allows access to protected paths.denydisallows access irrespective of any other granted access and capabilities.