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



##########
File path: core/src/main/scala/kafka/security/authorizer/AuthorizerWrapper.scala
##########
@@ -175,4 +181,32 @@ class AuthorizerWrapper(private[kafka] val baseAuthorizer: 
kafka.security.auth.A
   override def close(): Unit = {
     baseAuthorizer.close()
   }
+
+  override def authorizeByResourceType(requestContext: 
AuthorizableRequestContext,
+                                       op: AclOperation,
+                                       resourceType: ResourceType): 
AuthorizationResult = {
+    SecurityUtils.authorizeByResourceTypeCheckArgs(op, resourceType)
+
+    if (denyAllResource(requestContext, op, resourceType)) {
+      AuthorizationResult.DENIED
+    } else if (shouldAllowEveryoneIfNoAclIsFound) {
+      AuthorizationResult.ALLOWED
+    } else {
+      super.authorizeByResourceType(requestContext, op, resourceType)
+    }
+  }
+
+  private def denyAllResource(requestContext: AuthorizableRequestContext,
+                      op: AclOperation,
+                      resourceType: ResourceType): Boolean = {

Review comment:
       commit 8263bd3 changed the AuthorizerWrapper logic and optimized the 
performance a bit.
   
   Now AuthorizerWrapper#denyAllResource will 
   1. only use Authorizer#acls() to filter out the `WildcardResource` with the 
pattern type `LITERAL`. 
   2. check if any of the filtered out bindings match the `request principle` 
and `request host`. 
   
   So it's behavior diverges more from the interface default now.




----------------------------------------------------------------
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