-
Notifications
You must be signed in to change notification settings - Fork 290
add refresh credentials property to loadTableResult #2341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ | |
import java.util.Set; | ||
import java.util.function.Function; | ||
import org.apache.iceberg.MetadataUpdate; | ||
import org.apache.iceberg.aws.AwsClientProperties; | ||
import org.apache.iceberg.catalog.Namespace; | ||
import org.apache.iceberg.catalog.TableIdentifier; | ||
import org.apache.iceberg.exceptions.BadRequestException; | ||
|
@@ -71,7 +72,9 @@ | |
import org.apache.polaris.core.persistence.resolver.ResolverFactory; | ||
import org.apache.polaris.core.persistence.resolver.ResolverStatus; | ||
import org.apache.polaris.core.rest.PolarisEndpoints; | ||
import org.apache.polaris.core.rest.PolarisResourcePaths; | ||
import org.apache.polaris.core.secrets.UserSecretsManager; | ||
import org.apache.polaris.core.storage.StorageAccessProperty; | ||
import org.apache.polaris.service.catalog.AccessDelegationMode; | ||
import org.apache.polaris.service.catalog.CatalogPrefixParser; | ||
import org.apache.polaris.service.catalog.api.IcebergRestCatalogApiService; | ||
|
@@ -420,16 +423,45 @@ public Response loadTable( | |
.loadTableIfStale(tableIdentifier, ifNoneMatch, snapshots) | ||
.orElseThrow(() -> new WebApplicationException(Response.Status.NOT_MODIFIED)); | ||
} else { | ||
response = | ||
LoadTableResponse originalResponse = | ||
catalog | ||
.loadTableWithAccessDelegationIfStale(tableIdentifier, ifNoneMatch, snapshots) | ||
.orElseThrow(() -> new WebApplicationException(Response.Status.NOT_MODIFIED)); | ||
|
||
if (delegationModes.contains(VENDED_CREDENTIALS)) { | ||
response = | ||
injectRefreshVendedCredentialProperties( | ||
originalResponse, | ||
new PolarisResourcePaths(prefix).credentialsPath(tableIdentifier)); | ||
} else { | ||
response = originalResponse; | ||
} | ||
} | ||
|
||
return tryInsertETagHeader(Response.ok(response), response, namespace, table).build(); | ||
}); | ||
} | ||
|
||
private LoadTableResponse injectRefreshVendedCredentialProperties( | ||
LoadTableResponse originalResponse, String credentialsEndpoint) { | ||
LoadTableResponse.Builder loadResponseBuilder = | ||
LoadTableResponse.builder().withTableMetadata(originalResponse.tableMetadata()); | ||
loadResponseBuilder.addAllConfig(originalResponse.config()); | ||
loadResponseBuilder.addAllCredentials(originalResponse.credentials()); | ||
loadResponseBuilder.addConfig( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about azure ? do we want to do it in follow-up ? also should we only inject this when creds are for aws ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW, I think enabling the Azure refresh properties currently causes Azure credential vending to immediately fail due to apache/iceberg#13733, so could maybe wait for that fix to release? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Could maybe lift the AWS refresh check below to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's better to provide the URL even if it's not AWS that way the user can override There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AWS cred refresh properties are :
Azure credential refresh properties are :
I am not sure how can one re-use aws cred endpoint prop to enable azure ? nevertheless why would server send back azure properties for an aws storage ? |
||
AwsClientProperties.REFRESH_CREDENTIALS_ENDPOINT, credentialsEndpoint); | ||
// Only enable credential refresh for currently supported credential types | ||
if (originalResponse.credentials().stream() | ||
.anyMatch( | ||
credential -> | ||
credential | ||
.config() | ||
.containsKey(StorageAccessProperty.AWS_SECRET_KEY.getPropertyName()))) { | ||
loadResponseBuilder.addConfig(AwsClientProperties.REFRESH_CREDENTIALS_ENABLED, "true"); | ||
} | ||
return loadResponseBuilder.build(); | ||
} | ||
|
||
@Override | ||
public Response tableExists( | ||
String prefix, | ||
|
Uh oh!
There was an error while loading. Please reload this page.