1818 */
1919package org .apache .polaris .service .catalog .iceberg ;
2020
21- import static org .apache .polaris .core .config .FeatureConfiguration .ALLOW_EXTERNAL_CATALOG_CREDENTIAL_VENDING ;
21+ import static org .apache .polaris .core .config .FeatureConfiguration .ALLOW_FEDERATED_CATALOGS_CREDENTIAL_VENDING ;
2222import static org .apache .polaris .core .config .FeatureConfiguration .LIST_PAGINATION_ENABLED ;
2323import static org .apache .polaris .service .catalog .AccessDelegationMode .VENDED_CREDENTIALS ;
2424
@@ -426,6 +426,12 @@ public void authorizeCreateTableDirect(
426426 PolarisAuthorizableOperation .CREATE_TABLE_DIRECT_WITH_WRITE_DELEGATION ,
427427 TableIdentifier .of (namespace , request .name ()));
428428 }
429+
430+ CatalogEntity catalog = getResolvedCatalogEntity ();
431+ if (catalog .isStaticFacade ()) {
432+ throw new BadRequestException ("Cannot create table on static-facade external catalogs." );
433+ }
434+ checkAllowExternalCatalogCredentialVending (delegationModes );
429435 }
430436
431437 public LoadTableResponse createTableDirect (
@@ -436,10 +442,6 @@ public LoadTableResponse createTableDirect(
436442
437443 authorizeCreateTableDirect (namespace , request , delegationModes );
438444
439- CatalogEntity catalog = getResolvedCatalogEntity ();
440- if (catalog .isStaticFacade ()) {
441- throw new BadRequestException ("Cannot create table on static-facade external catalogs." );
442- }
443445 request .validate ();
444446
445447 TableIdentifier tableIdentifier = TableIdentifier .of (namespace , request .name ());
@@ -550,6 +552,12 @@ private void authorizeCreateTableStaged(
550552 PolarisAuthorizableOperation .CREATE_TABLE_STAGED_WITH_WRITE_DELEGATION ,
551553 TableIdentifier .of (namespace , request .name ()));
552554 }
555+
556+ CatalogEntity catalog = getResolvedCatalogEntity ();
557+ if (catalog .isStaticFacade ()) {
558+ throw new BadRequestException ("Cannot create table on static-facade external catalogs." );
559+ }
560+ checkAllowExternalCatalogCredentialVending (delegationModes );
553561 }
554562
555563 public LoadTableResponse createTableStaged (
@@ -560,10 +568,6 @@ public LoadTableResponse createTableStaged(
560568
561569 authorizeCreateTableStaged (namespace , request , delegationModes );
562570
563- CatalogEntity catalog = getResolvedCatalogEntity ();
564- if (catalog .isStaticFacade ()) {
565- throw new BadRequestException ("Cannot create table on static-facade external catalogs." );
566- }
567571 TableIdentifier ident = TableIdentifier .of (namespace , request .name ());
568572 TableMetadata metadata = stageTableCreateHelper (namespace , request );
569573
@@ -728,23 +732,7 @@ private Set<PolarisStorageActions> authorizeLoadTable(
728732 read , PolarisEntitySubType .ICEBERG_TABLE , tableIdentifier );
729733 }
730734
731- CatalogEntity catalogEntity = getResolvedCatalogEntity ();
732-
733- LOGGER .info ("Catalog type: {}" , catalogEntity .getCatalogType ());
734- LOGGER .info (
735- "allow external catalog credential vending: {}" ,
736- realmConfig .getConfig (
737- FeatureConfiguration .ALLOW_EXTERNAL_CATALOG_CREDENTIAL_VENDING , catalogEntity ));
738- if (catalogEntity
739- .getCatalogType ()
740- .equals (org .apache .polaris .core .admin .model .Catalog .TypeEnum .EXTERNAL )
741- && !realmConfig .getConfig (
742- FeatureConfiguration .ALLOW_EXTERNAL_CATALOG_CREDENTIAL_VENDING , catalogEntity )) {
743- throw new ForbiddenException (
744- "Access Delegation is not enabled for this catalog. Please consult applicable "
745- + "documentation for the catalog config property '%s' to enable this feature" ,
746- FeatureConfiguration .ALLOW_EXTERNAL_CATALOG_CREDENTIAL_VENDING .catalogConfig ());
747- }
735+ checkAllowExternalCatalogCredentialVending (delegationModes );
748736
749737 return actionsRequested ;
750738 }
@@ -814,13 +802,14 @@ private LoadTableResponse.Builder buildLoadTableResponseWithDelegationCredential
814802 CatalogUtils .findResolvedStorageEntity (resolutionManifest , tableIdentifier );
815803
816804 if (resolvedStoragePath == null ) {
817- LOGGER .debug ("Unable to find storage configuration information for table {}" , tableIdentifier );
805+ LOGGER .debug (
806+ "Unable to find storage configuration information for table {}" , tableIdentifier );
818807 return responseBuilder ;
819808 }
820809
821810 if (baseCatalog instanceof IcebergCatalog
822811 || realmConfig .getConfig (
823- ALLOW_EXTERNAL_CATALOG_CREDENTIAL_VENDING , getResolvedCatalogEntity ())) {
812+ ALLOW_FEDERATED_CATALOGS_CREDENTIAL_VENDING , getResolvedCatalogEntity ())) {
824813 AccessConfig accessConfig =
825814 accessConfigProvider .getAccessConfig (
826815 callContext ,
@@ -1223,6 +1212,31 @@ private EnumSet<PolarisAuthorizableOperation> getUpdateTableAuthorizableOperatio
12231212 }
12241213 }
12251214
1215+ private void checkAllowExternalCatalogCredentialVending (
1216+ EnumSet <AccessDelegationMode > delegationModes ) {
1217+
1218+ if (delegationModes .isEmpty ()) {
1219+ return ;
1220+ }
1221+ CatalogEntity catalogEntity = getResolvedCatalogEntity ();
1222+
1223+ LOGGER .info ("Catalog type: {}" , catalogEntity .getCatalogType ());
1224+ LOGGER .info (
1225+ "allow external catalog credential vending: {}" ,
1226+ realmConfig .getConfig (
1227+ FeatureConfiguration .ALLOW_EXTERNAL_CATALOG_CREDENTIAL_VENDING , catalogEntity ));
1228+ if (catalogEntity
1229+ .getCatalogType ()
1230+ .equals (org .apache .polaris .core .admin .model .Catalog .TypeEnum .EXTERNAL )
1231+ && !realmConfig .getConfig (
1232+ FeatureConfiguration .ALLOW_EXTERNAL_CATALOG_CREDENTIAL_VENDING , catalogEntity )) {
1233+ throw new ForbiddenException (
1234+ "Access Delegation is not enabled for this catalog. Please consult applicable "
1235+ + "documentation for the catalog config property '%s' to enable this feature" ,
1236+ FeatureConfiguration .ALLOW_EXTERNAL_CATALOG_CREDENTIAL_VENDING .catalogConfig ());
1237+ }
1238+ }
1239+
12261240 @ Override
12271241 public void close () throws Exception {
12281242 if (baseCatalog instanceof Closeable closeable ) {
0 commit comments