dragonls commented on code in PR #20068:
URL: https://github.com/apache/pulsar/pull/20068#discussion_r1166214272


##########
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 might understand what @michaeljmarshall meant.
   
   We can make `canProduceAsync` and `canConsumeAsync` to call 
`allowTopicOperationAsync` instead. And `allowTopicOperationAsync` calls maybe 
`innerCanProduceAsync` and `innerCanConsumeAsync`, which do the same thing as 
the old `canProduceAsync` do.



-- 
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]

Reply via email to