Skip to main content
In this guide, you’ll learn how to create and test tokens scoped to specific policies and write administrative policies for Vault operators. Leveraging policy-based access control (PBAC) in HashiCorp Vault ensures fine-grained security, minimal access, and clear audit trails.

Table of Contents

  1. Creating a Token with a Policy
  2. Inspecting an Existing Token
  3. Testing Token Capabilities
  4. Writing Administrative Policies
  5. Links and References

Creating a Token with a Policy

To issue a new Vault token and bind it to one or more policies, run:
Example output:

Token Attributes

Every token in Vault inherits the default policy. Always design your custom policies to grant only the permissions required for your application.

Inspecting an Existing Token

To review the details and policies of an existing Vault token, use:
This command displays all token attributes, including the list of policies attached.

Testing Token Capabilities

Before deploying a token in production, validate that it grants exactly the permissions you need. Suppose your web-app policy (web-app.hcl) should:
  1. Read a secret at secret/data/api/key/google.
  2. Generate AWS credentials from aws/creds/s3-readonly.
After writing and loading your policy:
Test the policy with these steps:
Always test both allowed and denied operations. Overprovisioned policies can lead to security risks.

Writing Administrative Policies

Vault operators need permissions to manage core system paths under sys/. Below is an example HCL policy granting common operator capabilities:

Key Points

  • Capabilities
    • read, list, create, update, delete: Standard operations.
    • sudo: Grants access to root-protected endpoints (use sparingly).
  • Least Privilege
    Only include the paths and capabilities that each operator role truly requires.

Watch Video

Practice Lab