dragonls commented on code in PR #20068:
URL: https://github.com/apache/pulsar/pull/20068#discussion_r1165539818
##########
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authorization/PulsarAuthorizationProvider.java:
##########
@@ -84,7 +84,18 @@ public void initialize(ServiceConfiguration conf,
PulsarResources pulsarResource
@Override
public CompletableFuture<Boolean> canProduceAsync(TopicName topicName,
String role,
AuthenticationDataSource authenticationData) {
- return checkAuthorization(topicName, role, AuthAction.produce);
+ return validateTenantAdminAccess(topicName.getTenant(), role,
authenticationData)
+ .thenCompose(isSuperUserOrAdmin -> {
+ if (log.isDebugEnabled()) {
+ log.debug("Verify if role {} is allowed to produce
topic {}: isSuperUserOrAdmin={}",
+ role, topicName, isSuperUserOrAdmin);
+ }
+ if (isSuperUserOrAdmin) {
+ return CompletableFuture.completedFuture(true);
+ } else {
+ return checkAuthorization(topicName, role,
AuthAction.produce);
+ }
+ });
Review Comment:
>
I think you are saying migrate from
`org.apache.pulsar.broker.authorization.AuthorizationProvider#canProduceAsync`
to
`org.apache.pulsar.broker.authorization.AuthorizationProvider#allowTopicOperationAsync`
in
`org.apache.pulsar.broker.authorization.AuthorizationService#canProduceAsync`.
If do so, this bug is indeed fixed.
However, this still leave hidden dangers in
`org.apache.pulsar.broker.authorization.PulsarAuthorizationProvider`. The
execution effect of
`org.apache.pulsar.broker.authorization.PulsarAuthorizationProvider#allowTopicOperationAsync`
and
`org.apache.pulsar.broker.authorization.PulsarAuthorizationProvider#canProduceAsync`
is still not consistent, because the latter do not check tenant admin
permission.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]