Refresh Vault token from disk on each Consult.load call#57
Open
Refresh Vault token from disk on each Consult.load call#57
Conversation
d67cbe1 to
f2de018
Compare
f2de018 to
3803261
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Vault Ruby gem caches the token in memory at client initialization and never re-reads. The token is being renewed and written to a shared volume (symlinked to ~/.vault-token), but the running Rails process keeps using the stale cached token. This causes 403 "invalid token" errors when templates are re-rendered at runtime.
Adding
c.token = Vault::Defaults.tokento configure_vault forces the client to re-read the token from ~/.vault-token on every Consult.load call, picking up vault-agent's renewed token.Test Plan
1. Start a console session
2. Load config and remove the explicit token
This simulates a production consult.yml key, relying on a local token agent instead.
3. Write a first token to disk
4. Call configure_vault and verify
5. Simulate a token rotation
In a separate terminal:
6. Call configure_vault again and confirm the new token is picked up
7. Restore your real Vault token when done