[fix][authentication] Store the original authentication data#19519
[fix][authentication] Store the original authentication data#19519nodece merged 4 commits intoapache:masterfrom
Conversation
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
michaeljmarshall
left a comment
There was a problem hiding this comment.
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
| } | ||
|
|
||
| @Test | ||
| public void testRefreshOriginalPrincipalWithAuthDataForwardedFromProxy() throws Exception { |
There was a problem hiding this comment.
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.
For current design, it works fine.
There was a problem hiding this comment.
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 <nodeces@gmail.com>
|
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 <nodeces@gmail.com>
michaeljmarshall
left a comment
There was a problem hiding this comment.
LGTM, great work @nodece
|
/pulsarbot rerun-failure-checks |
1 similar comment
|
/pulsarbot rerun-failure-checks |
|
@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. |
Signed-off-by: Zixuan Liu <nodeces@gmail.com> (cherry picked from commit 2d90089) Signed-off-by: Zixuan Liu <nodeces@gmail.com>
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.
Motivation
In the authentication:
originalAuthDataandoriginalPrincipal, and stores the proxy authentication to theauthenticationDataandauthRole.authenticationDataandauthRoleWhen with the proxy, the broker only checks whether
originalAuthDatais expired. If true, the broker sendsAuthChallengeto the client, then the client sendsCommandAuthResponse.In
handleAuthResponselogic, the broker always stores the authentication toauthenticationDataandauthRole, 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
authChallengeSuccessCallbackMockMutableAuthenticationProviderandMockMutableAuthenticationStateto refresh the role and datasourceMockAlwaysExpiredAuthenticationStateextendsMockMutableAuthenticationStateto avoid the code duplication, and override theisExpiredVerifying this change
Added
testRefreshOriginalPrincipalWithAuthDataForwardedFromProxytestDocumentation
docdoc-requireddoc-not-neededdoc-complete