diff --git a/presto-docs/src/main/sphinx/connector/iceberg.rst b/presto-docs/src/main/sphinx/connector/iceberg.rst index 55eb20acf9281..c29fb5be18fdb 100644 --- a/presto-docs/src/main/sphinx/connector/iceberg.rst +++ b/presto-docs/src/main/sphinx/connector/iceberg.rst @@ -219,6 +219,11 @@ Property Name Description ``iceberg.rest.auth.oauth2.token`` The Bearer token to use for OAUTH2 authentication. Example: ``SXVLUXUhIExFQ0tFUiEK`` +``iceberg.rest.auth.oauth2.scope`` The scope to use for OAUTH2 authentication. + This property is only applicable when using + ``iceberg.rest.auth.oauth2.credential``. + Example: ``PRINCIPAL_ROLE:ALL`` + ``iceberg.rest.session.type`` The session type to use when communicating with the REST catalog. Available values are ``NONE`` or ``USER`` (default: ``NONE``). diff --git a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/rest/IcebergRestCatalogFactory.java b/presto-iceberg/src/main/java/com/facebook/presto/iceberg/rest/IcebergRestCatalogFactory.java index 4a8be67c1c9db..ca363e793ace3 100644 --- a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/rest/IcebergRestCatalogFactory.java +++ b/presto-iceberg/src/main/java/com/facebook/presto/iceberg/rest/IcebergRestCatalogFactory.java @@ -50,6 +50,7 @@ import static org.apache.iceberg.rest.auth.OAuth2Properties.CREDENTIAL; import static org.apache.iceberg.rest.auth.OAuth2Properties.JWT_TOKEN_TYPE; import static org.apache.iceberg.rest.auth.OAuth2Properties.OAUTH2_SERVER_URI; +import static org.apache.iceberg.rest.auth.OAuth2Properties.SCOPE; import static org.apache.iceberg.rest.auth.OAuth2Properties.TOKEN; public class IcebergRestCatalogFactory @@ -124,6 +125,7 @@ protected Map getCatalogProperties(ConnectorSession session) } catalogConfig.getCredential().ifPresent(credential -> properties.put(CREDENTIAL, credential)); catalogConfig.getToken().ifPresent(token -> properties.put(TOKEN, token)); + catalogConfig.getScope().ifPresent(scope -> properties.put(SCOPE, scope)); } }); diff --git a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/rest/IcebergRestConfig.java b/presto-iceberg/src/main/java/com/facebook/presto/iceberg/rest/IcebergRestConfig.java index fe0d1a5522cb3..e46dfda2109c9 100644 --- a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/rest/IcebergRestConfig.java +++ b/presto-iceberg/src/main/java/com/facebook/presto/iceberg/rest/IcebergRestConfig.java @@ -28,6 +28,7 @@ public class IcebergRestConfig private String authenticationServerUri; private String credential; private String token; + private String scope; @NotNull public Optional getServerUri() @@ -108,6 +109,19 @@ public IcebergRestConfig setToken(String token) return this; } + public Optional getScope() + { + return Optional.ofNullable(scope); + } + + @Config("iceberg.rest.auth.oauth2.scope") + @ConfigDescription("The scope to use for OAUTH2 authentication") + public IcebergRestConfig setScope(String scope) + { + this.scope = scope; + return this; + } + public boolean credentialOrTokenExists() { return credential != null || token != null; diff --git a/presto-iceberg/src/test/java/com/facebook/presto/iceberg/rest/TestIcebergRestConfig.java b/presto-iceberg/src/test/java/com/facebook/presto/iceberg/rest/TestIcebergRestConfig.java index a332a8f6e6fc0..e21f70992e57c 100644 --- a/presto-iceberg/src/test/java/com/facebook/presto/iceberg/rest/TestIcebergRestConfig.java +++ b/presto-iceberg/src/test/java/com/facebook/presto/iceberg/rest/TestIcebergRestConfig.java @@ -35,6 +35,7 @@ public void testDefaults() .setAuthenticationServerUri(null) .setCredential(null) .setToken(null) + .setScope(null) .setSessionType(null)); } @@ -47,6 +48,7 @@ public void testExplicitPropertyMappings() .put("iceberg.rest.auth.oauth2.uri", "http://localhost:yyy") .put("iceberg.rest.auth.oauth2.credential", "key:secret") .put("iceberg.rest.auth.oauth2.token", "SXVLUXUhIExFQ0tFUiEK") + .put("iceberg.rest.auth.oauth2.scope", "PRINCIPAL_ROLE:ALL") .put("iceberg.rest.session.type", "USER") .build(); @@ -56,6 +58,7 @@ public void testExplicitPropertyMappings() .setAuthenticationServerUri("http://localhost:yyy") .setCredential("key:secret") .setToken("SXVLUXUhIExFQ0tFUiEK") + .setScope("PRINCIPAL_ROLE:ALL") .setSessionType(USER); assertFullMapping(properties, expected);