Skip to content

Commit

Permalink
BE: ACL: Consumers preset now include DESCRIBE permission for CG (#593)
Browse files Browse the repository at this point in the history
Co-authored-by: Poleg Kashti <poleg@DESKTOP-BSN03E3>
Co-authored-by: Roman Zabaluev <gpg@haarolean.dev>
  • Loading branch information
3 people authored Oct 18, 2024
1 parent 7be3325 commit c8a8759
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
4 changes: 2 additions & 2 deletions api/src/main/java/io/kafbat/ui/service/acl/AclsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public Mono<Void> createConsumerAcl(KafkaCluster cluster, CreateConsumerAclDTO r
.then();
}

//Read, Describe on topics, Read on consumerGroups
//Read, Describe on topics and consumerGroups
private List<AclBinding> createConsumerBindings(CreateConsumerAclDTO request) {
List<AclBinding> bindings = new ArrayList<>();
bindings.addAll(
Expand All @@ -172,7 +172,7 @@ private List<AclBinding> createConsumerBindings(CreateConsumerAclDTO request) {
bindings.addAll(
createAllowBindings(
GROUP,
List.of(READ),
List.of(READ, DESCRIBE),
request.getPrincipal(),
request.getHost(),
request.getConsumerGroupsPrefix(),
Expand Down
21 changes: 15 additions & 6 deletions api/src/test/java/io/kafbat/ui/service/acl/AclsServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ void createsConsumerDependantAcls() {
.topics(List.of("t1", "t2"))
).block();

//Read, Describe on topics, Read on consumerGroups
//Read, Describe on topics and consumerGroups
Collection<AclBinding> createdBindings = createdCaptor.getValue();
assertThat(createdBindings)
.hasSize(6)
.hasSize(8)
.contains(new AclBinding(
new ResourcePattern(ResourceType.TOPIC, "t1", PatternType.LITERAL),
new AccessControlEntry(principal, host, AclOperation.READ, AclPermissionType.ALLOW)))
Expand All @@ -122,9 +122,15 @@ void createsConsumerDependantAcls() {
.contains(new AclBinding(
new ResourcePattern(ResourceType.GROUP, "cg1", PatternType.LITERAL),
new AccessControlEntry(principal, host, AclOperation.READ, AclPermissionType.ALLOW)))
.contains(new AclBinding(
new ResourcePattern(ResourceType.GROUP, "cg1", PatternType.LITERAL),
new AccessControlEntry(principal, host, AclOperation.DESCRIBE, AclPermissionType.ALLOW)))
.contains(new AclBinding(
new ResourcePattern(ResourceType.GROUP, "cg2", PatternType.LITERAL),
new AccessControlEntry(principal, host, AclOperation.READ, AclPermissionType.ALLOW)))
.contains(new AclBinding(
new ResourcePattern(ResourceType.GROUP, "cg2", PatternType.LITERAL),
new AccessControlEntry(principal, host, AclOperation.READ, AclPermissionType.ALLOW)));
new AccessControlEntry(principal, host, AclOperation.DESCRIBE, AclPermissionType.ALLOW)));
}

@Test
Expand All @@ -145,10 +151,10 @@ void createsConsumerDependantAclsWhenTopicsAndGroupsSpecifiedByPrefix() {
.topicsPrefix("topicPref")
).block();

//Read, Describe on topics, Read on consumerGroups
//Read, Describe on topics and consumerGroups
Collection<AclBinding> createdBindings = createdCaptor.getValue();
assertThat(createdBindings)
.hasSize(3)
.hasSize(4)
.contains(new AclBinding(
new ResourcePattern(ResourceType.TOPIC, "topicPref", PatternType.PREFIXED),
new AccessControlEntry(principal, host, AclOperation.READ, AclPermissionType.ALLOW)))
Expand All @@ -157,7 +163,10 @@ void createsConsumerDependantAclsWhenTopicsAndGroupsSpecifiedByPrefix() {
new AccessControlEntry(principal, host, AclOperation.DESCRIBE, AclPermissionType.ALLOW)))
.contains(new AclBinding(
new ResourcePattern(ResourceType.GROUP, "cgPref", PatternType.PREFIXED),
new AccessControlEntry(principal, host, AclOperation.READ, AclPermissionType.ALLOW)));
new AccessControlEntry(principal, host, AclOperation.READ, AclPermissionType.ALLOW)))
.contains(new AclBinding(
new ResourcePattern(ResourceType.GROUP, "cgPref", PatternType.PREFIXED),
new AccessControlEntry(principal, host, AclOperation.DESCRIBE, AclPermissionType.ALLOW)));
}

@Test
Expand Down

0 comments on commit c8a8759

Please sign in to comment.