-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[Authorization] Optimize the logic of allowing namespace operation #13090
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
[Authorization] Optimize the logic of allowing namespace operation #13090
Conversation
pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/NamespaceOperation.java
Show resolved
Hide resolved
nicoloboschi
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.
LGTM
...common/src/main/java/org/apache/pulsar/broker/authorization/PulsarAuthorizationProvider.java
Outdated
Show resolved
Hide resolved
eolivelli
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.
I left one last comment, then I am +1
@michaeljmarshall can you please take a look ?
...common/src/main/java/org/apache/pulsar/broker/authorization/PulsarAuthorizationProvider.java
Outdated
Show resolved
Hide resolved
michaeljmarshall
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.
Currently, pulsar supports 12
NamespaceOperation, so there should not be more than 12 in methodPulsarAuthorizationProvider#allowNamespaceOperationAsync
Otherwise, the undefinedNamespaceOperationcan also be passed by super-user or role with admin privileges.
@yuruguo - can you explain the risk more? The NamespaceOperation is a serverside abstraction. I think might be missing something.
pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/NamespaceOperation.java
Show resolved
Hide resolved
...roker-common/src/main/java/org/apache/pulsar/broker/authorization/AuthorizationProvider.java
Outdated
Show resolved
Hide resolved
michaeljmarshall
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.
@yuruguo - unfortunately, my PR #13133 created merge conflicts for this PR, so you'll need to rebase.
Based on looking at this PR and at #6428, I think there are a few opportunities for cleanup, but I need to look at the API a little more before I have a fully formed opinion. For example, I think we might be able to add the @Deprecated annotation for several enum fields. Here are the ones that I am tentatively considering: NamespaceOperation.GET_TOPIC, NamespaceOperation.ADD_BUNDLE, TopicOperation.ADD_BUNDLE_RANGE, TopicOperation.GET_BUNDLE_RANGE, and TopicOperation.DELETE_BUNDLE_RANGE. These seem unnecessary, but I might be missing something. It'd probably be worth an email to the dev mailing list before we officially deprecate these fields.
I also see that we have these unused fields: TopicOperation.GRANT_PERMISSION, TopicOperation.GET_PERMISSION, and TopicOperation.REVOKE_PERMISSION. Perhaps they should be used, though, if we want to support topic level granularity for permissions. The current implementation does not rely on these 3 fields because the PersistentTopicsBase#internalGrantPermissionsOnTopic implements logic that I think should reside in an AuthorizationProvider.
Nice! pulsar/pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/TenantOperation.java Lines 22 to 29 in 50ab411
|
eolivelli
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.
+1
|
@yuruguo Please note that authZ is pluggable. Even if the default AuthorizationProvider does not use these operations, it exists plugins that are not role-based but token-based and they need the operations information to authorize. IMO, you should not deprecate the Operations which are not used in default AuthorizationProvider. |
@KannarFr - I agree that we shouldn't just deprecate fields because they are not used by the |
michaeljmarshall
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.
LGTM
|
Add the |
Motivation
Currently, pulsar supports 13
NamespaceOperation, so there should not be more than 13 in methodPulsarAuthorizationProvider#allowNamespaceOperationAsync. Otherwise, the undefinedNamespaceOperationcan also be passed by super-user or role with admin privileges.pulsar/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authorization/PulsarAuthorizationProvider.java
Lines 525 to 550 in 7adfffd
The purpose of this PR is to optimize the logic of
PulsarAuthorizationProvider#allowNamespaceOperationAsyncso that it only covers theNamespaceOperationsupported by pulsar.Documentation
no-need-doc