dimas-b commented on code in PR #2736:
URL: https://github.com/apache/polaris/pull/2736#discussion_r2395798854


##########
runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/SupportsCredentialDelegation.java:
##########
@@ -24,14 +24,22 @@
 import org.apache.iceberg.catalog.TableIdentifier;
 import org.apache.polaris.core.storage.AccessConfig;
 import org.apache.polaris.core.storage.PolarisStorageActions;
+import org.apache.polaris.service.catalog.io.AccessConfigProvider;
 
 /**
  * Adds support for credential vending for (typically) {@link 
org.apache.iceberg.TableOperations} to
  * fetch access credentials that are inserted into the {@link
  * org.apache.iceberg.rest.responses.LoadTableResponse#config()} property. See 
the
  * rest-catalog-open-api.yaml spec for details on the expected format of 
vended credential
  * configuration.
+ *
+ * @deprecated This interface tightly couples credential vending to catalog 
implementation via
+ *     inheritance, making it difficult to support credential vending for 
federated catalogs or
+ *     other non-Polaris catalog implementations. Use {@link 
AccessConfigProvider} instead, which
+ *     provides credential vending as a standalone factory that can work with 
any catalog
+ *     implementation. This interface will be removed in a future release.
  */
+@Deprecated
 public interface SupportsCredentialDelegation {
   AccessConfig getAccessConfig(

Review Comment:
   Same here: there are no callers in Apache Polaris code. Let's remove.



##########
runtime/service/src/main/java/org/apache/polaris/service/catalog/io/AccessConfigProvider.java:
##########
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.polaris.service.catalog.io;
+
+import jakarta.annotation.Nonnull;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+import java.util.Optional;
+import java.util.Set;
+import org.apache.iceberg.TableMetadata;
+import org.apache.iceberg.catalog.TableIdentifier;
+import org.apache.polaris.core.context.CallContext;
+import org.apache.polaris.core.entity.PolarisEntity;
+import org.apache.polaris.core.persistence.PolarisMetaStoreManager;
+import org.apache.polaris.core.persistence.PolarisResolvedPathWrapper;
+import org.apache.polaris.core.storage.AccessConfig;
+import org.apache.polaris.core.storage.PolarisStorageActions;
+import org.apache.polaris.core.storage.StorageUtil;
+import org.apache.polaris.core.storage.cache.StorageCredentialCache;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Provides temporary, scoped credentials for accessing table data in object 
storage (S3, GCS, Azure
+ * Blob Storage).
+ *
+ * <p>This provider decouples credential vending from catalog implementations, 
and should be the
+ * primary entrypoint to get sub-scoped credentials for accessing table data.
+ */
+@ApplicationScoped
+public class AccessConfigProvider {
+
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(AccessConfigProvider.class);
+  private final StorageCredentialCache storageCredentialCache;
+  private final PolarisMetaStoreManager metaStoreManager;
+
+  @Inject
+  public AccessConfigProvider(
+      StorageCredentialCache storageCredentialCache,
+      PolarisMetaStoreManager polarisMetaStoreManager) {
+    this.storageCredentialCache = storageCredentialCache;
+    this.metaStoreManager = polarisMetaStoreManager;
+  }
+
+  /**
+   * Vends credentials for accessing table storage, extracting locations from 
table metadata.
+   *
+   * @param callContext the call context containing realm, principal, and 
security context
+   * @param tableIdentifier the table identifier
+   * @param tableMetadata the table metadata containing storage location URIs
+   * @param storageActions the storage operations (READ, WRITE, LIST, DELETE) 
to scope credentials
+   *     to
+   * @param refreshCredentialsEndpoint optional endpoint URL for clients to 
refresh credentials
+   * @param resolvedPath the entity hierarchy to search for storage 
configuration
+   * @return {@link AccessConfig} with scoped credentials and metadata; empty 
if no storage config
+   *     found
+   */
+  public AccessConfig getAccessConfig(
+      @Nonnull CallContext callContext,
+      @Nonnull TableIdentifier tableIdentifier,
+      @Nonnull TableMetadata tableMetadata,
+      @Nonnull Set<PolarisStorageActions> storageActions,
+      @Nonnull Optional<String> refreshCredentialsEndpoint,
+      @Nonnull PolarisResolvedPathWrapper resolvedPath) {
+    return getAccessConfig(
+        callContext,
+        tableIdentifier,
+        StorageUtil.getLocationsUsedByTable(tableMetadata),
+        storageActions,
+        refreshCredentialsEndpoint,
+        resolvedPath);
+  }
+
+  /**
+   * Vends credentials for accessing table storage at explicit locations.
+   *
+   * @param callContext the call context containing realm, principal, and 
security context
+   * @param tableIdentifier the table identifier, used for logging and refresh 
endpoint construction
+   * @param tableLocations set of storage location URIs to scope credentials to
+   * @param storageActions the storage operations (READ, WRITE, LIST, DELETE) 
to scope credentials
+   *     to
+   * @param refreshCredentialsEndpoint optional endpoint URL for clients to 
refresh credentials
+   * @param resolvedPath the entity hierarchy to search for storage 
configuration
+   * @return {@link AccessConfig} with scoped credentials and metadata; empty 
if no storage config
+   *     found
+   */
+  public AccessConfig getAccessConfig(

Review Comment:
   Sweet 👍 



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