Skip to content

Commit 9ba0c54

Browse files
committed
Replace sigv4-enabled with security in Iceberg
1 parent 5b81408 commit 9ba0c54

File tree

8 files changed

+40
-33
lines changed

8 files changed

+40
-33
lines changed

docs/src/main/sphinx/object-storage/metastores.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,8 +517,6 @@ following properties:
517517
Defaults to `false`.
518518
* - `iceberg.rest-catalog.view-endpoints-enabled`
519519
- Enable view endpoints. Defaults to `true`.
520-
* - `iceberg.rest-catalog.sigv4-enabled`
521-
- Enable AWS Signature version 4 (SigV4). Defaults to `false`.
522520
* - `iceberg.rest-catalog.signing-name`
523521
- AWS SigV4 signing service name. Defaults to `execute-api`.
524522
* - `iceberg.rest-catalog.case-insensitive-name-matching`

plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/rest/IcebergRestCatalogConfig.java

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,17 @@
2727
import static java.util.concurrent.TimeUnit.MILLISECONDS;
2828
import static java.util.concurrent.TimeUnit.MINUTES;
2929

30-
@DefunctConfig("iceberg.rest-catalog.parent-namespace")
30+
@DefunctConfig({
31+
"iceberg.rest-catalog.parent-namespace",
32+
"iceberg.rest-catalog.sigv4-enabled",
33+
})
3134
public class IcebergRestCatalogConfig
3235
{
3336
public enum Security
3437
{
3538
NONE,
3639
OAUTH2,
40+
SIGV4,
3741
}
3842

3943
public enum SessionType
@@ -51,7 +55,6 @@ public enum SessionType
5155
private Duration sessionTimeout = new Duration(CatalogProperties.AUTH_SESSION_TIMEOUT_MS_DEFAULT, MILLISECONDS);
5256
private boolean vendedCredentialsEnabled;
5357
private boolean viewEndpointsEnabled = true;
54-
private boolean sigV4Enabled;
5558
private boolean caseInsensitiveNameMatching;
5659
private Duration caseInsensitiveNameMatchingCacheTtl = new Duration(1, MINUTES);
5760

@@ -179,19 +182,6 @@ public IcebergRestCatalogConfig setViewEndpointsEnabled(boolean viewEndpointsEna
179182
return this;
180183
}
181184

182-
public boolean isSigV4Enabled()
183-
{
184-
return sigV4Enabled;
185-
}
186-
187-
@Config("iceberg.rest-catalog.sigv4-enabled")
188-
@ConfigDescription("Enable AWS Signature version 4 (SigV4)")
189-
public IcebergRestCatalogConfig setSigV4Enabled(boolean sigV4Enabled)
190-
{
191-
this.sigV4Enabled = sigV4Enabled;
192-
return this;
193-
}
194-
195185
public boolean isCaseInsensitiveNameMatching()
196186
{
197187
return caseInsensitiveNameMatching;

plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/rest/IcebergRestCatalogModule.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
*/
1414
package io.trino.plugin.iceberg.catalog.rest;
1515

16-
import com.google.common.collect.ImmutableMap;
1716
import com.google.inject.Binder;
1817
import com.google.inject.Scopes;
1918
import io.airlift.configuration.AbstractConfigurationAwareModule;
@@ -42,12 +41,9 @@ protected void setup(Binder binder)
4241
new NoneSecurityModule()));
4342
install(conditionalModule(
4443
IcebergRestCatalogConfig.class,
45-
IcebergRestCatalogConfig::isSigV4Enabled,
46-
internalBinder -> {
47-
configBinder(internalBinder).bindConfig(IcebergRestCatalogSigV4Config.class);
48-
internalBinder.bind(AwsProperties.class).to(SigV4AwsProperties.class).in(Scopes.SINGLETON);
49-
},
50-
internalBinder -> internalBinder.bind(AwsProperties.class).toInstance(ImmutableMap::of)));
44+
config -> config.getSecurity() == Security.SIGV4,
45+
new SigV4SecurityModule(),
46+
new NoneSecurityModule()));
5147

5248
binder.bind(TrinoCatalogFactory.class).to(TrinoIcebergRestCatalogFactory.class).in(Scopes.SINGLETON);
5349
newOptionalBinder(binder, IcebergFileSystemFactory.class).setBinding().to(IcebergRestCatalogFileSystemFactory.class).in(Scopes.SINGLETON);

plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/rest/SigV4AwsProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import static org.apache.iceberg.aws.AwsProperties.REST_SIGNING_NAME;
3737

3838
public class SigV4AwsProperties
39-
implements AwsProperties
39+
implements SecurityProperties
4040
{
4141
// Copy of `org.apache.iceberg.aws.AwsClientProperties.CLIENT_CREDENTIAL_PROVIDER_PREFIX` https://github.com/apache/iceberg/blob/ab6fc83ec0269736355a0a89c51e44e822264da8/aws/src/main/java/org/apache/iceberg/aws/AwsClientProperties.java#L69
4242
private static final String CLIENT_CREDENTIAL_PROVIDER_PREFIX = "client.credentials-provider.";
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
package io.trino.plugin.iceberg.catalog.rest;
15+
16+
import com.google.inject.Binder;
17+
import io.airlift.configuration.AbstractConfigurationAwareModule;
18+
19+
import static io.airlift.configuration.ConfigBinder.configBinder;
20+
21+
public class SigV4SecurityModule
22+
extends AbstractConfigurationAwareModule
23+
{
24+
@Override
25+
protected void setup(Binder binder)
26+
{
27+
configBinder(binder).bindConfig(IcebergRestCatalogSigV4Config.class);
28+
binder.bind(SecurityProperties.class).to(SigV4AwsProperties.class);
29+
}
30+
}

plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/rest/TrinoIcebergRestCatalogFactory.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ public class TrinoIcebergRestCatalogFactory
6363
private final boolean vendedCredentialsEnabled;
6464
private final boolean viewEndpointsEnabled;
6565
private final SecurityProperties securityProperties;
66-
private final AwsProperties awsProperties;
6766
private final boolean uniqueTableLocation;
6867
private final TypeManager typeManager;
6968
private final boolean caseInsensitiveNameMatching;
@@ -79,7 +78,6 @@ public TrinoIcebergRestCatalogFactory(
7978
CatalogName catalogName,
8079
IcebergRestCatalogConfig restConfig,
8180
SecurityProperties securityProperties,
82-
AwsProperties awsProperties,
8381
IcebergConfig icebergConfig,
8482
TypeManager typeManager,
8583
NodeVersion nodeVersion)
@@ -97,7 +95,6 @@ public TrinoIcebergRestCatalogFactory(
9795
this.vendedCredentialsEnabled = restConfig.isVendedCredentialsEnabled();
9896
this.viewEndpointsEnabled = restConfig.isViewEndpointsEnabled();
9997
this.securityProperties = requireNonNull(securityProperties, "securityProperties is null");
100-
this.awsProperties = requireNonNull(awsProperties, "awsProperties is null");
10198
requireNonNull(icebergConfig, "icebergConfig is null");
10299
this.uniqueTableLocation = icebergConfig.isUniqueTableLocation();
103100
this.typeManager = requireNonNull(typeManager, "typeManager is null");
@@ -126,7 +123,6 @@ public synchronized TrinoCatalog create(ConnectorIdentity identity)
126123
properties.put("trino-version", trinoVersion);
127124
properties.put(AUTH_SESSION_TIMEOUT_MS, String.valueOf(sessionTimeout.toMillis()));
128125
properties.putAll(securityProperties.get());
129-
properties.putAll(awsProperties.get());
130126

131127
if (vendedCredentialsEnabled) {
132128
properties.put("header.X-Iceberg-Access-Delegation", "vended-credentials");

plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/catalog/rest/TestIcebergRestCatalogConfig.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public void testDefaults()
4141
.setSecurity(IcebergRestCatalogConfig.Security.NONE)
4242
.setVendedCredentialsEnabled(false)
4343
.setViewEndpointsEnabled(true)
44-
.setSigV4Enabled(false)
4544
.setCaseInsensitiveNameMatching(false)
4645
.setCaseInsensitiveNameMatchingCacheTtl(new Duration(1, MINUTES)));
4746
}
@@ -59,7 +58,6 @@ public void testExplicitPropertyMappings()
5958
.put("iceberg.rest-catalog.session-timeout", "100ms")
6059
.put("iceberg.rest-catalog.vended-credentials-enabled", "true")
6160
.put("iceberg.rest-catalog.view-endpoints-enabled", "false")
62-
.put("iceberg.rest-catalog.sigv4-enabled", "true")
6361
.put("iceberg.rest-catalog.case-insensitive-name-matching", "true")
6462
.put("iceberg.rest-catalog.case-insensitive-name-matching.cache-ttl", "3m")
6563
.buildOrThrow();
@@ -74,7 +72,6 @@ public void testExplicitPropertyMappings()
7472
.setSecurity(IcebergRestCatalogConfig.Security.OAUTH2)
7573
.setVendedCredentialsEnabled(true)
7674
.setViewEndpointsEnabled(false)
77-
.setSigV4Enabled(true)
7875
.setCaseInsensitiveNameMatching(true)
7976
.setCaseInsensitiveNameMatchingCacheTtl(new Duration(3, MINUTES));
8077

plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/catalog/rest/TestIcebergS3TablesConnectorSmokeTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ protected QueryRunner createQueryRunner()
7171
.addIcebergProperty("iceberg.rest-catalog.uri", "https://glue.%s.amazonaws.com/iceberg".formatted(AWS_REGION))
7272
.addIcebergProperty("iceberg.rest-catalog.warehouse", "s3tablescatalog/" + S3_TABLES_BUCKET)
7373
.addIcebergProperty("iceberg.rest-catalog.view-endpoints-enabled", "false")
74-
.addIcebergProperty("iceberg.rest-catalog.sigv4-enabled", "true")
74+
.addIcebergProperty("iceberg.rest-catalog.security", "sigv4")
7575
.addIcebergProperty("iceberg.rest-catalog.signing-name", "glue")
7676
.addIcebergProperty("iceberg.writer-sort-buffer-size", "1MB")
7777
.addIcebergProperty("iceberg.allowed-extra-properties", "write.metadata.delete-after-commit.enabled,write.metadata.previous-versions-max")

0 commit comments

Comments
 (0)