-
Notifications
You must be signed in to change notification settings - Fork 419
Implement Kerberos authentication support for Hive Catalog #766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -268,19 +268,15 @@ catalog: | |
| catalog: | ||
| default: | ||
| uri: thrift://localhost:9083 | ||
| hive.hive2-compatible: true | ||
| hive.kerberos-authorization: true | ||
| s3.endpoint: http://localhost:9000 | ||
| s3.access-key-id: admin | ||
| s3.secret-access-key: password | ||
| ``` | ||
|
|
||
| When using Hive 2.x, make sure to set the compatibility flag: | ||
|
|
||
| ```yaml | ||
| catalog: | ||
| default: | ||
| ... | ||
| hive.hive2-compatible: true | ||
| ``` | ||
|
Comment on lines
-276
to
-283
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: leave this as is, since this is only required for hive2. and maybe add similar block for |
||
| | Key | Example | Description | | ||
| | --------------------------- | ------- | --------------------------------- | | ||
| | hive.hive2-compatible | true | Using Hive 2.x compatibility mode | | ||
| | hive.kerberos-authorization | true | Using authentication via Kerberos | | ||
|
|
||
| ### Glue Catalog | ||
|
|
||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -121,6 +121,9 @@ | |||||
| HIVE2_COMPATIBLE = "hive.hive2-compatible" | ||||||
| HIVE2_COMPATIBLE_DEFAULT = False | ||||||
|
|
||||||
| HIVE_KERBEROS_AUTH = "hive.kerberos-authorization" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit:
Suggested change
Kerberos is authentication https://docs.cloudera.com/cdw-runtime/1.5.1/securing-hive/topics/hive_remote_data_access.html |
||||||
| HIVE_KERBEROS_AUTH_DEFAULT = False | ||||||
|
|
||||||
| LOCK_CHECK_MIN_WAIT_TIME = "lock-check-min-wait-time" | ||||||
| LOCK_CHECK_MAX_WAIT_TIME = "lock-check-max-wait-time" | ||||||
| LOCK_CHECK_RETRIES = "lock-check-retries" | ||||||
|
|
@@ -138,17 +141,34 @@ class _HiveClient: | |||||
| _client: Client | ||||||
| _ugi: Optional[List[str]] | ||||||
|
|
||||||
| def __init__(self, uri: str, ugi: Optional[str] = None): | ||||||
| url_parts = urlparse(uri) | ||||||
| transport = TSocket.TSocket(url_parts.hostname, url_parts.port) | ||||||
| self._transport = TTransport.TBufferedTransport(transport) | ||||||
| protocol = TBinaryProtocol.TBinaryProtocol(transport) | ||||||
| def __init__(self, uri: str, ugi: Optional[str] = None, kerberos_auth: Optional[bool] = HIVE_KERBEROS_AUTH_DEFAULT): | ||||||
| self._uri = uri | ||||||
| self._kerberos_auth = kerberos_auth | ||||||
| self._ugi = ugi.split(":") if ugi else None | ||||||
|
|
||||||
| self._init_thrift_client() | ||||||
|
|
||||||
| def _init_thrift_client(self): | ||||||
| url_parts = urlparse(self._uri) | ||||||
|
|
||||||
| socket = TSocket.TSocket(url_parts.hostname, url_parts.port) | ||||||
|
|
||||||
| if not self._kerberos_auth: | ||||||
| self._transport = TTransport.TBufferedTransport(socket) | ||||||
| else: | ||||||
| self._transport = TTransport.TSaslClientTransport(socket, host=url_parts.hostname, service="hive") | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is "hive" a static value here or should it be configurable? |
||||||
|
|
||||||
| protocol = TBinaryProtocol.TBinaryProtocol(self._transport) | ||||||
|
|
||||||
| self._client = Client(protocol) | ||||||
| self._ugi = ugi.split(":") if ugi else None | ||||||
|
|
||||||
| def __enter__(self) -> Client: | ||||||
| self._transport.open() | ||||||
| if not self._kerberos_auth: | ||||||
| self._transport.open() | ||||||
| else: | ||||||
| self._init_thrift_client() | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can this be called multiple times? The init function already calls this
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can remove it here, it is also called on line 149 |
||||||
| self._transport.open() | ||||||
|
|
||||||
| if self._ugi: | ||||||
| self._client.set_ugi(*self._ugi) | ||||||
| return self._client | ||||||
|
|
@@ -257,7 +277,11 @@ class HiveCatalog(MetastoreCatalog): | |||||
|
|
||||||
| def __init__(self, name: str, **properties: str): | ||||||
| super().__init__(name, **properties) | ||||||
| self._client = _HiveClient(properties["uri"], properties.get("ugi")) | ||||||
| self._client = _HiveClient( | ||||||
| properties["uri"], | ||||||
| properties.get("ugi"), | ||||||
| PropertyUtil.property_as_bool(properties, HIVE_KERBEROS_AUTH, HIVE_KERBEROS_AUTH_DEFAULT), | ||||||
| ) | ||||||
|
|
||||||
| self._lock_check_min_wait_time = property_as_float(properties, LOCK_CHECK_MIN_WAIT_TIME, DEFAULT_LOCK_CHECK_MIN_WAIT_TIME) | ||||||
| self._lock_check_max_wait_time = property_as_float(properties, LOCK_CHECK_MAX_WAIT_TIME, DEFAULT_LOCK_CHECK_MAX_WAIT_TIME) | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.