Skip to content

Commit

Permalink
fix confluent user ids
Browse files Browse the repository at this point in the history
  • Loading branch information
adriencalime committed Oct 12, 2023
1 parent 93fbb8b commit a60e673
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.admin.Admin;
import org.apache.kafka.common.acl.AccessControlEntryFilter;
import org.apache.kafka.common.acl.AclBinding;
import org.apache.kafka.common.acl.AclBindingFilter;
import org.apache.kafka.common.acl.AclOperation;
import org.apache.kafka.common.acl.AclPermissionType;
import org.apache.kafka.common.resource.PatternType;
import org.apache.kafka.common.resource.ResourcePattern;
import org.apache.kafka.common.resource.ResourcePatternFilter;
import org.apache.kafka.common.resource.ResourceType;

/**
Expand Down Expand Up @@ -179,8 +181,14 @@ private List<AclBinding> collectBrokerAcls(boolean managedUsersOnly)
List<ResourceType> validResourceTypes =
List.of(ResourceType.TOPIC, ResourceType.GROUP, ResourceType.TRANSACTIONAL_ID);

AccessControlEntryFilter accessControlEntryFilter = new AccessControlEntryFilter(
managedClusterProperties.getProvider()
.equals(ManagedClusterProperties.KafkaProvider.CONFLUENT_CLOUD) ? "UserV2:*" : null,
null, AclOperation.ANY, AclPermissionType.ANY);
AclBindingFilter aclBindingFilter = new AclBindingFilter(ResourcePatternFilter.ANY, accessControlEntryFilter);

List<AclBinding> userAcls = getAdminClient()
.describeAcls(AclBindingFilter.ANY)
.describeAcls(aclBindingFilter)
.values().get(10, TimeUnit.SECONDS)
.stream()
.filter(aclBinding -> validResourceTypes.contains(aclBinding.pattern().resourceType()))
Expand Down

0 comments on commit a60e673

Please sign in to comment.