-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix][broker] Only validate superuser access if authz enabled #19989
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] Only validate superuser access if authz enabled #19989
Conversation
poorbarcode
left a comment
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.
Since there will not have a scenario like this disabled authentication & enabled authorization, so it will work.
LGTM
Correct. The broker actually fails on startup if that is the configuration: pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java Lines 695 to 698 in 6621fd3
|
|
/pulsarbot run-failure-checks |
|
@michaeljmarshall Is it possible to add a test to make we will not be impacted in the future? |
|
/pulsarbot run-failure-checks |
|
Looks like there are some legitimate test failures. I fixed the first. The second is |
|
/pulsarbot run-failure-checks |
I decided to remove the configuration to enable authorization. It was not actually used in the previous tests and it was forcing the failure here. If we want to test authorization in that test, we need to enable authentication as well. |
|
/pulsarbot run-failure-checks |
|
There are more, legitimate test failures. This one is next pulsar/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/NamespacesTest.java Lines 706 to 707 in 3a069ed
When running the |
|
This is the part of the code that has the "hack" described in the above comment: pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java Lines 512 to 519 in 3b76dd4
pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java Lines 536 to 547 in 3b76dd4
|
|
After discovering the hack, I noticed that the "easiest" solution is to add the check for authentication back in. I don't have time to dig into the (surprising) coupling of authorization and geo replication, so I created an issue #20023. |
@codelipenghui - given that it made a test fail, I think we're "covered" because I updated the test. I think the more ideal solution will be to refactor this logic so that it is in the |
Codecov Report
@@ Coverage Diff @@
## master #19989 +/- ##
============================================
- Coverage 72.89% 72.82% -0.08%
+ Complexity 31619 31594 -25
============================================
Files 1861 1861
Lines 137356 137383 +27
Branches 15117 15123 +6
============================================
- Hits 100131 100054 -77
- Misses 29271 29371 +100
- Partials 7954 7958 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
I'll take care of cherry picking this later tonight. There are some merge conflicts to resolve. |
### Motivation In #19455, I added a requirement that only the proxy role could supply an original principal. That check is only supposed to apply when the broker has authorization enabled. However, in one case, that was not the case. This PR does a check and returns early when authorization is not enabled in the broker. See #19830 (comment) for additional motivation. ### Modifications * Update the `PulsarWebResource#validateSuperUserAccessAsync` to only validate when authentication and authorization are enabled in the configuration. ### Verifying this change This is a trivial change. It'd be good to add tests, but I didn't include them here because this is a somewhat urgent fix. There was one test that broke because of this change, so there is at least some existing coverage. ### Documentation - [x] `doc-not-needed` ### Matching PR in forked repository PR in forked repository: michaeljmarshall#39 (cherry picked from commit 1a6c28d)
In #19455, I added a requirement that only the proxy role could supply an original principal. That check is only supposed to apply when the broker has authorization enabled. However, in one case, that was not the case. This PR does a check and returns early when authorization is not enabled in the broker. See #19830 (comment) for additional motivation. * Update the `PulsarWebResource#validateSuperUserAccessAsync` to only validate when authentication and authorization are enabled in the configuration. This is a trivial change. It'd be good to add tests, but I didn't include them here because this is a somewhat urgent fix. There was one test that broke because of this change, so there is at least some existing coverage. - [x] `doc-not-needed` PR in forked repository: michaeljmarshall#39 (cherry picked from commit 1a6c28d)
In #19455, I added a requirement that only the proxy role could supply an original principal. That check is only supposed to apply when the broker has authorization enabled. However, in one case, that was not the case. This PR does a check and returns early when authorization is not enabled in the broker. See #19830 (comment) for additional motivation. * Update the `PulsarWebResource#validateSuperUserAccessAsync` to only validate when authentication and authorization are enabled in the configuration. This is a trivial change. It'd be good to add tests, but I didn't include them here because this is a somewhat urgent fix. There was one test that broke because of this change, so there is at least some existing coverage. - [x] `doc-not-needed` PR in forked repository: michaeljmarshall#39 (cherry picked from commit 1a6c28d) (cherry picked from commit 36f0db5)
|
Cherry picking complete. |
…#19989) In apache#19455, I added a requirement that only the proxy role could supply an original principal. That check is only supposed to apply when the broker has authorization enabled. However, in one case, that was not the case. This PR does a check and returns early when authorization is not enabled in the broker. See apache#19830 (comment) for additional motivation. * Update the `PulsarWebResource#validateSuperUserAccessAsync` to only validate when authentication and authorization are enabled in the configuration. This is a trivial change. It'd be good to add tests, but I didn't include them here because this is a somewhat urgent fix. There was one test that broke because of this change, so there is at least some existing coverage. - [x] `doc-not-needed` PR in forked repository: michaeljmarshall#39 (cherry picked from commit 1a6c28d) (cherry picked from commit 36f0db5)
Motivation
In #19455, I added a requirement that only the proxy role could supply an original principal. That check is only supposed to apply when the broker has authorization enabled. However, in one case, that was not the case. This PR does a check and returns early when authorization is not enabled in the broker.
See #19830 (comment) for additional motivation.
Modifications
PulsarWebResource#validateSuperUserAccessAsyncto only validate when authentication and authorization are enabled in the configuration.Verifying this change
This is a trivial change. It'd be good to add tests, but I didn't include them here because this is a somewhat urgent fix. There was one test that broke because of this change, so there is at least some existing coverage.
Documentation
doc-not-neededMatching PR in forked repository
PR in forked repository: michaeljmarshall#39