jerryshao commented on code in PR #14766:
URL: https://github.com/apache/gravitino/pull/14766#discussion_r4511343462


##########
iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/server/web/filter/IcebergLoadAuthzHandlerHelper.java:
##########
@@ -84,10 +88,25 @@ static LoadContext extractLoadContext(
     return new LoadContext(catalogId.namespace().level(0), catalogId.name(), 
schemaId.name());
   }
 
-  static IcebergCatalogWrapper getCatalogWrapper(String catalog) {
-    return IcebergRESTServerContext.getInstance()
-        .catalogWrapperManager()
-        .getCatalogWrapper(catalog);
+  static IcebergCatalogWrapper getCatalogWrapper(
+      String catalog, Map<EntityType, NameIdentifier> nameIdentifierMap) {
+    try {
+      return IcebergRESTServerContext.getInstance()
+          .catalogWrapperManager()
+          .getCatalogWrapper(catalog);
+    } catch (NoSuchCatalogException | IllegalArgumentException e) {
+      // A load handler resolves the backend before evaluating table/view 
privileges. Do not
+      // disclose catalog existence or its provider to a caller who cannot see 
the catalog.
+      if (!isAllowed(
+          nameIdentifierMap,
+          
AuthorizationExpressionConstants.LOAD_CATALOG_AUTHORIZATION_EXPRESSION)) {
+        throw new ForbiddenException("Not authorized to access catalog '%s'", 
catalog);
+      }
+      if (e instanceof NoSuchCatalogException) {
+        throw new NoSuchNamespaceException("No Iceberg configuration for 
catalog '%s'", catalog);

Review Comment:
   A missing catalog is returned as NoSuchNamespaceException, which is a bit 
misleading for view and table loads. Consider a message that names the catalog 
explicitly, or confirm clients expect this status.



##########
iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/IcebergCatalogWrapper.java:
##########
@@ -265,6 +266,16 @@ public void reloadHadoopConf() {
   public LoadTableResponse createTable(Namespace namespace, CreateTableRequest 
request) {
     request.validate();
     validateTableDefinition(request);
+    if (request.location() != null && 
S3FileIO.class.getName().equals(fileIOImpl())) {

Review Comment:
   The S3 location check only runs in createTable, so registerTable and 
location changes in updates can still use non-S3 locations. Consider moving it 
to a shared helper.



##########
iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/server/web/filter/IcebergMetadataAuthorizationMethodInterceptor.java:
##########
@@ -192,6 +205,11 @@ protected boolean isExceptionPropagate(Exception 
exception) {
     return 
exception.getClass().getName().startsWith("org.apache.iceberg.exceptions");
   }
 
+  @Override
+  protected boolean isAuthorizationDenial(Exception exception) {
+    return super.isAuthorizationDenial(exception) || exception instanceof 
ForbiddenException;

Review Comment:
   Any ForbiddenException is now treated as an authorization denial, including 
ones thrown by the backend (for example storage credential errors). Should 
these be audited as denials, or only the ones thrown by this filter?



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

Reply via email to