Chapter 94: HashiCorp Vault and Secrets Management
94.9 Tokens — TTL, renewal and revocation
Story (fictional teaching scenario). At a fictional Nagpur company, Arjun and Chloe from Paris stop using one permanent shared token for every process.
Why
A leaked short-lived scoped identity is less harmful than a permanent unrestricted one, but expiry needs client handling.
What
- Token is an opaque authentication credential: do not parse its internal structure.
- TTL is the remaining time-to-live.
- Renewable means a token may request extension; policy and maximum lifetime still constrain it.
- Revocation invalidates the token. Ordinary child token trees and associated leases can also be revoked; orphan and batch tokens differ.
- A token accessor is a limited reference for management, not a login credential. Protect it too.
How
-
Prefer short-lived least-privilege workload tokens.
-
Inspect the returned TTL after renewal.
-
Reauthenticate when renewal is no longer allowed.
-
Treat root tokens as restricted bootstrap/emergency material, not application config.
Example 1: Look up only harmless properties
- Read the command or request.
vault token lookup -format=json
- Read the result.
Output (illustrative; NOT executed against Vault)
{"data":{"ttl":60,"renewable":true,"policies":["shop-read"]}}
- Line by line: This is a deliberately REDACTED illustrative subset. Actual output can include sensitive identity/token information, so do not record the full real response. TTL60 means about sixty seconds remain, not a promise of unlimited renewal.
Example 2: Renewal is bounded
- Read the command or request.
Issued at t=0, expires at t=60
At t=30 request another60seconds
Server permits expiry at t=90
- Read the result.
Output (illustrative; NOT executed against Vault)
Returned remaining TTL: 60 seconds in this example.
- Line by line: Renewal is subject to maximums and token type. A requested increment is not permission to exceed maximum lifetime. Periodic tokens have special renewal behaviour; do not generalize this example to every token.
Ravindra Bagale's Tip
Renewable is not permanent. Always handle expiry.
Renewable म्हणजे कायमचा नाही. Expiry हाताळा.
Renewable का मतलब permanent नहीं. Expiry संभालो.
Did you understand? Let us try it once more.