xiangfu0 commented on code in PR #20456:
URL: https://github.com/apache/pinot/pull/20456#discussion_r4795202254


##########
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/MultiStageBrokerRequestHandler.java:
##########
@@ -528,12 +533,23 @@ private QueryEnvironment.CompiledQuery compileQuery(long 
requestId, String query
     }
   }
 
-  private boolean checkAuthorization(RequesterIdentity requesterIdentity, 
RequestContext requestContext,
+  @VisibleForTesting
+  boolean checkAuthorization(RequesterIdentity requesterIdentity, 
RequestContext requestContext,
       HttpHeaders httpHeaders, QueryEnvironment.CompiledQuery compiledQuery) {
     Set<String> tables = compiledQuery.getTableNames();
     if (tables != null && !tables.isEmpty()) {
+      Set<String> tablesToAuthorize = new HashSet<>(tables);
+      for (String table : tables) {
+        String logicalTableName = _tableCache.getActualLogicalTableName(table);
+        if (logicalTableName != null) {
+          LogicalTableConfig config = 
_tableCache.getLogicalTableConfig(logicalTableName);
+          if (config != null) {
+            
tablesToAuthorize.addAll(config.getPhysicalTableConfigMap().keySet());

Review Comment:
   These keys carry the type suffix (`foo_OFFLINE`). The file-backed broker 
`BasicAuthAccessControlFactory` matches table names exactly, so a principal 
that was granted the raw name `foo` now gets 403 on a multi-stage query against 
the logical table, while the ZK-backed variant strips the suffix. Should the 
raw names be authorized instead, or as well? Either way this changes behaviour 
for existing setups, so it deserves a label and an upgrade note.



##########
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/MultiStageBrokerRequestHandler.java:
##########
@@ -528,12 +533,23 @@ private QueryEnvironment.CompiledQuery compileQuery(long 
requestId, String query
     }
   }
 
-  private boolean checkAuthorization(RequesterIdentity requesterIdentity, 
RequestContext requestContext,
+  @VisibleForTesting
+  boolean checkAuthorization(RequesterIdentity requesterIdentity, 
RequestContext requestContext,
       HttpHeaders httpHeaders, QueryEnvironment.CompiledQuery compiledQuery) {
     Set<String> tables = compiledQuery.getTableNames();
     if (tables != null && !tables.isEmpty()) {
+      Set<String> tablesToAuthorize = new HashSet<>(tables);
+      for (String table : tables) {
+        String logicalTableName = _tableCache.getActualLogicalTableName(table);
+        if (logicalTableName != null) {
+          LogicalTableConfig config = 
_tableCache.getLogicalTableConfig(logicalTableName);
+          if (config != null) {
+            
tablesToAuthorize.addAll(config.getPhysicalTableConfigMap().keySet());
+          }
+        }
+      }
       TableAuthorizationResult tableAuthorizationResult =
-          hasTableAccess(requesterIdentity, tables, requestContext, 
httpHeaders);
+          hasTableAccess(requesterIdentity, tablesToAuthorize, requestContext, 
httpHeaders);

Review Comment:
   `applyRlsFilters` a few lines down (line 556) still receives the logical 
names only. Should it get the backing tables' names as well, to match the 
authorization above?



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