-
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][authentication] Store the original authentication data #19519
Conversation
Signed-off-by: Zixuan Liu <[email protected]>
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.
It looks like this PR is partially addressing #19332. It won't solve that issue because this PR doesn't address the fact that we cannot refresh both of the AuthData
objects.
pulsar-broker/src/test/java/org/apache/pulsar/broker/auth/MockAuthenticationProvider.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
Outdated
Show resolved
Hide resolved
@@ -1030,6 +1030,55 @@ public void testVerifyAuthRoleAndAuthDataFromDirectConnectionBroker() throws Exc | |||
})); | |||
} | |||
|
|||
@Test | |||
public void testRefreshOriginalPrincipalWithAuthDataForwardedFromProxy() throws Exception { |
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.
Note that the tests that comment about https://github.com/apache/pulsar/issues/19332
should fail because they make assertions on the current behavior.
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.
For current design, it works fine.
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 must not have written some of the assertions I thought I did. You're right that those tests all pass. It might be worth removing the comments that reference #19332 because your PR will make them incorrect.
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Zixuan Liu <[email protected]>
Hi @michaeljmarshall, I updated this PR. |
pulsar-broker/src/test/java/org/apache/pulsar/broker/auth/MockAuthenticationProvider.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Zixuan Liu <[email protected]>
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, great work @nodece
/pulsarbot rerun-failure-checks |
1 similar comment
/pulsarbot rerun-failure-checks |
Signed-off-by: Zixuan Liu <[email protected]>
@nodece - I think this is a bug, so we can back port it to the older release branches, if you would like. However, I am finishing up cherry picking some of this PR's dependencies, so it will be easiest to delay cherry-picking by a day or two. |
@michaeljmarshall Thank you for your work! I look forward to your contribution! |
@nodece - just so you know, I finished cherry picking my changes to the older branches. |
…19519) Signed-off-by: Zixuan Liu <[email protected]> (cherry picked from commit 2d90089) Signed-off-by: Zixuan Liu <[email protected]>
…19519) Signed-off-by: Zixuan Liu <[email protected]> (cherry picked from commit 2d90089) Signed-off-by: Zixuan Liu <[email protected]>
Signed-off-by: Zixuan Liu <[email protected]> (cherry picked from commit 2d90089) Signed-off-by: Zixuan Liu <[email protected]>
…19519) Signed-off-by: Zixuan Liu <[email protected]> (cherry picked from commit 2d90089) Signed-off-by: Zixuan Liu <[email protected]>
When #19519 was cherry-picked to branch-2.11, it did not implement the authenticate method in the MockMutableAuthenticationState, which led to several test failures in the ServerCnxTest class. This commit fixes those tests. Note that the issue is only in the test code.
…19519) Signed-off-by: Zixuan Liu <[email protected]> (cherry picked from commit 2d90089)
…19519) Signed-off-by: Zixuan Liu <[email protected]> (cherry picked from commit 2d90089)
…19519) Signed-off-by: Zixuan Liu <[email protected]> (cherry picked from commit 2d90089)
Motivation
In the authentication:
originalAuthData
andoriginalPrincipal
, and stores the proxy authentication to theauthenticationData
andauthRole
.authenticationData
andauthRole
When with the proxy, the broker only checks whether
originalAuthData
is expired. If true, the broker sendsAuthChallenge
to the client, then the client sendsCommandAuthResponse
.In
handleAuthResponse
logic, the broker always stores the authentication toauthenticationData
andauthRole
, without considering the proxy case. When the authorization provider checks the role and authentication data, it is unmatched, this is incorrect behavior, so we need to distinguish whether have the proxy and then store the authentication data and role correctly.More context: #18130
Modifications
authChallengeSuccessCallback
MockMutableAuthenticationProvider
andMockMutableAuthenticationState
to refresh the role and datasourceMockAlwaysExpiredAuthenticationState
extendsMockMutableAuthenticationState
to avoid the code duplication, and override theisExpired
Verifying this change
Added
testRefreshOriginalPrincipalWithAuthDataForwardedFromProxy
testDocumentation
doc
doc-required
doc-not-needed
doc-complete