Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(topicdata): rename cluster param to fix data copy authorization check #2016

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/main/java/org/akhq/controllers/TopicController.java
Original file line number Diff line number Diff line change
Expand Up @@ -605,27 +605,27 @@ public List<RecordRepository.TimeOffset> 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<OffsetCopy> 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");
}
Expand All @@ -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(),
Expand Down
Loading