adutra commented on code in PR #3734:
URL: https://github.com/apache/polaris/pull/3734#discussion_r3274300755


##########
runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java:
##########
@@ -808,6 +834,44 @@ private Set<PolarisStorageActions> authorizeLoadTable(
     return actionsRequested;
   }
 
+  private Set<PolarisStorageActions> authorizeRegisterTable(
+      TableIdentifier tableIdentifier,
+      EnumSet<AccessDelegationMode> delegationModes,
+      boolean overwrite) {
+
+    if (delegationModes.isEmpty()) {
+      PolarisAuthorizableOperation op =
+          overwrite
+              ? PolarisAuthorizableOperation.REGISTER_TABLE_OVERWRITE
+              : PolarisAuthorizableOperation.REGISTER_TABLE;
+      authorizeCreateTableLikeUnderNamespaceOperationOrThrow(op, 
tableIdentifier);
+      return Set.of();
+    }
+
+    PolarisAuthorizableOperation readOp =
+        overwrite
+            ? 
PolarisAuthorizableOperation.REGISTER_TABLE_OVERWRITE_WITH_READ_DELEGATION
+            : PolarisAuthorizableOperation.REGISTER_TABLE_WITH_READ_DELEGATION;
+    PolarisAuthorizableOperation writeOp =
+        overwrite
+            ? 
PolarisAuthorizableOperation.REGISTER_TABLE_OVERWRITE_WITH_WRITE_DELEGATION
+            : 
PolarisAuthorizableOperation.REGISTER_TABLE_WITH_WRITE_DELEGATION;
+
+    Set<PolarisStorageActions> actionsRequested =
+        EnumSet.of(PolarisStorageActions.READ, PolarisStorageActions.LIST);
+
+    try {
+      authorizeCreateTableLikeUnderNamespaceOperationOrThrow(writeOp, 
tableIdentifier);
+      actionsRequested.add(PolarisStorageActions.WRITE);
+    } catch (ForbiddenException e) {
+      authorizeCreateTableLikeUnderNamespaceOperationOrThrow(readOp, 
tableIdentifier);
+    }
+
+    checkAllowExternalCatalogCredentialVending(delegationModes);

Review Comment:
   Yes, for non-overwrite scenarios only.



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