d8tltanc commented on a change in pull request #9485:
URL: https://github.com/apache/kafka/pull/9485#discussion_r529089666



##########
File path: core/src/main/scala/kafka/security/authorizer/AclAuthorizer.scala
##########
@@ -307,6 +312,111 @@ class AclAuthorizer extends Authorizer with Logging {
     if (zkClient != null) zkClient.close()
   }
 
+  // TODO: 1. Discuss how to log audit message
+  // TODO: 2. Discuss if we need a trie to optimize(mainly for the O(n^2) loop 
but I think
+  //  in most of the cases it would be O(1) because denyDominatePrefixAllow 
should be rare
+  override def authorizeByResourceType(requestContext: 
AuthorizableRequestContext,
+                                       op: AclOperation,
+                                       resourceType: ResourceType): 
AuthorizationResult = {
+    if (resourceType eq ResourceType.ANY)
+      throw new IllegalArgumentException("Must specify a non-filter resource 
type for authorizeByResourceType")
+
+    if (resourceType eq ResourceType.UNKNOWN)
+      throw new IllegalArgumentException("Unknown resource type")
+
+    if (op eq AclOperation.ANY)
+      throw new IllegalArgumentException("Must specify a non-filter operation 
type for authorizeByResourceType")
+
+    if (op eq AclOperation.UNKNOWN)
+      throw new IllegalArgumentException("Unknown operation type")
+
+    val allowPatterns = matchingPatterns(
+      requestContext.principal().toString,
+      requestContext.clientAddress().getHostAddress,
+      op,
+      resourceType,
+      AclPermissionType.ALLOW
+    )
+
+    val denyPatterns = matchingPatterns(
+      requestContext.principal().toString,
+      requestContext.clientAddress().getHostAddress,
+      op,
+      resourceType,
+      AclPermissionType.DENY

Review comment:
       Good point. Deferred the collection generation until we need it. 
   
   commit 3906f978e62255ff266f081bf646a4b3c6b896ad 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to