From 54894fb361bdafa6cc1ae83a28b77a940e62359e Mon Sep 17 00:00:00 2001 From: AlexisSouquiere Date: Fri, 6 Dec 2024 16:08:13 +0100 Subject: [PATCH] Fix topic data copy authorization check --- .../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 dd6a88db2..0e0723b32 100644 --- a/src/main/java/org/akhq/controllers/TopicController.java +++ b/src/main/java/org/akhq/controllers/TopicController.java @@ -605,27 +605,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"); } @@ -638,7 +638,7 @@ public RecordRepository.CopyResult copy( .collect(Collectors.joining("_")); RecordRepository.Options options = dataSearchOptions( - fromCluster, + cluster, fromTopicName, Optional.ofNullable(StringUtils.isNotEmpty(offsetsList) ? offsetsList : null), Optional.empty(),