Skip to content

Commit 6ee282e

Browse files
committed
review
1 parent e637fa8 commit 6ee282e

File tree

9 files changed

+29
-38
lines changed

9 files changed

+29
-38
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ request adding CHANGELOG notes for breaking (!) changes and possibly other secti
2929

3030
### Highlights
3131

32+
- Support for S3 request signing has been added, allowing Polaris to work with S3-compatible object storage systems.
33+
*Remote signing is currently experimental and not enabled by default*. To enable it, either set the system-wide property
34+
`REMOTE_SIGNING_ENABLED` to `true`, or the catalog-level `polaris.request-signing.enabled` property to `true`.
35+
3236
### Upgrade notes
3337

3438
### Breaking changes

api/iceberg-aws-sign-service/src/main/java/org/apache/polaris/service/aws/sign/model/PolarisS3SignRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
public interface PolarisS3SignRequest extends S3SignRequest {
3838

3939
@Value.Default
40-
@Nullable // Replace javax.annotation.Nullable with jakarta.annotation.Nullable
40+
@Nullable // Replace javax.annotation.Nullable from S3SignRequest with jakarta.annotation.Nullable
4141
@Override
4242
default String body() {
4343
return null;

polaris-core/src/main/java/org/apache/polaris/core/config/FeatureConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,8 @@ public static void enforceFeatureEnabledOrThrow(
355355
.key("REMOTE_SIGNING_ENABLED")
356356
.catalogConfig("polaris.config.remote-signing.enabled")
357357
.description(
358-
"If true, the remote signing endpoints are enabled either globally, or for a specific catalog.")
358+
"If true, the remote signing endpoints are enabled either globally, or for a specific catalog. "
359+
+ "This feature is currently experimental and may change in future releases.")
359360
.defaultValue(false)
360361
.buildFeatureConfiguration();
361362

polaris-core/src/main/java/org/apache/polaris/core/entity/CatalogEntity.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import java.util.HashMap;
2727
import java.util.HashSet;
2828
import java.util.Map;
29-
import java.util.Objects;
3029
import java.util.Optional;
3130
import java.util.Set;
3231
import org.apache.iceberg.exceptions.BadRequestException;
@@ -207,7 +206,7 @@ public Catalog.TypeEnum getCatalogType() {
207206
}
208207

209208
public boolean isExternal() {
210-
return Objects.equals(getCatalogType(), Catalog.TypeEnum.EXTERNAL);
209+
return getCatalogType() == Catalog.TypeEnum.EXTERNAL;
211210
}
212211

213212
public boolean isPassthroughFacade() {

polaris-core/src/main/java/org/apache/polaris/core/rest/PolarisEndpoints.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,9 @@ public static Set<Endpoint> getSupportedPolicyEndpoints(RealmConfig realmConfig)
106106
* remote signing; otherwise, returns an empty set.
107107
*/
108108
public static Set<Endpoint> getSupportedRemoteSigningEndpoints(
109-
CallContext callContext, CatalogEntity catalogEntity) {
109+
RealmConfig realmConfig, CatalogEntity catalogEntity) {
110110
boolean remoteSigningEnabled =
111-
callContext
112-
.getRealmConfig()
113-
.getConfig(FeatureConfiguration.REMOTE_SIGNING_ENABLED, catalogEntity);
111+
realmConfig.getConfig(FeatureConfiguration.REMOTE_SIGNING_ENABLED, catalogEntity);
114112
return remoteSigningEnabled ? REMOTE_SIGNING_ENDPOINTS : ImmutableSet.of();
115113
}
116114
}

runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalog.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
*/
1919
package org.apache.polaris.service.catalog.iceberg;
2020

21-
import static org.apache.polaris.core.storage.PolarisStorageConfigurationInfo.deserialize;
2221
import static org.apache.polaris.service.exception.IcebergExceptionMapper.isStorageProviderRetryableException;
2322

2423
import com.google.common.annotations.VisibleForTesting;
@@ -130,9 +129,9 @@
130129
import org.apache.polaris.core.storage.PolarisStorageIntegration;
131130
import org.apache.polaris.core.storage.PolarisStorageIntegrationProvider;
132131
import org.apache.polaris.core.storage.StorageLocation;
132+
import org.apache.polaris.core.storage.StorageUtil;
133133
import org.apache.polaris.core.storage.aws.AwsCredentialsStorageIntegration;
134134
import org.apache.polaris.core.storage.aws.AwsStorageConfigurationInfo;
135-
import org.apache.polaris.core.storage.StorageUtil;
136135
import org.apache.polaris.core.storage.cache.StorageCredentialCache;
137136
import org.apache.polaris.service.catalog.CatalogPrefixParser;
138137
import org.apache.polaris.service.catalog.SupportsNotifications;
@@ -877,11 +876,9 @@ public AccessConfig getAccessConfigForRemoteSigning(TableIdentifier tableIdentif
877876

878877
Optional<PolarisStorageConfigurationInfo> configurationInfo =
879878
findStorageInfo(tableIdentifier)
880-
.map(
881-
info ->
882-
deserialize(
883-
info.getInternalPropertiesAsMap()
884-
.get(PolarisEntityConstants.getStorageConfigInfoPropertyName())));
879+
.map(PolarisEntity::getInternalPropertiesAsMap)
880+
.map(info -> info.get(PolarisEntityConstants.getStorageConfigInfoPropertyName()))
881+
.map(PolarisStorageConfigurationInfo::deserialize);
885882

886883
if (configurationInfo.isEmpty()) {
887884
LOGGER

runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ public Response getConfig(
803803
.addAll(PolarisEndpoints.getSupportedPolicyEndpoints(realmConfig))
804804
.addAll(
805805
PolarisEndpoints.getSupportedRemoteSigningEndpoints(
806-
callContext, catalogEntity))
806+
callContext.getRealmConfig(), catalogEntity))
807807
.build())
808808
.build())
809809
.build();

runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -701,17 +701,16 @@ public Optional<LoadTableResponse> loadTableWithAccessDelegationIfStale(
701701

702702
if (delegationModes.contains(AccessDelegationMode.VENDED_CREDENTIALS)) {
703703

704-
LOGGER.info(
705-
"allow external catalog credential vending: {}",
704+
boolean allowExternalCatalogCredentialVending =
706705
callContext
707706
.getRealmConfig()
708707
.getConfig(
709-
FeatureConfiguration.ALLOW_EXTERNAL_CATALOG_CREDENTIAL_VENDING, catalogEntity));
710-
if (catalogEntity.isExternal()
711-
&& !callContext
712-
.getRealmConfig()
713-
.getConfig(
714-
FeatureConfiguration.ALLOW_EXTERNAL_CATALOG_CREDENTIAL_VENDING, catalogEntity)) {
708+
FeatureConfiguration.ALLOW_EXTERNAL_CATALOG_CREDENTIAL_VENDING, catalogEntity);
709+
710+
LOGGER.info(
711+
"allow external catalog credential vending: {}", allowExternalCatalogCredentialVending);
712+
713+
if (catalogEntity.isExternal() && !allowExternalCatalogCredentialVending) {
715714
throw new ForbiddenException(
716715
"Access Delegation is not enabled for this catalog. Please consult applicable "
717716
+ "documentation for the catalog config property '%s' to enable this feature",
@@ -776,26 +775,17 @@ private LoadTableResponse.Builder buildLoadTableResponseWithDelegationCredential
776775
CatalogEntity catalogEntity) {
777776
LoadTableResponse.Builder responseBuilder =
778777
LoadTableResponse.builder().withTableMetadata(tableMetadata);
778+
AccessConfig accessConfig = null;
779779
if (baseCatalog instanceof SupportsCredentialDelegation credentialDelegation
780780
&& delegationModes.contains(AccessDelegationMode.VENDED_CREDENTIALS)) {
781781
LOGGER
782782
.atDebug()
783783
.addKeyValue("tableIdentifier", tableIdentifier)
784784
.addKeyValue("tableLocation", tableMetadata.location())
785785
.log("Fetching client credentials for table");
786-
AccessConfig accessConfig =
786+
accessConfig =
787787
credentialDelegation.getAccessConfigForCredentialDelegation(
788788
tableIdentifier, tableMetadata, actions);
789-
Map<String, String> credentialConfig = accessConfig.credentials();
790-
responseBuilder.addAllConfig(credentialConfig);
791-
responseBuilder.addAllConfig(accessConfig.extraProperties());
792-
if (!credentialConfig.isEmpty()) {
793-
responseBuilder.addCredential(
794-
ImmutableCredential.builder()
795-
.prefix(tableMetadata.location())
796-
.config(credentialConfig)
797-
.build());
798-
}
799789
} else if (baseCatalog instanceof SupportsRemoteSigning remoteSigning
800790
&& delegationModes.contains(AccessDelegationMode.REMOTE_SIGNING)) {
801791
S3RemoteSigningCatalogHandler.throwIfRemoteSigningNotEnabled(
@@ -805,7 +795,9 @@ private LoadTableResponse.Builder buildLoadTableResponseWithDelegationCredential
805795
.addKeyValue("tableIdentifier", tableIdentifier)
806796
.addKeyValue("tableLocation", tableMetadata.location())
807797
.log("Enabling remote signing for table");
808-
AccessConfig accessConfig = remoteSigning.getAccessConfigForRemoteSigning(tableIdentifier);
798+
accessConfig = remoteSigning.getAccessConfigForRemoteSigning(tableIdentifier);
799+
}
800+
if (accessConfig != null) {
809801
Map<String, String> credentialConfig = accessConfig.credentials();
810802
responseBuilder.addAllConfig(credentialConfig);
811803
responseBuilder.addAllConfig(accessConfig.extraProperties());

runtime/service/src/main/java/org/apache/polaris/service/storage/aws/signer/S3RemoteSigningCatalogHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ public PolarisS3SignResponse signS3Request(
7070

7171
LOGGER.debug("Requesting s3 signing for {}: {}", tableIdentifier, s3SignRequest);
7272

73+
throwIfRemoteSigningNotEnabled(callContext.getRealmConfig(), catalogEntity);
74+
7375
// TODO authorize based on the request's method?
7476

7577
try {
@@ -83,8 +85,6 @@ public PolarisS3SignResponse signS3Request(
8385
PolarisAuthorizableOperation.SIGN_S3_REQUEST, tableIdentifier);
8486
}
8587

86-
throwIfRemoteSigningNotEnabled(callContext.getRealmConfig(), catalogEntity);
87-
8888
PolarisS3SignResponse s3SignResponse = s3RequestSigner.signRequest(s3SignRequest);
8989
LOGGER.debug("S3 signing response: {}", s3SignResponse);
9090

0 commit comments

Comments
 (0)