-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(secret/vault): update strategy to refresh token #570
Merged
Conversation
This file contains 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
Codecov Report
@@ Coverage Diff @@
## master #570 +/- ##
==========================================
+ Coverage 54.23% 54.43% +0.19%
==========================================
Files 181 181
Lines 15093 15131 +38
==========================================
+ Hits 8186 8236 +50
+ Misses 6590 6578 -12
Partials 317 317
|
jbrockopp
changed the title
fix(secret/vault): refreshing and renewing tokens
fix(secret/vault): refreshing token
Jan 20, 2022
jbrockopp
changed the title
fix(secret/vault): refreshing token
fix(secret/vault): update strategy to refresh token
Jan 20, 2022
JordanSussman
approved these changes
Jan 20, 2022
wass3r
approved these changes
Jan 24, 2022
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.
Closes go-vela/community#473
This change resolves a problem with the token expiring using HashiCorp Vault as an
engine
forsecrets
in Vela.At this time, the behavior appears specifically related to using the
AWS
authentication method with Vault.Currently, the code used to renew the Vault token spawns an infinite
for
loop:server/secret/vault/refresh.go
Lines 117 to 132 in 0b72c15
Problem 1
The first issue with this is the usage of an empty time to live (TTL) for the token returned from Vault:
server/secret/vault/refresh.go
Line 121 in 0b72c15
Previously, we passed
c.TTL
to the VaultRenewSelf()
call but no code setsc.TTL
so that value is always0s
.We've removed both the
c.TTL
variable as well as the call toRenewSelf()
since they are not needed.Problem 2
The second issue with this is not handling when the TTL for the token is less than the configured renewal duration.
The current code has no checks to verify the token TTL is less than the renewal duration.
The problem this leads to is the token will expire (due to the TTL), before being renewed leading to a
403
error.Now, we'll always refresh the token after waiting the configured renewal duration:
server/secret/vault/refresh.go
Lines 121 to 133 in 525707a
Tech Debt
Accompanying the above changes, I added/updated some of the logging around this for future troubleshooting.
Also, a previous change was introduced to add metadata fields to secrets:
However, I noticed that those fields weren't applied to secrets in Vault so I added support for that:
server/secret/vault/vault.go
Lines 238 to 272 in 6b33471
server/secret/vault/vault.go
Lines 328 to 346 in 6b33471