Skip to content

Commit 6e416a9

Browse files
Add IMPLICIT authentication support to the CLI (#2121)
PRs #1925 and #1912 were merged around the same time. This PR connects the two changes and enables the CLI to accept IMPLICIT authentication type. Since Hadoop federated catalogs rely purely on IMPLICIT authentication, the CLI parsing test has been updated to reflect the same.
1 parent 82ae2cf commit 6e416a9

File tree

3 files changed

+33
-20
lines changed

3 files changed

+33
-20
lines changed

client/python/cli/command/catalogs.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from cli.options.option_tree import Argument
2828
from polaris.management import PolarisDefaultApi, CreateCatalogRequest, UpdateCatalogRequest, \
2929
StorageConfigInfo, ExternalCatalog, AwsStorageConfigInfo, AzureStorageConfigInfo, GcpStorageConfigInfo, \
30-
PolarisCatalog, CatalogProperties, BearerAuthenticationParameters, \
30+
PolarisCatalog, CatalogProperties, BearerAuthenticationParameters, ImplicitAuthenticationParameters, \
3131
OAuthClientCredentialsParameters, SigV4AuthenticationParameters, HadoopConnectionConfigInfo, \
3232
IcebergRestConnectionConfigInfo, AwsIamServiceIdentityInfo
3333

@@ -107,7 +107,11 @@ def validate(self):
107107
raise Exception(f"Authentication type 'SIGV4 requires"
108108
f" {Argument.to_flag_name(Arguments.CATALOG_ROLE_ARN)}"
109109
f" and {Argument.to_flag_name(Arguments.CATALOG_SIGNING_REGION)}")
110-
110+
if self.catalog_connection_type == CatalogConnectionType.HADOOP.value:
111+
if not self.hadoop_warehouse or not self.catalog_uri:
112+
raise Exception(f"Missing required argument for connection type 'HADOOP':"
113+
f" {Argument.to_flag_name(Arguments.HADOOP_WAREHOUSE)}"
114+
f" and {Argument.to_flag_name(Arguments.CATALOG_URI)}")
111115
if self.catalog_service_identity_type == ServiceIdentityType.AWS_IAM.value:
112116
if not self.catalog_service_identity_iam_arn:
113117
raise Exception(f"Missing required argument for service identity type 'AWS_IAM':"
@@ -224,6 +228,10 @@ def _build_connection_config_info(self):
224228
signing_region=self.catalog_signing_region,
225229
signing_name=self.catalog_signing_name,
226230
)
231+
elif self.catalog_authentication_type == AuthenticationType.IMPLICIT.value:
232+
auth_params = ImplicitAuthenticationParameters(
233+
authentication_type=self.catalog_authentication_type.upper()
234+
)
227235
elif self.catalog_authentication_type is not None:
228236
raise Exception("Unknown authentication type:", self.catalog_authentication_type)
229237

client/python/cli/constants.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class AuthenticationType(Enum):
6565
OAUTH = "oauth"
6666
BEARER = "bearer"
6767
SIGV4 = "sigv4"
68+
IMPLICIT = "implicit"
6869

6970

7071
class ServiceIdentityType(Enum):
@@ -241,7 +242,7 @@ class External:
241242
"The type of external catalog in [ICEBERG, HADOOP]."
242243
)
243244
CATALOG_AUTHENTICATION_TYPE = (
244-
"The type of authentication in [OAUTH, BEARER, SIGV4]"
245+
"The type of authentication in [OAUTH, BEARER, SIGV4, IMPLICIT]"
245246
)
246247
CATALOG_SERVICE_IDENTITY_TYPE = "The type of service identity in [AWS_IAM]"
247248

client/python/test/test_cli_parsing.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -504,19 +504,6 @@ def get(obj, arg_string):
504504
(2, 'grant.namespace'): ['a', 'b', 'c'],
505505
(2, 'grant.view_name'): 'v',
506506
})
507-
check_arguments(
508-
mock_execute(['catalogs', 'create', 'my-catalog', '--type', 'external',
509-
'--storage-type', 'gcs', '--default-base-location', 'dbl',
510-
'--catalog-connection-type', 'hadoop', '--hadoop-warehouse', 'h',
511-
'--catalog-uri', 'u', '--catalog-authentication-type', 'bearer',
512-
'--catalog-bearer-token', 'b']),
513-
'create_catalog', {
514-
(0, 'catalog.name'): 'my-catalog',
515-
(0, 'catalog.type'): 'EXTERNAL',
516-
(0, 'catalog.connection_config_info.connection_type'): 'HADOOP',
517-
(0, 'catalog.connection_config_info.warehouse'): 'h',
518-
(0, 'catalog.connection_config_info.uri'): 'u',
519-
})
520507
check_arguments(
521508
mock_execute(['catalogs', 'create', 'my-catalog', '--type', 'external',
522509
'--storage-type', 'gcs', '--default-base-location', 'dbl',
@@ -533,20 +520,24 @@ def get(obj, arg_string):
533520
check_arguments(
534521
mock_execute(['catalogs', 'create', 'my-catalog', '--type', 'external',
535522
'--storage-type', 'gcs', '--default-base-location', 'dbl',
536-
'--catalog-connection-type', 'hadoop', '--hadoop-warehouse', 'h',
537-
'--catalog-authentication-type', 'oauth',
523+
'--catalog-connection-type', 'iceberg-rest',
524+
'--iceberg-remote-catalog-name', 'c',
525+
'--catalog-uri', 'u', '--catalog-authentication-type', 'oauth',
538526
'--catalog-token-uri', 'u', '--catalog-client-id', 'i',
539527
'--catalog-client-secret', 'k', '--catalog-client-scope', 's1',
540528
'--catalog-client-scope', 's2']),
541529
'create_catalog', {
542530
(0, 'catalog.name'): 'my-catalog',
543531
(0, 'catalog.type'): 'EXTERNAL',
544-
(0, 'catalog.connection_config_info.connection_type'): 'HADOOP',
545-
(0, 'catalog.connection_config_info.warehouse'): 'h',
532+
(0, 'catalog.connection_config_info.connection_type'): 'ICEBERG_REST',
533+
(0, 'catalog.connection_config_info.remote_catalog_name'): 'c',
534+
(0, 'catalog.connection_config_info.uri'): 'u',
546535
(0, 'catalog.connection_config_info.authentication_parameters.authentication_type'): 'OAUTH',
547536
(0, 'catalog.connection_config_info.authentication_parameters.token_uri'): 'u',
548537
(0, 'catalog.connection_config_info.authentication_parameters.client_id'): 'i',
549538
(0, 'catalog.connection_config_info.authentication_parameters.scopes'): ['s1', 's2'],
539+
(0, 'catalog.storage_config_info.storage_type'): 'GCS',
540+
(0, 'catalog.properties.default_base_location'): 'dbl',
550541
})
551542
check_arguments(
552543
mock_execute(['catalogs', 'create', 'my-catalog', '--type', 'external',
@@ -583,6 +574,19 @@ def get(obj, arg_string):
583574
(0, 'catalog.connection_config_info.authentication_parameters.external_id'): 'i',
584575
(0, 'catalog.connection_config_info.authentication_parameters.signing_name'): 'g',
585576
})
577+
check_arguments(
578+
mock_execute(['catalogs', 'create', 'my-catalog', '--type', 'external',
579+
'--storage-type', 'file', '--default-base-location', 'dbl',
580+
'--catalog-connection-type', 'hadoop', '--hadoop-warehouse', 'h',
581+
'--catalog-authentication-type', 'implicit', '--catalog-uri', 'u']),
582+
'create_catalog', {
583+
(0, 'catalog.name'): 'my-catalog',
584+
(0, 'catalog.type'): 'EXTERNAL',
585+
(0, 'catalog.connection_config_info.connection_type'): 'HADOOP',
586+
(0, 'catalog.connection_config_info.warehouse'): 'h',
587+
(0, 'catalog.connection_config_info.authentication_parameters.authentication_type'): 'IMPLICIT',
588+
(0, 'catalog.connection_config_info.uri'): 'u',
589+
})
586590

587591

588592
if __name__ == '__main__':

0 commit comments

Comments
 (0)