sarankk commented on code in PR #308:
URL: https://github.com/apache/cassandra-sidecar/pull/308#discussion_r2692095449


##########
server/src/main/java/org/apache/cassandra/sidecar/acl/authorization/CachedAuthorizationHandler.java:
##########
@@ -264,15 +266,27 @@ protected void 
checkOrFetchAuthorizations(Promise<Boolean> promise, Authorizatio
         promise.fail(new HttpException(FORBIDDEN.code()));
     }
 
-    protected boolean isAdmin(List<String> identities)
+    protected Future<Boolean> isAdmin(List<String> identities)
     {
+        if (identities.isEmpty())
+        {
+            return Future.succeededFuture(false);
+        }
+        List<Future<Boolean>> adminFutures = new 
ArrayList<>(identities.size());
         for (String identity : identities)
         {
-            if (adminIdentityResolver.isAdmin(identity))
-            {
-                return true;
-            }
+            adminFutures.add(adminIdentityResolver.isAdmin(identity));
         }
-        return false;
+        return Future.all(adminFutures)
+                     .map(cf -> {
+                         for (int i = 0; i < cf.size(); i++)
+                         {
+                             if (Boolean.TRUE.equals(cf.resultAt(i)))
+                             {
+                                 return true;
+                             }
+                         }
+                         return false;
+                     });

Review Comment:
   Yes thought about this too before. If we complete fast, the fastest future 
may not be always admin, we need to wait for all futures to check if any one 
has admin access. 



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to