You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/09/02 14:39:05 UTC

[GitHub] [pulsar] gaoran10 commented on a diff in pull request #17411: Check create topic permission on topic creation using pulsar proto clients

gaoran10 commented on code in PR #17411:
URL: https://github.com/apache/pulsar/pull/17411#discussion_r961752310


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java:
##########
@@ -1080,102 +1077,126 @@ protected void handleSubscribe(final CommandSubscribe subscribe) {
                 }
                 Optional<Map<String, String>> subscriptionProperties = SubscriptionOption.getPropertiesMap(
                         subscribe.getSubscriptionPropertiesList());
-                service.getTopic(topicName.toString(), createTopicIfDoesNotExist)
-                        .thenCompose(optTopic -> {
-                            if (!optTopic.isPresent()) {
-                                return FutureUtil
-                                        .failedFuture(new TopicNotFoundException(
-                                                "Topic " + topicName + " does not exist"));
-                            }
 
-                            Topic topic = optTopic.get();
+                CompletableFuture<Boolean> isAuthorizedToCreateTopicFuture = isNamespaceOperationAllowed(
+                        topicName.getNamespaceObject(),
+                        NamespaceOperation.CREATE_TOPIC

Review Comment:
   Maybe we can add this before [line 1026](https://github.com/apache/pulsar/pull/17411/files#diff-1e0e8195fb5ec5a6d79acbc7d859c025a9b711f94e6ab37c94439e99b3202e84L1026), and use this method `isAuthorizedFuture.thenCombine(isAuthorizedToCreateTopicFuture, (isAuthorized, isAuthorizedToCreateTopic)`.



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org