-
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] Support get/remove permissions for AuthorizationProvider #20496
[improve][broker] Support get/remove permissions for AuthorizationProvider #20496
Conversation
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.
Nice direction @Technoboy-. I'll review again when it is ready for review.
bc599cc
to
6fd6843
Compare
https://github.com/apache/pulsar/actions/runs/5184201141/jobs/9344064663
For the above spotbugs issue, I have added this fix |
Thanks |
Codecov Report
@@ Coverage Diff @@
## master #20496 +/- ##
=============================================
+ Coverage 36.78% 72.90% +36.12%
- Complexity 12059 31942 +19883
=============================================
Files 1690 1867 +177
Lines 129001 138614 +9613
Branches 14041 15222 +1181
=============================================
+ Hits 47453 101061 +53608
+ Misses 75294 29535 -45759
- Partials 6254 8018 +1764
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
The migration code looks great. I left several comments.
...roker-common/src/main/java/org/apache/pulsar/broker/authorization/AuthorizationProvider.java
Outdated
Show resolved
Hide resolved
...roker-common/src/main/java/org/apache/pulsar/broker/authorization/AuthorizationProvider.java
Outdated
Show resolved
Hide resolved
* @param topicName | ||
* @return CompletableFuture<Map<String, Set<AuthAction>>> | ||
*/ | ||
default CompletableFuture<Map<String, Set<AuthAction>>> getPermissionsAsync(TopicName topicName) { |
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.
One interesting way we could consider expanding this method is to add the role of the user requesting this operation. As it is currently implemented, the broker will first verify that the role is a tenant admin or a superuser and then will call this method. It seems simpler to defer that kind of checking to the authentication provider. However, we don't do that kind of thing for any of the other methods, so that might not be consistent with the current design. What do you think @Technoboy-?
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.
Currently, my design and implementation are simple. It's only for Admin API usage.
For this getPermissionsAsync
, it's only used for getPermissionsOnTopic
in Admin
If we change getPermissionsAsync(TopicName topicName, String role)
, I think it's really match other methods in the AuthorizationProvider, but we don't need it right now.
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.
Your design and implementation are correct for the built-in policy, but we also need to consider the external policy.
These methods are used to get all permissions on a topic or namespace, so don't need to pass the role and auth data.
...roker-common/src/main/java/org/apache/pulsar/broker/authorization/AuthorizationProvider.java
Outdated
Show resolved
Hide resolved
...roker-common/src/main/java/org/apache/pulsar/broker/authorization/AuthorizationProvider.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
Show resolved
Hide resolved
...er/src/test/java/org/apache/pulsar/broker/transaction/buffer/TransactionBufferCloseTest.java
Outdated
Show resolved
Hide resolved
...roker-common/src/main/java/org/apache/pulsar/broker/authorization/AuthorizationProvider.java
Show resolved
Hide resolved
...common/src/main/java/org/apache/pulsar/broker/authorization/PulsarAuthorizationProvider.java
Show resolved
Hide resolved
...common/src/main/java/org/apache/pulsar/broker/authorization/PulsarAuthorizationProvider.java
Show resolved
Hide resolved
...common/src/main/java/org/apache/pulsar/broker/authorization/PulsarAuthorizationProvider.java
Show resolved
Hide resolved
…rovider ### Motivation apache#20496 introduced a breaking change that if the custom authz provider does not implement the `removePermissionsAsync` method, the built-in admin will fail to delete a topic. It's because `BrokerService#deleteTopicAuthenticationWithRetry` calls `authorizationService.removePermissionsAsync`. ### Modifications To make it backward compatible, return a normal completed future in `removePermissionsAsync`. Verify the change by deleting a topic in `AuthorizationWithAuthDataTest#testAdmin`.
Motivation
This is a follow-up improvement for AuthorizationProvider. As discussed in the #20478-comment, we need more methods to avoid admin handling permissions directly.
Modification
removePermissionsAsync
: when deleting partitioned topics, we need to delete the authentication data.getPermissionsAsync
: we have topic level API to get all the permissions. so we need this.getSubscriptionPermissionsAsync
: we have topic level API to get all subscription permissions.getPermissionsAsync
: we have namespace level API to get all the permissions.Documentation
doc
doc-required
doc-not-needed
doc-complete