[Authorization] Optimize the logic of allowing namespace operation - #13090
[Authorization] Optimize the logic of allowing namespace operation#13090eolivelli merged 1 commit into
Conversation
eolivelli
left a comment
There was a problem hiding this comment.
I left one last comment, then I am +1
@michaeljmarshall can you please take a look ?
michaeljmarshall
left a comment
There was a problem hiding this comment.
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.
michaeljmarshall
left a comment
There was a problem hiding this comment.
@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! |
|
@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 |
|
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