fix: cert auth method watches cert file change and NewCreds() notific…#28126
fix: cert auth method watches cert file change and NewCreds() notific…#28126VioletHynes merged 1 commit intohashicorp:mainfrom
Conversation
|
Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement Learn more about why HashiCorp requires a CLA and what the CLA includes Have you signed the CLA already but the status is still pending? Recheck it. |
1bfe278 to
6982a03
Compare
VioletHynes
left a comment
There was a problem hiding this comment.
Hi there! Thanks for your contribution.
Reading through the description and your submission, this makes sense to me. That being said, I'm not an expert in cert logic, so I'm going to try and get a second set of eyes on this that does have that expertise and talk through this with them before I call this approved.
In either case, I've added some comments that will need to be addressed before this is merged. This is shaping up to be awesome so far :D
|
To add to the suggestions Scott and I made, this will also need a changelog (a file called You will also want to update the docs around this feature. In particular, there should be a new entry added for the new config option, and you should also update the Thanks for the contribution! Excited to get this merged. Please let me know if you have any questions about any of the suggestions. |
6982a03 to
d172a95
Compare
|
Hi Violet and Scott, After checking the existing code logic carefully, I realised there were special cases that the users may:
Although the most common use case is setting all 3 options, we need to cover them in the test cases and keep it backward compatible. So I adjusted the codes a little bit for this. I also added the release note and relevant module docs, please take a look at them. Any further suggestions, please let me know. Cheers |
cca470b to
6ffde2a
Compare
VioletHynes
left a comment
There was a problem hiding this comment.
Hi there! Looking better! I've asked a few clarifying questions and I have a few small suggestions, too.
|
Closes #12233 (as merging this will make |
VioletHynes
left a comment
There was a problem hiding this comment.
This looks good! Just a few small things to get this over the finish line. I agree that we should make enable_reauth_on_new_credentials supported.
If you could remove the bits of text:
// NOTE: This is unsupported outside of testing and may disappear at any
// time.
above it (in the two config.go files) that'd be great. We should do that if we're documenting it as officially supported.
6824ee7 to
8e98f4e
Compare
8e98f4e to
304d646
Compare
VioletHynes
left a comment
There was a problem hiding this comment.
Thanks for this! Approved. Apologies it took us some time to get to this, and I appreciate your hard work and readiness to update based on feedback.
I've kicked off CI, and assuming it's all green, I'll get this merged :)
Thank you for your contribution!
|
I saw there were tiny red ones. No worry, let me solve the race condition in test cases, they are only for debugging purpose but we can do it in the right way. |
304d646 to
0ee774e
Compare
…ation Signed-off-by: Jason Joo <hblzxsj@gmail.com>
0ee774e to
41993b2
Compare
|
Thanks for the contribution, and the diligence in the added and improved tests. Merging! 🚢 |
|
Thanks for your kind and patient review, @VioletHynes and @sgmiller |
…ation (hashicorp#28126) Signed-off-by: Jason Joo <hblzxsj@gmail.com>
…ation (hashicorp#28126) Signed-off-by: Jason Joo <hblzxsj@gmail.com>
…ation (hashicorp#28126) Signed-off-by: Jason Joo <hblzxsj@gmail.com>
Hi community and committees,
Recently, our team encountered TLS certificate reloading issue even after adding
reload: truetoconfigwhen usingcertmethod. After checking, it looks like not functioning properly.Although there was a previous PR(#19002 ) which added certificate reloading capability to auto auth, it doesn't work in the actual use case. After checking further a little bit, I found that the agent blocked at the line auth.go:526 while the server responded with 400 errors at transport layer due to expired certificate. In our case, we use certificates in cloud native applications with 5 days as expiry and refresh the certs every day.
At the same time, the lifetime loop also listens on a channel returned by NewCreds() but it's not implemented in
certmethod. So it may be the best and shortest path adding this support to make the reloading mechanism work.Description
So in a nutshell, the
reloadoption forcertmethod only guaranteeAuthClient()return a different client instance when called. It doesn't guarantee the renewed certificate on disk can sooner or later be used in auth. I don't know whether people maintain a good understanding on what this option actually does but it would be better to be more straightforward and more automated in reloading it.This PR adds implementation of existing
NewCreds()method in the interface as well as a new optional optionreload_periodfor the internal file watching loop. And they only take effect whenreloadis enabled. In common cases,reloadis the only option people need to set when they need.TODO only if you're a HashiCorp employee
to N, N-1, and N-2, using the
backport/ent/x.x.x+entlabels. If this PR is in the CE repo, you should only backport to N, using thebackport/x.x.xlabel, not the enterprise labels.of a public function, even if that change is in a CE file, double check that
applying the patch for this PR to the ENT repo and running tests doesn't
break any tests. Sometimes ENT only tests rely on public functions in CE
files.
in the PR description, commit message, or branch name.
description. Also, make sure the changelog is in this PR, not in your ENT PR.