
Legacy Application Auto-Auth Workflow
- Vault Agent authenticates to Vault using a machine-oriented auth method (e.g., AppRole, Kubernetes).
- Vault returns a token, which the Agent writes to a local sink file.
- The legacy application reads the token from the sink and calls the Vault API for secret operations (read secrets, encrypt/decrypt).


How Auto-Auth Works
Vault Agent’s auto-auth feature is configured in a single HCL file. It authenticates using the specified method, writes the returned token to a flat file sink, and then handles reauthentication and renewal automatically.
Supported Auth Methods
The Vault Agent supports all machine-oriented auth methods:
For detailed configuration parameters (required and optional), see the Vault Agent Auto-Auth documentation.
Example: AppRole Auto-Auth Configuration
Below is a minimal HCL configuration for AppRole authentication, writing the token to a file sink:Sink Configuration
Vault Agent currently supports only thefile sink type. Common parameters:
type(alwaysfile)path(location for the token file)mode(file permissions, default0640)wrap_ttl(optional response-wrapping TTL)

Response Wrapping for Enhanced Security
To protect tokens in transit or at the host, Vault offers a response-wrapping feature. You can apply wrapping at either the auth method or the sink.1. Wrap at the Auth Method
When you setwrap_ttl under the auth method, Vault returns a single-use wrapped token reference. This prevents eavesdropping on the actual token but means the Agent cannot renew it.


Response wrapping at the auth method protects against MITM but prevents token renewal.
2. Wrap at the Sink
By settingwrap_ttl under the sink stanza, the Agent unwraps the Vault response and rewraps it for the application. The Agent can still renew the token, but the token travels in cleartext between Vault and the Agent.

Comparison of Wrapping Options

Conclusion
Vault Agent’s Auto-Auth and Token Sink features simplify secret injection for legacy applications by centralizing authentication, renewal, and local storage of Vault tokens. Response wrapping further enhances security according to your threat model.Links and References
- Vault Agent Auto-Auth Documentation
- Vault Response Wrapping
- HashiCorp Vault: AppRole Auth Method
- Kubernetes Authentication