@@ -551,7 +551,8 @@ public LoadTableResponse createTableDirect(Namespace namespace, CreateTableReque
551551
552552 public LoadTableResponse createTableDirectWithWriteDelegation (
553553 Namespace namespace , CreateTableRequest request ) {
554- PolarisAuthorizableOperation op = PolarisAuthorizableOperation .CREATE_TABLE_DIRECT ;
554+ PolarisAuthorizableOperation op =
555+ PolarisAuthorizableOperation .CREATE_TABLE_DIRECT_WITH_WRITE_DELEGATION ;
555556 authorizeCreateTableLikeUnderNamespaceOperationOrThrow (
556557 op , TableIdentifier .of (namespace , request .name ()));
557558
@@ -591,20 +592,18 @@ public LoadTableResponse createTableDirectWithWriteDelegation(
591592 LoadTableResponse .Builder responseBuilder =
592593 LoadTableResponse .builder ().withTableMetadata (tableMetadata );
593594 if (baseCatalog instanceof SupportsCredentialDelegation credentialDelegation ) {
594- try {
595- Set <PolarisStorageActions > actionsRequested =
596- getValidTableActionsOrThrow (tableIdentifier );
597-
598- LOG .atDebug ()
599- .addKeyValue ("tableIdentifier" , tableIdentifier )
600- .addKeyValue ("tableLocation" , tableMetadata .location ())
601- .log ("Fetching client credentials for table" );
602- responseBuilder .addAllConfig (
603- credentialDelegation .getCredentialConfig (
604- tableIdentifier , tableMetadata , actionsRequested ));
605- } catch (ForbiddenException | NoSuchTableException e ) {
606- // No privileges available
607- }
595+ LOG .atDebug ()
596+ .addKeyValue ("tableIdentifier" , tableIdentifier )
597+ .addKeyValue ("tableLocation" , tableMetadata .location ())
598+ .log ("Fetching client credentials for table" );
599+ responseBuilder .addAllConfig (
600+ credentialDelegation .getCredentialConfig (
601+ tableIdentifier ,
602+ tableMetadata ,
603+ Set .of (
604+ PolarisStorageActions .READ ,
605+ PolarisStorageActions .WRITE ,
606+ PolarisStorageActions .LIST )));
608607 }
609608 return responseBuilder .build ();
610609 } else if (table instanceof BaseMetadataTable ) {
@@ -706,18 +705,13 @@ public LoadTableResponse createTableStagedWithWriteDelegation(
706705 LoadTableResponse .builder ().withTableMetadata (metadata );
707706
708707 if (baseCatalog instanceof SupportsCredentialDelegation credentialDelegation ) {
709- try {
710- Set <PolarisStorageActions > actionsRequested = getValidTableActionsOrThrow (ident );
711-
712- LOG .atDebug ()
713- .addKeyValue ("tableIdentifier" , ident )
714- .addKeyValue ("tableLocation" , metadata .location ())
715- .log ("Fetching client credentials for table" );
716- responseBuilder .addAllConfig (
717- credentialDelegation .getCredentialConfig (ident , metadata , actionsRequested ));
718- } catch (ForbiddenException | NoSuchTableException e ) {
719- // No privileges available
720- }
708+ LOG .atDebug ()
709+ .addKeyValue ("tableIdentifier" , ident )
710+ .addKeyValue ("tableLocation" , metadata .location ())
711+ .log ("Fetching client credentials for table" );
712+ responseBuilder .addAllConfig (
713+ credentialDelegation .getCredentialConfig (
714+ ident , metadata , Set .of (PolarisStorageActions .ALL )));
721715 }
722716 return responseBuilder .build ();
723717 });
@@ -779,39 +773,31 @@ public LoadTableResponse loadTable(TableIdentifier tableIdentifier, String snaps
779773 return doCatalogOperation (() -> CatalogHandlers .loadTable (baseCatalog , tableIdentifier ));
780774 }
781775
782- private Set <PolarisStorageActions > getValidTableActionsOrThrow (TableIdentifier tableIdentifier ) {
776+ public LoadTableResponse loadTableWithAccessDelegation (
777+ TableIdentifier tableIdentifier , String xIcebergAccessDelegation , String snapshots ) {
778+ // Here we have a single method that falls through multiple candidate
779+ // PolarisAuthorizableOperations because instead of identifying the desired operation up-front
780+ // and
781+ // failing the authz check if grants aren't found, we find the first most-privileged authz match
782+ // and respond according to that.
783783 PolarisAuthorizableOperation read =
784784 PolarisAuthorizableOperation .LOAD_TABLE_WITH_READ_DELEGATION ;
785785 PolarisAuthorizableOperation write =
786786 PolarisAuthorizableOperation .LOAD_TABLE_WITH_WRITE_DELEGATION ;
787+
787788 Set <PolarisStorageActions > actionsRequested =
788789 new HashSet <>(Set .of (PolarisStorageActions .READ , PolarisStorageActions .LIST ));
789790 try {
790791 // TODO: Refactor to have a boolean-return version of the helpers so we can fallthrough
791792 // easily.
792793 authorizeBasicTableLikeOperationOrThrow (write , PolarisEntitySubType .TABLE , tableIdentifier );
793794 actionsRequested .add (PolarisStorageActions .WRITE );
794- } catch (ForbiddenException | NoSuchTableException e ) {
795- LOG .atDebug ()
796- .addKeyValue ("tableIdentifier" , tableIdentifier )
797- .log ("Authz failed for LOAD_TABLE_WITH_WRITE_DELEGATION so attempting READ only" );
795+ } catch (ForbiddenException e ) {
798796 authorizeBasicTableLikeOperationOrThrow (read , PolarisEntitySubType .TABLE , tableIdentifier );
799797 }
800- return actionsRequested ;
801- }
802-
803- public LoadTableResponse loadTableWithAccessDelegation (
804- TableIdentifier tableIdentifier , String xIcebergAccessDelegation , String snapshots ) {
805- // Here we have a single method that falls through multiple candidate
806- // PolarisAuthorizableOperations because instead of identifying the desired operation up-front
807- // and
808- // failing the authz check if grants aren't found, we find the first most-privileged authz match
809- // and respond according to that.
810798
811799 // TODO: Find a way for the configuration or caller to better express whether to fail or omit
812800 // when data-access is specified but access delegation grants are not found.
813- Set <PolarisStorageActions > actionsRequested = getValidTableActionsOrThrow (tableIdentifier );
814-
815801 return doCatalogOperation (
816802 () -> {
817803 Table table = baseCatalog .loadTable (tableIdentifier );
0 commit comments