Skip to content
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] Implement authenticateAsync for AuthenticationProviderList #20132

Merged
merged 1 commit into from
Apr 19, 2023

Conversation

michaeljmarshall
Copy link
Member

PIP: #12105 and #19771

Motivation

With the implementation of asynchronous authentication in PIP 97, I missed a case in the AuthenticationProviderList where we need to implement the authenticateAsync methods. This PR is necessary for making the AuthenticationProviderToken and the AuthenticationProviderOpenID work together, which is necessary for anyone transitioning to AuthenticationProviderOpenID.

Modifications

  • Implement AuthenticationListState#authenticateAsync using a recursive algorithm that first attempts to authenticate the client using the current authState and then tries the remaining options.
  • Implement AuthenticationProviderList#authenticateAsync using a recursive algorithm that attempts each provider sequentially.
  • Add test to AuthenticationProviderListTest that exercises this method. It didn't technically fail previously, but it's worth adding.
  • Add test to AuthenticationProviderOpenIDIntegrationTest to cover the exact failures that were causing problems.

Verifying this change

A new test is added and all existing tests pass.

Documentation

  • doc-not-needed

Matching PR in forked repository

PR in forked repository: Skipping since I was able to run the relevant tests locally

@michaeljmarshall michaeljmarshall added type/feature The PR added a new feature or issue requested a new feature doc-not-needed Your PR changes do not impact docs area/authn ready-to-test labels Apr 18, 2023
@michaeljmarshall michaeljmarshall added this to the 3.0.0 milestone Apr 18, 2023
@michaeljmarshall michaeljmarshall added the release/blocker Indicate the PR or issue that should block the release until it gets resolved label Apr 18, 2023
Copy link
Contributor

@dlg99 dlg99 left a comment

Choose a reason for hiding this comment

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

LGTM

@codecov-commenter
Copy link

Codecov Report

Merging #20132 (e3b7323) into master (b50e880) will increase coverage by 35.16%.
The diff coverage is 56.75%.

Impacted file tree graph

@@              Coverage Diff              @@
##             master   #20132       +/-   ##
=============================================
+ Coverage     37.75%   72.91%   +35.16%     
- Complexity    12534    31929    +19395     
=============================================
  Files          1691     1868      +177     
  Lines        128811   138411     +9600     
  Branches      14045    15236     +1191     
=============================================
+ Hits          48632   100927    +52295     
+ Misses        73850    29444    -44406     
- Partials       6329     8040     +1711     
Flag Coverage Δ
inttests 24.17% <0.00%> (+<0.01%) ⬆️
systests 24.77% <0.00%> (-0.21%) ⬇️
unittests 72.22% <56.75%> (+39.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...xtensions/channel/ServiceUnitStateChannelImpl.java 83.79% <ø> (+83.21%) ⬆️
.../org/apache/pulsar/PulsarClusterMetadataSetup.java 72.51% <33.33%> (+55.54%) ⬆️
...ker/authentication/AuthenticationProviderList.java 46.57% <51.92%> (+46.57%) ⬆️
...ns/channel/ServiceUnitStateCompactionStrategy.java 80.95% <83.33%> (+70.42%) ⬆️
...n/java/org/apache/pulsar/broker/PulsarService.java 81.63% <100.00%> (+11.98%) ⬆️
.../pulsar/compaction/StrategicTwoPhaseCompactor.java 76.49% <100.00%> (+1.70%) ⬆️
...a/org/apache/pulsar/client/impl/TableViewImpl.java 86.29% <100.00%> (+34.22%) ⬆️

... and 1420 files with indirect coverage changes

@RobertIndie RobertIndie merged commit 58ccf02 into apache:master Apr 19, 2023
RobertIndie pushed a commit that referenced this pull request Apr 19, 2023
…ist (#20132)

PIP: #12105 and #19771

### Motivation

With the implementation of asynchronous authentication in PIP 97, I missed a case in the `AuthenticationProviderList` where we need to implement the `authenticateAsync` methods. This PR is necessary for making the `AuthenticationProviderToken` and the `AuthenticationProviderOpenID` work together, which is necessary for anyone transitioning to `AuthenticationProviderOpenID`.

### Modifications

* Implement `AuthenticationListState#authenticateAsync` using a recursive algorithm that first attempts to authenticate the client using the current `authState` and then tries the remaining options.
* Implement `AuthenticationProviderList#authenticateAsync` using a recursive algorithm that attempts each provider sequentially.
* Add test to `AuthenticationProviderListTest` that exercises this method. It didn't technically fail previously, but it's worth adding.
* Add test to `AuthenticationProviderOpenIDIntegrationTest` to cover the exact failures that were causing problems.

(cherry picked from commit 58ccf02)
@michaeljmarshall michaeljmarshall deleted the fix-auth-provider-list branch April 19, 2023 01:36
@michaeljmarshall michaeljmarshall removed the release/blocker Indicate the PR or issue that should block the release until it gets resolved label Apr 19, 2023
michaeljmarshall added a commit to michaeljmarshall/pulsar that referenced this pull request Apr 20, 2023
…ist (apache#20132)

PIP: apache#12105 and apache#19771

With the implementation of asynchronous authentication in PIP 97, I missed a case in the `AuthenticationProviderList` where we need to implement the `authenticateAsync` methods. This PR is necessary for making the `AuthenticationProviderToken` and the `AuthenticationProviderOpenID` work together, which is necessary for anyone transitioning to `AuthenticationProviderOpenID`.

* Implement `AuthenticationListState#authenticateAsync` using a recursive algorithm that first attempts to authenticate the client using the current `authState` and then tries the remaining options.
* Implement `AuthenticationProviderList#authenticateAsync` using a recursive algorithm that attempts each provider sequentially.
* Add test to `AuthenticationProviderListTest` that exercises this method. It didn't technically fail previously, but it's worth adding.
* Add test to `AuthenticationProviderOpenIDIntegrationTest` to cover the exact failures that were causing problems.

(cherry picked from commit 58ccf02)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/authn doc-not-needed Your PR changes do not impact docs ready-to-test type/feature The PR added a new feature or issue requested a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants