Skip to content

[fix][authentication] Store the original authentication data - #19519

Merged
nodece merged 4 commits into
apache:masterfrom
nodece:store-original-auth-data-role
Feb 16, 2023
Merged

nodece merged 4 commits into
apache:masterfrom
nodece:store-original-auth-data-role

Conversation

@nodece

@nodece nodece commented Feb 14, 2023 •

Copy link
Copy Markdown
Member

Motivation

In the authentication:

  • With the proxy, the broker stores the client authentication to the originalAuthData and originalPrincipal, and stores the proxy authentication to the authenticationData and authRole.
  • Without the proxy, the broker stores the authentication to the authenticationData and authRole

When with the proxy, the broker only checks whether originalAuthData is expired. If true, the broker sends AuthChallenge to the client, then the client sends CommandAuthResponse.

In handleAuthResponse logic, the broker always stores the authentication to authenticationData and authRole, 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

  • Fix storing the authentication in the authChallengeSuccessCallback
  • Add MockMutableAuthenticationProvider and MockMutableAuthenticationState to refresh the role and datasource
  • Make MockAlwaysExpiredAuthenticationState extends MockMutableAuthenticationState to avoid the code duplication, and override the isExpired

Verifying this change

  • Make sure that the change passes the CI checks.

Added testRefreshOriginalPrincipalWithAuthDataForwardedFromProxy test

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

@nodece nodece self-assigned this Feb 14, 2023
@github-actions github-actions Bot added the doc-not-needed Your PR changes do not impact docs label Feb 14, 2023
@nodece nodece added this to the 3.0.0 milestone Feb 14, 2023

@michaeljmarshall michaeljmarshall left a comment

Copy link
Copy Markdown
Member

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.

}

@Test
public void testRefreshOriginalPrincipalWithAuthDataForwardedFromProxy() throws Exception {

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member Author

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.

Copy link
Copy Markdown
Member

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.

@nodece

nodece commented Feb 15, 2023

Copy link
Copy Markdown
Member Author

Hi @michaeljmarshall, I updated this PR.

@michaeljmarshall michaeljmarshall left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, great work @nodece

@nodece

nodece commented Feb 16, 2023

Copy link
Copy Markdown
Member Author

/pulsarbot rerun-failure-checks

1 similar comment
@nodece

nodece commented Feb 16, 2023

Copy link
Copy Markdown
Member Author

/pulsarbot rerun-failure-checks

Signed-off-by: Zixuan Liu <[email protected]>
@nodece
nodece merged commit 2d90089 into apache:master Feb 16, 2023
@michaeljmarshall

Copy link
Copy Markdown
Member

@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.

@nodece

nodece commented Feb 17, 2023

Copy link
Copy Markdown
Member Author

@michaeljmarshall Thank you for your work! I look forward to your contribution!

@michaeljmarshall

Copy link
Copy Markdown
Member

@nodece - just so you know, I finished cherry picking my changes to the older branches.

nodece added a commit to nodece/pulsar that referenced this pull request Mar 2, 2023
…19519)

Signed-off-by: Zixuan Liu <[email protected]>

(cherry picked from commit 2d90089)
Signed-off-by: Zixuan Liu <[email protected]>
nodece added a commit to nodece/pulsar that referenced this pull request Mar 2, 2023
…19519)

Signed-off-by: Zixuan Liu <[email protected]>

(cherry picked from commit 2d90089)
Signed-off-by: Zixuan Liu <[email protected]>
nodece added a commit that referenced this pull request Mar 13, 2023
Signed-off-by: Zixuan Liu <[email protected]>

(cherry picked from commit 2d90089)
Signed-off-by: Zixuan Liu <[email protected]>
nodece added a commit to nodece/pulsar that referenced this pull request Mar 13, 2023
…19519)

Signed-off-by: Zixuan Liu <[email protected]>

(cherry picked from commit 2d90089)
Signed-off-by: Zixuan Liu <[email protected]>
michaeljmarshall added a commit that referenced this pull request Mar 18, 2023
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.
@michaeljmarshall

Copy link
Copy Markdown
Member

@nodece - just letting you know there was a minor issue when cherry picking this to branch-2.11. Some of the ServerCnxTest tests were failing. I fixed it with ad06fac.

michaeljmarshall pushed a commit to michaeljmarshall/pulsar that referenced this pull request Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants