eolivelli commented on a change in pull request #12743:
URL: https://github.com/apache/pulsar/pull/12743#discussion_r747263854
##########
File path:
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authorization/PulsarAuthorizationProvider.java
##########
@@ -370,20 +370,24 @@ public void initialize(ServiceConfiguration conf,
PulsarResources pulsarResource
}
private CompletableFuture<Boolean> checkAuthorization(TopicName topicName,
String role, AuthAction action) {
- return checkPermission(topicName, role, action)
- .thenApply(isPermission -> isPermission &&
checkCluster(topicName));
+ return checkPermission(topicName, role, action).
+ thenApply(isPermission -> isPermission).
+ thenCompose(permission -> permission ? checkCluster(topicName)
:
+ CompletableFuture.completedFuture(false));
}
- private boolean checkCluster(TopicName topicName) {
+ private CompletableFuture<Boolean> checkCluster(TopicName topicName) {
if (topicName.isGlobal() ||
conf.getClusterName().equals(topicName.getCluster())) {
- return true;
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Topic [{}] does not belong to local cluster [{}]",
topicName.toString(),
- conf.getClusterName());
- }
- return false;
+ return CompletableFuture.completedFuture(true);
}
+ if (log.isDebugEnabled()) {
+ log.debug("Topic [{}] does not belong to local cluster [{}]",
topicName.toString(), conf.getClusterName());
+ }
+ return pulsarResources.getClusterResources().listAsync()
+ .thenApply(clusters -> {
+ log.info("clusters {}, cluster {}",clusters,
topicName.getCluster());
Review comment:
Will this be printed out maty times?
--
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]