apache-airflow-providers-hashicorp 4.3.0rc1__py3-none-any.whl → 4.3.1rc1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,7 +29,7 @@ from airflow import __version__ as airflow_version
29
29
 
30
30
  __all__ = ["__version__"]
31
31
 
32
- __version__ = "4.3.0"
32
+ __version__ = "4.3.1"
33
33
 
34
34
  if packaging.version.parse(packaging.version.parse(airflow_version).base_version) < packaging.version.parse(
35
35
  "2.10.0"
@@ -153,6 +153,15 @@ class _VaultClient(LoggingMixin):
153
153
  raise VaultError("The 'radius' authentication type requires 'radius_host'")
154
154
  if not radius_secret:
155
155
  raise VaultError("The 'radius' authentication type requires 'radius_secret'")
156
+ if auth_type == "gcp":
157
+ if not gcp_scopes:
158
+ raise VaultError("The 'gcp' authentication type requires 'gcp_scopes'")
159
+ if not role_id:
160
+ raise VaultError("The 'gcp' authentication type requires 'role_id'")
161
+ if not gcp_key_path and not gcp_keyfile_dict:
162
+ raise VaultError(
163
+ "The 'gcp' authentication type requires 'gcp_key_path' or 'gcp_keyfile_dict'"
164
+ )
156
165
 
157
166
  self.kv_engine_version = kv_engine_version or 2
158
167
  self.url = url
@@ -303,13 +312,41 @@ class _VaultClient(LoggingMixin):
303
312
  )
304
313
 
305
314
  scopes = _get_scopes(self.gcp_scopes)
306
- credentials, _ = get_credentials_and_project_id(
315
+ credentials, project_id = get_credentials_and_project_id(
307
316
  key_path=self.gcp_key_path, keyfile_dict=self.gcp_keyfile_dict, scopes=scopes
308
317
  )
318
+
319
+ import json
320
+ import time
321
+
322
+ import googleapiclient
323
+
324
+ if self.gcp_keyfile_dict:
325
+ creds = self.gcp_keyfile_dict
326
+ elif self.gcp_key_path:
327
+ with open(self.gcp_key_path) as f:
328
+ creds = json.load(f)
329
+
330
+ service_account = creds["client_email"]
331
+
332
+ # Generate a payload for subsequent "signJwt()" call
333
+ # Reference: https://googleapis.dev/python/google-auth/latest/reference/google.auth.jwt.html#google.auth.jwt.Credentials
334
+ now = int(time.time())
335
+ expires = now + 900 # 15 mins in seconds, can't be longer.
336
+ payload = {"iat": now, "exp": expires, "sub": credentials, "aud": f"vault/{self.role_id}"}
337
+ body = {"payload": json.dumps(payload)}
338
+ name = f"projects/{project_id}/serviceAccounts/{service_account}"
339
+
340
+ # Perform the GCP API call
341
+ iam = googleapiclient.discovery.build("iam", "v1", credentials=credentials)
342
+ request = iam.projects().serviceAccounts().signJwt(name=name, body=body)
343
+ resp = request.execute()
344
+ jwt = resp["signedJwt"]
345
+
309
346
  if self.auth_mount_point:
310
- _client.auth.gcp.configure(credentials=credentials, mount_point=self.auth_mount_point)
347
+ _client.auth.gcp.login(role=self.role_id, jwt=jwt, mount_point=self.auth_mount_point)
311
348
  else:
312
- _client.auth.gcp.configure(credentials=credentials)
349
+ _client.auth.gcp.login(role=self.role_id, jwt=jwt)
313
350
 
314
351
  def _auth_azure(self, _client: hvac.Client) -> None:
315
352
  if self.auth_mount_point:
@@ -23,12 +23,16 @@ from typing import TYPE_CHECKING, Any
23
23
 
24
24
  from hvac.exceptions import VaultError
25
25
 
26
- from airflow.hooks.base import BaseHook
27
26
  from airflow.providers.hashicorp._internal_client.vault_client import (
28
27
  DEFAULT_KUBERNETES_JWT_PATH,
29
28
  DEFAULT_KV_ENGINE_VERSION,
30
29
  _VaultClient,
31
30
  )
31
+
32
+ try:
33
+ from airflow.sdk import BaseHook
34
+ except ImportError:
35
+ from airflow.hooks.base import BaseHook # type: ignore[attr-defined,no-redef]
32
36
  from airflow.utils.helpers import merge_dicts
33
37
 
34
38
  if TYPE_CHECKING:
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: apache-airflow-providers-hashicorp
3
- Version: 4.3.0rc1
3
+ Version: 4.3.1rc1
4
4
  Summary: Provider package apache-airflow-providers-hashicorp for Apache Airflow
5
5
  Keywords: airflow-provider,hashicorp,airflow,integration
6
6
  Author-email: Apache Software Foundation <dev@airflow.apache.org>
7
7
  Maintainer-email: Apache Software Foundation <dev@airflow.apache.org>
8
- Requires-Python: ~=3.9
8
+ Requires-Python: ~=3.10
9
9
  Description-Content-Type: text/x-rst
10
10
  Classifier: Development Status :: 5 - Production/Stable
11
11
  Classifier: Environment :: Console
@@ -15,7 +15,6 @@ Classifier: Intended Audience :: System Administrators
15
15
  Classifier: Framework :: Apache Airflow
16
16
  Classifier: Framework :: Apache Airflow :: Provider
17
17
  Classifier: License :: OSI Approved :: Apache Software License
18
- Classifier: Programming Language :: Python :: 3.9
19
18
  Classifier: Programming Language :: Python :: 3.10
20
19
  Classifier: Programming Language :: Python :: 3.11
21
20
  Classifier: Programming Language :: Python :: 3.12
@@ -25,8 +24,8 @@ Requires-Dist: hvac>=1.1.0
25
24
  Requires-Dist: boto3>=1.33.0 ; extra == "boto3"
26
25
  Requires-Dist: apache-airflow-providers-google ; extra == "google"
27
26
  Project-URL: Bug Tracker, https://github.com/apache/airflow/issues
28
- Project-URL: Changelog, https://airflow.staged.apache.org/docs/apache-airflow-providers-hashicorp/4.3.0/changelog.html
29
- Project-URL: Documentation, https://airflow.staged.apache.org/docs/apache-airflow-providers-hashicorp/4.3.0
27
+ Project-URL: Changelog, https://airflow.staged.apache.org/docs/apache-airflow-providers-hashicorp/4.3.1/changelog.html
28
+ Project-URL: Documentation, https://airflow.staged.apache.org/docs/apache-airflow-providers-hashicorp/4.3.1
30
29
  Project-URL: Mastodon, https://fosstodon.org/@airflow
31
30
  Project-URL: Slack Chat, https://s.apache.org/airflow-slack
32
31
  Project-URL: Source Code, https://github.com/apache/airflow
@@ -59,7 +58,7 @@ Provides-Extra: google
59
58
 
60
59
  Package ``apache-airflow-providers-hashicorp``
61
60
 
62
- Release: ``4.3.0``
61
+ Release: ``4.3.1``
63
62
 
64
63
 
65
64
  Hashicorp including `Hashicorp Vault <https://www.vaultproject.io/>`__
@@ -72,7 +71,7 @@ This is a provider package for ``hashicorp`` provider. All classes for this prov
72
71
  are in ``airflow.providers.hashicorp`` python package.
73
72
 
74
73
  You can find package information and changelog for the provider
75
- in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-hashicorp/4.3.0/>`_.
74
+ in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-hashicorp/4.3.1/>`_.
76
75
 
77
76
  Installation
78
77
  ------------
@@ -81,7 +80,7 @@ You can install this package on top of an existing Airflow 2 installation (see `
81
80
  for the minimum Airflow version supported) via
82
81
  ``pip install apache-airflow-providers-hashicorp``
83
82
 
84
- The package supports the following python versions: 3.9,3.10,3.11,3.12
83
+ The package supports the following python versions: 3.10,3.11,3.12
85
84
 
86
85
  Requirements
87
86
  ------------
@@ -113,5 +112,5 @@ Dependent package
113
112
  ==================================================================================================== ==========
114
113
 
115
114
  The changelog for the provider package can be found in the
116
- `changelog <https://airflow.apache.org/docs/apache-airflow-providers-hashicorp/4.3.0/changelog.html>`_.
115
+ `changelog <https://airflow.apache.org/docs/apache-airflow-providers-hashicorp/4.3.1/changelog.html>`_.
117
116
 
@@ -1,13 +1,13 @@
1
1
  airflow/providers/hashicorp/LICENSE,sha256=gXPVwptPlW1TJ4HSuG5OMPg-a3h43OGMkZRR1rpwfJA,10850
2
- airflow/providers/hashicorp/__init__.py,sha256=K0ztj8UCaPmneYnujTPAC0J370BreCfw-bQqdCG1awI,1498
2
+ airflow/providers/hashicorp/__init__.py,sha256=GmnqEIZVRmniAtrQAkbSkEo1PQesrEiJzTKEa0RQ5MI,1498
3
3
  airflow/providers/hashicorp/get_provider_info.py,sha256=AFQ7VdRDobAK4-p5A0R9kv4vseR3xtxm7HASrLHThG8,2038
4
4
  airflow/providers/hashicorp/_internal_client/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
5
- airflow/providers/hashicorp/_internal_client/vault_client.py,sha256=MzPl1e54F1eJoZ2PEGU9t5EY6rAzySCpysoALzxYGP0,23112
5
+ airflow/providers/hashicorp/_internal_client/vault_client.py,sha256=9kcavdjUL_SLE7gUidin01MBHC5QBnY8QChTjaIy1tY,24683
6
6
  airflow/providers/hashicorp/hooks/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
7
- airflow/providers/hashicorp/hooks/vault.py,sha256=CUo8jUf0mwzLXrJI4EmrDAxehk5dtDljiU83E-xz8ag,18072
7
+ airflow/providers/hashicorp/hooks/vault.py,sha256=Iw521CvQQ3xmBSmYCpCBw4E5FeSA1xJwrhzeSyVOyl8,18178
8
8
  airflow/providers/hashicorp/secrets/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
9
9
  airflow/providers/hashicorp/secrets/vault.py,sha256=_7zhXwHZJZb5HqLq1PttcJUz2KshnTygsNx96sUVXD4,11553
10
- apache_airflow_providers_hashicorp-4.3.0rc1.dist-info/entry_points.txt,sha256=M338G3KvFSRu5IqEFm5Qheg_myVuQbsN_2EbAwcgqk4,105
11
- apache_airflow_providers_hashicorp-4.3.0rc1.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
12
- apache_airflow_providers_hashicorp-4.3.0rc1.dist-info/METADATA,sha256=dAARRgOtkK1sH3KUKcehT3wlQBupbMioI_CsLiraa6Y,5050
13
- apache_airflow_providers_hashicorp-4.3.0rc1.dist-info/RECORD,,
10
+ apache_airflow_providers_hashicorp-4.3.1rc1.dist-info/entry_points.txt,sha256=M338G3KvFSRu5IqEFm5Qheg_myVuQbsN_2EbAwcgqk4,105
11
+ apache_airflow_providers_hashicorp-4.3.1rc1.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
12
+ apache_airflow_providers_hashicorp-4.3.1rc1.dist-info/METADATA,sha256=yEqePzsQgtGnnPEvZ4f0WANQpnfhXTB59efuOM20XJM,4997
13
+ apache_airflow_providers_hashicorp-4.3.1rc1.dist-info/RECORD,,