From 7e5a54f65569fab41db4196a538db56b815710e7 Mon Sep 17 00:00:00 2001 From: Alexis SOUQUIERE Date: Fri, 24 Jan 2025 23:44:58 +0100 Subject: [PATCH] fix(topic): fix topic data copy authorization check (#2016) --- .../java/org/akhq/controllers/TopicController.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/akhq/controllers/TopicController.java b/src/main/java/org/akhq/controllers/TopicController.java index 35ac0d7ac..5ae17965d 100644 --- a/src/main/java/org/akhq/controllers/TopicController.java +++ b/src/main/java/org/akhq/controllers/TopicController.java @@ -608,27 +608,27 @@ public List offsetsStart(String cluster, String top @AKHQSecured(resource = Role.Resource.TOPIC_DATA, action = Role.Action.CREATE) - @Post("api/{fromCluster}/topic/{fromTopicName}/copy/{toCluster}/topic/{toTopicName}") + @Post("api/{cluster}/topic/{fromTopicName}/copy/{toCluster}/topic/{toTopicName}") @Operation(tags = {"topic data"}, summary = "Copy from a topic to another topic") public RecordRepository.CopyResult copy( HttpRequest request, - String fromCluster, + String cluster, String fromTopicName, String toCluster, String toTopicName, @Body List offsets ) throws ExecutionException, InterruptedException { - checkIfClusterAndResourceAllowed(fromCluster, fromTopicName); + checkIfClusterAndResourceAllowed(cluster, fromTopicName); checkIfClusterAndResourceAllowed(toCluster, toTopicName); - Topic fromTopic = this.topicRepository.findByName(fromCluster, fromTopicName); + Topic fromTopic = this.topicRepository.findByName(cluster, fromTopicName); Topic toTopic = this.topicRepository.findByName(toCluster, toTopicName); if (!CollectionUtils.isNotEmpty(offsets)) { throw new IllegalArgumentException("Empty collections"); } - if (fromCluster.equals(toCluster) && fromTopicName.equals(toTopicName)) { + if (cluster.equals(toCluster) && fromTopicName.equals(toTopicName)) { // #745 Prevent endless loop when copying topic onto itself; Use intermediate copy topic for duplication throw new IllegalArgumentException("Can not copy topic to itself"); } @@ -641,7 +641,7 @@ public RecordRepository.CopyResult copy( .collect(Collectors.joining("_")); RecordRepository.Options options = dataSearchOptions( - fromCluster, + cluster, fromTopicName, Optional.ofNullable(StringUtils.isNotEmpty(offsetsList) ? offsetsList : null), Optional.empty(),