-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[extension/bearertokenauth] Fix the RPC credential updates #35653
base: main
Are you sure you want to change the base?
Conversation
Note that I have in-fact never written golang before so would appreciate any pointers on how this actually should be done. |
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
type PerRPCAuth struct { | ||
metadata map[string]string | ||
renderMetadata func() map[string]string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tabs, not spaces
@@ -22,13 +22,15 @@ import ( | |||
var _ credentials.PerRPCCredentials = (*PerRPCAuth)(nil) | |||
|
|||
// PerRPCAuth is a gRPC credentials.PerRPCCredentials implementation that returns an 'authorization' header. | |||
// NOTE: Needs a function instead of static values so the data can be refreshed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this note better as an issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can try and reword the note - this is merely here to help people not trip up on the bug that was originally here as the design does not make it obvious that you actually need a function pointer rather than a static value (that then will not get refreshed)
Please add changelog, please add a test. |
- Change spaces to tabs - Reword the note
Fixes a bug - The gRPC headers not getting updated after collecter startup
Description
Does not appear there were any open/closed issues for this, but somewhere down the line the extension handling code has likely changed so that the
PerRPCCredentials
does not get called anymore for each call.To excite the issue - you can start the collector with valid credentials, then inject invalid credentials to the token file.
Expected behavior: The collector starts using the invalid credentials and fails authentication
Old behavior: The collector keeps using the credentials it read at startup (problematic if you need to refresh the token)
This fixes the behavior by moving the evaluation of the authorization token to happen when the metadata is being fetched instead of at a time when the auth object is created.
Testing
Manual testing performed by manipulating the token file on the disk.
The interface to the rest of the application should remain exactly the same.