-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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][broker] Let TokenAuthState update authenticationDataSource #19282
[fix][broker] Let TokenAuthState update authenticationDataSource #19282
Conversation
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.
Lgtm
@@ -375,6 +383,7 @@ public String getAuthRole() throws AuthenticationException { | |||
public AuthData authenticate(AuthData authData) throws AuthenticationException { | |||
String token = new String(authData.getBytes(), UTF_8); | |||
checkExpiration(token); | |||
this.authenticationDataSource = new AuthenticationDataCommand(token, remoteAddress, sslSession); |
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.
Are there any thread safety concerns here? would it make sense to make authenticationDataSource field volatile
?
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.
Good question. The current usage of this field in the pulsar code base is all from netty event loops, so I don't think that is needed. Similarly, the jwt
and the expiration
are not volatile
. I see that expiration
is called from another thread, so that one might be 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.
LGTM
Codecov Report
@@ Coverage Diff @@
## master #19282 +/- ##
============================================
+ Coverage 47.04% 52.62% +5.58%
- Complexity 9190 22238 +13048
============================================
Files 607 1824 +1217
Lines 57677 136692 +79015
Branches 6007 15044 +9037
============================================
+ Hits 27132 71939 +44807
- Misses 27598 57271 +29673
- Partials 2947 7482 +4535
Flags with carried forward coverage won't be shown. Click here to find out more.
|
…che#19282) (cherry picked from commit c875365)
Motivation
We use the result of
TokenAuthenticationState#getAuthDataSource
to pass to theAuthorizationProvider
. For custom implementations, it is important that this information is up to date.The
TokenAuthenticationState
fieldAuthenticationDataSource
is set on initialization and never again. Given that tokens can be refreshed, we should update the fieldTokenAuthenticationState#authenticationDataSource
when theauthenticate
method is called.Modifications
authenticationDataSource
whenauthenticate
is called.Verifying this change
A new test is added to cover this change.
Does this pull request potentially affect one of the following parts:
This change will only affect third party
AuthorizationProvider
implementations. It's possible that it could break their integration, though unlikely. Note that we update theauthRole
whenauthenticate
is called.Documentation
doc-not-needed
We do not document this kind of internal behavior anywhere.
Matching PR in forked repository
PR in forked repository: michaeljmarshall#15