Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions presto-docs/src/main/sphinx/connector/iceberg.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,8 @@ Property Name Description
Example: ``https://localhost:19120/api/v1``

``iceberg.nessie.auth.type`` The authentication type to use.
Available values are ``BASIC`` or ``BEARER``.
Example: ``BEARER``

``iceberg.nessie.auth.basic.username`` The username to use with ``BASIC`` authentication.
Example: ``test_user``

``iceberg.nessie.auth.basic.password`` The password to use with ``BASIC`` authentication.
Example: ``my$ecretPass``
Available values are ``NONE`` or ``BEARER``.
Default: ``NONE``

``iceberg.nessie.auth.bearer.token`` The token to use with ``BEARER`` authentication.
Example: ``SXVLUXUhIExFQ0tFUiEK``
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import static com.facebook.presto.iceberg.CatalogType.NESSIE;
import static com.facebook.presto.iceberg.IcebergSessionProperties.getNessieReferenceHash;
import static com.facebook.presto.iceberg.IcebergSessionProperties.getNessieReferenceName;
import static com.facebook.presto.iceberg.nessie.AuthenticationType.BASIC;
import static com.facebook.presto.iceberg.nessie.AuthenticationType.BEARER;
import static com.facebook.presto.spi.StandardErrorCode.NOT_SUPPORTED;
import static com.google.common.base.Throwables.throwIfInstanceOf;
Expand Down Expand Up @@ -165,13 +164,7 @@ public Map<String, String> getCatalogProperties(ConnectorSession session)
nessieConfig.getConnectTimeoutMillis().ifPresent(val -> properties.put("transport.connect-timeout", val.toString()));
nessieConfig.getClientBuilderImpl().ifPresent(val -> properties.put("client-builder-impl", val));
nessieConfig.getAuthenticationType().ifPresent(type -> {
if (type == BASIC) {
properties.put("authentication.username", nessieConfig.getUsername()
.orElseThrow(() -> new IllegalStateException("iceberg.nessie.auth.basic.username must be set with BASIC authentication")));
properties.put("authentication.password", nessieConfig.getPassword()
.orElseThrow(() -> new IllegalStateException("iceberg.nessie.auth.basic.password must be set with BASIC authentication")));
}
else if (type == BEARER) {
if (type == BEARER) {
properties.put("authentication.token", nessieConfig.getBearerToken()
.orElseThrow(() -> new IllegalStateException("iceberg.nessie.auth.bearer.token must be set with BEARER authentication")));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@

public enum AuthenticationType
{
BASIC,
NONE,
BEARER
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@

import java.util.Optional;

import static com.facebook.presto.iceberg.nessie.AuthenticationType.NONE;

public class NessieConfig
{
private String defaultReferenceName = "main";
private String serverUri;
private AuthenticationType authenticationType;
private String username;
private String password;
private AuthenticationType authenticationType = NONE;
private String bearerToken;
private Integer readTimeoutMillis;
private Integer connectTimeoutMillis;
Expand Down Expand Up @@ -61,7 +61,7 @@ public NessieConfig setServerUri(String serverUri)
}

@Config("iceberg.nessie.auth.type")
@ConfigDescription("The authentication type to use. Available values are BASIC | BEARER")
@ConfigDescription("The authentication type to use. Available values are NONE | BEARER")
public NessieConfig setAuthenticationType(AuthenticationType authenticationType)
{
this.authenticationType = authenticationType;
Expand All @@ -73,32 +73,6 @@ public Optional<AuthenticationType> getAuthenticationType()
return Optional.ofNullable(authenticationType);
}

@Config("iceberg.nessie.auth.basic.username")
@ConfigDescription("The username to use with BASIC authentication")
public NessieConfig setUsername(String username)
{
this.username = username;
return this;
}

public Optional<String> getUsername()
{
return Optional.ofNullable(username);
}

@Config("iceberg.nessie.auth.basic.password")
@ConfigDescription("The password to use with BASIC authentication")
public NessieConfig setPassword(String password)
{
this.password = password;
return this;
}

public Optional<String> getPassword()
{
return Optional.ofNullable(password);
}

@Config("iceberg.nessie.auth.bearer.token")
@ConfigDescription("The token to use with BEARER authentication")
public NessieConfig setBearerToken(String bearerToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static com.facebook.airlift.configuration.testing.ConfigAssertions.assertFullMapping;
import static com.facebook.airlift.configuration.testing.ConfigAssertions.assertRecordedDefaults;
import static com.facebook.airlift.configuration.testing.ConfigAssertions.recordDefaults;
import static com.facebook.presto.iceberg.nessie.AuthenticationType.NONE;

public class TestNessieConfig
{
Expand All @@ -29,16 +30,14 @@ public void testDefaults()
{
assertRecordedDefaults(recordDefaults(NessieConfig.class)
.setClientBuilderImpl(null)
.setAuthenticationType(null)
.setAuthenticationType(NONE)
.setBearerToken(null)
.setCompressionEnabled(true)
.setDefaultReferenceName("main")
.setConnectTimeoutMillis(null)
.setPassword(null)
.setReadTimeoutMillis(null)
.setReadTimeoutMillis(null)
.setServerUri(null)
.setUsername(null));
.setServerUri(null));
}

@Test
Expand All @@ -47,9 +46,7 @@ public void testExplicitPropertyMappings()
Map<String, String> properties = ImmutableMap.<String, String>builder()
.put("iceberg.nessie.uri", "http://localhost:xxx/api/v1")
.put("iceberg.nessie.ref", "someRef")
.put("iceberg.nessie.auth.type", "BASIC")
.put("iceberg.nessie.auth.basic.username", "user")
.put("iceberg.nessie.auth.basic.password", "pass")
.put("iceberg.nessie.auth.type", "BEARER")
.put("iceberg.nessie.auth.bearer.token", "bearerToken")
.put("iceberg.nessie.compression-enabled", "false")
.put("iceberg.nessie.connect-timeout-ms", "123")
Expand All @@ -60,9 +57,7 @@ public void testExplicitPropertyMappings()
NessieConfig expected = new NessieConfig()
.setServerUri("http://localhost:xxx/api/v1")
.setDefaultReferenceName("someRef")
.setAuthenticationType(AuthenticationType.BASIC)
.setUsername("user")
.setPassword("pass")
.setAuthenticationType(AuthenticationType.BEARER)
.setBearerToken("bearerToken")
.setCompressionEnabled(false)
.setConnectTimeoutMillis(123)
Expand Down