-
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
[improve][broker] Authorize originalPrincipal when provided #19830
[improve][broker] Authorize originalPrincipal when provided #19830
Conversation
...broker-common/src/main/java/org/apache/pulsar/broker/authorization/AuthorizationService.java
Show resolved
Hide resolved
...er-common/src/test/java/org/apache/pulsar/broker/authorization/AuthorizationServiceTest.java
Show resolved
Hide resolved
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
(cherry picked from commit 6bc3530)
I'm not sure it really makes sense to add the |
@michaeljmarshall |
@coderzc good catch. The test is actually failing here too. It is in the "flaky test" batch and I didn't take a look. There are several |
The ServerCnxTest class is run as part of the flaky tests, so #19830 was merged without noticing that the changes didn't actually pass tests. This commit fixes the test by changing the assertions to ensure that "correct" combinations of roles and original principals are verified.
The ServerCnxTest class is run as part of the flaky tests, so #19830 was merged without noticing that the changes didn't actually pass tests. This commit fixes the test by changing the assertions to ensure that "correct" combinations of roles and original principals are verified. (cherry picked from commit 13f4a0d)
The ServerCnxTest class is run as part of the flaky tests, so #19830 was merged without noticing that the changes didn't actually pass tests. This commit fixes the test by changing the assertions to ensure that "correct" combinations of roles and original principals are verified. (cherry picked from commit 13f4a0d)
The ServerCnxTest class is run as part of the flaky tests, so #19830 was merged without noticing that the changes didn't actually pass tests. This commit fixes the test by changing the assertions to ensure that "correct" combinations of roles and original principals are verified. (cherry picked from commit 13f4a0d)
@coderzc - all branches |
…ior (#19845) Relates to: #19455 #19830 ### Motivation When I added the requirement for the proxy to use a role in the `proxyRoles` set, I didn't add a test that checked the negative case. This new test was first added in #19830 with one small difference. The goal of this test is to ensure that authorization of the client role and the original role is handled correctly. ### Modifications * Add new test class named `AuthorizationServiceTest`. We use `pass.proxy` and `fail.proxy` as proxy roles to simulate cases where the proxy's role passes and fails authorization, which is always possible. * Add new mock authorization provider named `MockAuthorizationProvider`. The logic is to let any role that starts with `pass` be considered authorized. ### Verifying this change This is a new test. It simply verifies the existing behavior to prevent future regressions. ### Documentation - [x] `doc-not-needed` ### Matching PR in forked repository PR in forked repository: Skipping forked test since the new tests pass locally and there are no other modifications.
Hi @michaeljmarshall any progress on the doc? Thanks! |
The ServerCnxTest class is run as part of the flaky tests, so apache#19830 was merged without noticing that the changes didn't actually pass tests. This commit fixes the test by changing the assertions to ensure that "correct" combinations of roles and original principals are verified. (cherry picked from commit 13f4a0d) (cherry picked from commit 45f303c)
I saw that you pushed a commit into You can reproduce this issue like this:
Same for Could you take a look? |
I'm not sure what you mean here. This PR (#19830) was merged to
That was not a mistake.
I can see in the code why this is happening. It must just be a case that wasn't covered by any tests. I can try to put up a fix soon.
You also need to connect through a pulsar proxy for this to actually be an issue because the Let me know if you have any questions. |
@poorbarcode - this should solve it: #19989. We might want to stop the current 2.10 and 2.11 releases, depending on how important it is for users to run with authn but without authz. |
### 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
### 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)
…pache#19830)" This reverts commit 0c365e2. This commit was made as a concession because some were concerned that it might break implementations. My primary argument was that those implementations were at risk, so they were okay to "break". Therefore, I am reverting this on our fork. It is unlikely for there to be many conflicts because of this diversion.
…ior (apache#19845) Relates to: apache#19455 apache#19830 ### Motivation When I added the requirement for the proxy to use a role in the `proxyRoles` set, I didn't add a test that checked the negative case. This new test was first added in apache#19830 with one small difference. The goal of this test is to ensure that authorization of the client role and the original role is handled correctly. ### Modifications * Add new test class named `AuthorizationServiceTest`. We use `pass.proxy` and `fail.proxy` as proxy roles to simulate cases where the proxy's role passes and fails authorization, which is always possible. * Add new mock authorization provider named `MockAuthorizationProvider`. The logic is to let any role that starts with `pass` be considered authorized. ### Verifying this change This is a new test. It simply verifies the existing behavior to prevent future regressions. ### Documentation - [x] `doc-not-needed` ### Matching PR in forked repository PR in forked repository: Skipping forked test since the new tests pass locally and there are no other modifications. (cherry picked from commit c6de57c)
This reverts commit 6a9a22c.
…#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 made a change to require that only a role in the broker's
proxyRoles
configuration could provide an original principal. Because this change can break certain installations on patch upgrades, a better temporary solution is to always authorize theoriginalPrincipal
when present and to allow non proxy roles to supply the original principal.Modifications
AuthorizationService#isValidOriginalPrincipal
to allow non proxy roles to supply an original principal. I added a log line in place of the previous failure.ServiceConfiguration#getProxyRoles()
to also check if the original principal is not blank. When it is not blank, we will authorize both roles. Note that this is consistent with the logic in theAuthorizationService#isValidOriginalPrincipal
method that is already merged to master.Verifying this change
I modified existing tests to make this work, and I added a new test to cover mos of the relevant cases where we changed logic.
I plan to copy the new tests to master since they will be valuable there too.
Documentation
doc-required
I will follow up with docs for these proxy changes.
Matching PR in forked repository
PR in forked repository: in order to save time, we'll run tests directly in the pulsar repo.