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


##########
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 don't think we want to modify the `canProduceAsync` method. I think we 
should migrate the calling code to use `allowTopicOperationAsync` since that 
internally calls `validateTenantAdminAccess` then calls `canProduceAsync`.



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