VaultAPI-Client 0.3.0__py3-none-any.whl → 0.3.2__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.
- vaultapi_client/__init__.py +1 -1
- vaultapi_client/config.py +25 -2
- vaultapi_client/session.py +3 -2
- {vaultapi_client-0.3.0.dist-info → vaultapi_client-0.3.2.dist-info}/METADATA +7 -1
- vaultapi_client-0.3.2.dist-info/RECORD +14 -0
- {vaultapi_client-0.3.0.dist-info → vaultapi_client-0.3.2.dist-info}/WHEEL +1 -1
- vaultapi_client-0.3.0.dist-info/RECORD +0 -14
- {vaultapi_client-0.3.0.dist-info → vaultapi_client-0.3.2.dist-info}/entry_points.txt +0 -0
- {vaultapi_client-0.3.0.dist-info → vaultapi_client-0.3.2.dist-info}/licenses/LICENSE +0 -0
- {vaultapi_client-0.3.0.dist-info → vaultapi_client-0.3.2.dist-info}/top_level.txt +0 -0
vaultapi_client/__init__.py
CHANGED
vaultapi_client/config.py
CHANGED
|
@@ -6,6 +6,8 @@ import dotenv
|
|
|
6
6
|
import requests
|
|
7
7
|
from cryptography.fernet import Fernet
|
|
8
8
|
from packaging import version
|
|
9
|
+
from requests.adapters import HTTPAdapter
|
|
10
|
+
from urllib3.util import Retry
|
|
9
11
|
|
|
10
12
|
from vaultapi_client.aws import AWSClient
|
|
11
13
|
from vaultapi_client.exceptions import VaultAPIClientError, VaultAPIServerError
|
|
@@ -16,6 +18,25 @@ dotenv.load_dotenv(env_file)
|
|
|
16
18
|
MINIMUM_SERVER_VERSION = version.parse("0.6.0")
|
|
17
19
|
|
|
18
20
|
|
|
21
|
+
def create_session():
|
|
22
|
+
"""Return a ``requests.Session`` object with retry adapters mounted."""
|
|
23
|
+
# Define retry adapter
|
|
24
|
+
retry_strategy = Retry(
|
|
25
|
+
total=5, # Total number of retries
|
|
26
|
+
backoff_factor=1, # Delay between retries
|
|
27
|
+
status_forcelist=[429, 502, 503, 504], # HTTP codes to retry
|
|
28
|
+
allowed_methods=["GET", "POST", "PUT", "DELETE"], # HTTP methods to retry
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
# Create adapter and session
|
|
32
|
+
adapter = HTTPAdapter(max_retries=retry_strategy)
|
|
33
|
+
session = requests.Session()
|
|
34
|
+
# noinspection HttpUrlsUsage
|
|
35
|
+
session.mount("http://", adapter)
|
|
36
|
+
session.mount("https://", adapter)
|
|
37
|
+
return session
|
|
38
|
+
|
|
39
|
+
|
|
19
40
|
class EndpointMapping(Enum):
|
|
20
41
|
"""Enum like function to get all endpoint names to avoid hard coding.
|
|
21
42
|
|
|
@@ -56,6 +77,7 @@ class EnvConfig:
|
|
|
56
77
|
self.vault_secret: str = vault_secret
|
|
57
78
|
self.transit_key_length: int = int(vault_transit_key_length)
|
|
58
79
|
self.transit_time_bucket: int = int(vault_transit_time_bucket)
|
|
80
|
+
self.session = create_session()
|
|
59
81
|
self.__assert__()
|
|
60
82
|
|
|
61
83
|
def server_check(self, endpoint: EndpointMapping) -> None | NoReturn:
|
|
@@ -65,8 +87,9 @@ class EnvConfig:
|
|
|
65
87
|
endpoint: Endpoint to check.
|
|
66
88
|
"""
|
|
67
89
|
try:
|
|
68
|
-
|
|
69
|
-
|
|
90
|
+
# (connect_timeout: 2, read_timeout: 1)
|
|
91
|
+
response = self.session.get(
|
|
92
|
+
url=urljoin(self.vault_server, endpoint), timeout=(2, 1)
|
|
70
93
|
)
|
|
71
94
|
response.raise_for_status()
|
|
72
95
|
except requests.RequestException as error:
|
vaultapi_client/session.py
CHANGED
|
@@ -5,7 +5,7 @@ from typing import Any, Callable, Dict, NoReturn
|
|
|
5
5
|
|
|
6
6
|
import requests
|
|
7
7
|
|
|
8
|
-
from vaultapi_client.config import EndpointMapping, EnvConfig
|
|
8
|
+
from vaultapi_client.config import EndpointMapping, EnvConfig, create_session
|
|
9
9
|
from vaultapi_client.exceptions import VaultAPIServerError
|
|
10
10
|
from vaultapi_client.util import urljoin
|
|
11
11
|
|
|
@@ -79,6 +79,7 @@ class Session:
|
|
|
79
79
|
"Accept": "application/json",
|
|
80
80
|
"Authorization": f"Bearer {generate_bearer_token(token)}",
|
|
81
81
|
}
|
|
82
|
+
self.session = create_session()
|
|
82
83
|
|
|
83
84
|
def request(
|
|
84
85
|
self,
|
|
@@ -105,7 +106,7 @@ class Session:
|
|
|
105
106
|
else:
|
|
106
107
|
headers = self.headers(token=f"{self.apikey}.{self.secret}")
|
|
107
108
|
try:
|
|
108
|
-
response =
|
|
109
|
+
response = self.session.request(
|
|
109
110
|
method=method, url=url, headers=headers, params=params, json=json
|
|
110
111
|
)
|
|
111
112
|
response.raise_for_status()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: VaultAPI-Client
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: Client application for VaultAPI Server
|
|
5
5
|
Author-email: Vignesh Rao <svignesh1793@gmail.com>
|
|
6
6
|
License: MIT License
|
|
@@ -27,6 +27,7 @@ License: MIT License
|
|
|
27
27
|
|
|
28
28
|
Project-URL: Homepage, https://github.com/thevickypedia/VaultAPI-Client-python
|
|
29
29
|
Project-URL: Source, https://github.com/thevickypedia/VaultAPI-Client-python
|
|
30
|
+
Project-URL: Bug Tracker, https://github.com/thevickypedia/VaultAPI-Client-python/issues
|
|
30
31
|
Keywords: vaultapi,vault,fastapi,sqlite3,fernet
|
|
31
32
|
Classifier: License :: OSI Approved :: MIT License
|
|
32
33
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -36,6 +37,11 @@ Classifier: Topic :: Security :: Cryptography
|
|
|
36
37
|
Requires-Python: >=3.10
|
|
37
38
|
Description-Content-Type: text/markdown
|
|
38
39
|
License-File: LICENSE
|
|
40
|
+
Requires-Dist: cryptography==49.0.0
|
|
41
|
+
Requires-Dist: packaging==26.*
|
|
42
|
+
Requires-Dist: python-dotenv==1.2.*
|
|
43
|
+
Requires-Dist: requests==2.*
|
|
44
|
+
Requires-Dist: urllib3==2.*
|
|
39
45
|
Provides-Extra: dev
|
|
40
46
|
Requires-Dist: pre-commit; extra == "dev"
|
|
41
47
|
Provides-Extra: aws
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
vaultapi_client/__init__.py,sha256=hURJp9_84PSwOgy2V7SrgqyaVBNFp8w3c7UbTSNt-T4,1308
|
|
2
|
+
vaultapi_client/aws.py,sha256=1y-hSg76K5oc1wqbOBVuGhVZV3Ckt2ttTEdL5O0i4yo,2694
|
|
3
|
+
vaultapi_client/config.py,sha256=uy-DjVn8382EoSCodmlFLUGrLa9A6aoesjgymHw4inE,6284
|
|
4
|
+
vaultapi_client/exceptions.py,sha256=hpZxtnSa1SHNDaTJwYdwXFuUkzi2ZdB23apKrKOOUzk,602
|
|
5
|
+
vaultapi_client/main.py,sha256=6joJFNJRFNM1Te2ixzGdzB9iGbrgonIvYZeAUQ60ncc,6956
|
|
6
|
+
vaultapi_client/session.py,sha256=sSN92klmGBRffI131ByI95tk42-VNMi3ytxqHwC5dTo,5347
|
|
7
|
+
vaultapi_client/transit.py,sha256=ZH4OF-TO50zQfcCy6e1f202QWYaBPk9bzZ2bWhSPQxo,3114
|
|
8
|
+
vaultapi_client/util.py,sha256=qMD1Hpu3_GmwxNJ8AM-k5yu-QlN--qes00LT--Q5kkQ,393
|
|
9
|
+
vaultapi_client-0.3.2.dist-info/licenses/LICENSE,sha256=_sOIKJWdD2o1WwwDIwYB2qTP2nlSWqT5Tyg9jr1Xa4w,1070
|
|
10
|
+
vaultapi_client-0.3.2.dist-info/METADATA,sha256=yfKd7qFy_YpsdxysAAaegfk5g8vwdu0gGJAYXu2yYp0,6160
|
|
11
|
+
vaultapi_client-0.3.2.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
12
|
+
vaultapi_client-0.3.2.dist-info/entry_points.txt,sha256=P3CaBVJ9RvRJy7xvd9A4o3HYEfoM4wStZcQ8L6837NE,64
|
|
13
|
+
vaultapi_client-0.3.2.dist-info/top_level.txt,sha256=J0qf2Tuj66RGC_VTF9f3Ce137qPqL8n0V21-1xwp1nw,16
|
|
14
|
+
vaultapi_client-0.3.2.dist-info/RECORD,,
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
vaultapi_client/__init__.py,sha256=EpHR8g5-TpGoV-6fo_5PEy43sJaKdy8wMrCl_F0hrsQ,1308
|
|
2
|
-
vaultapi_client/aws.py,sha256=1y-hSg76K5oc1wqbOBVuGhVZV3Ckt2ttTEdL5O0i4yo,2694
|
|
3
|
-
vaultapi_client/config.py,sha256=Z8dGcxk5FKuQj0HpAe8Wq_bwEcuT8TamrXdrbNadFVg,5456
|
|
4
|
-
vaultapi_client/exceptions.py,sha256=hpZxtnSa1SHNDaTJwYdwXFuUkzi2ZdB23apKrKOOUzk,602
|
|
5
|
-
vaultapi_client/main.py,sha256=6joJFNJRFNM1Te2ixzGdzB9iGbrgonIvYZeAUQ60ncc,6956
|
|
6
|
-
vaultapi_client/session.py,sha256=rh2aazo-8gjFIIiSohaZdmiUiZpjWxMQZqCVxl09uqo,5287
|
|
7
|
-
vaultapi_client/transit.py,sha256=ZH4OF-TO50zQfcCy6e1f202QWYaBPk9bzZ2bWhSPQxo,3114
|
|
8
|
-
vaultapi_client/util.py,sha256=qMD1Hpu3_GmwxNJ8AM-k5yu-QlN--qes00LT--Q5kkQ,393
|
|
9
|
-
vaultapi_client-0.3.0.dist-info/licenses/LICENSE,sha256=_sOIKJWdD2o1WwwDIwYB2qTP2nlSWqT5Tyg9jr1Xa4w,1070
|
|
10
|
-
vaultapi_client-0.3.0.dist-info/METADATA,sha256=t7T2o9UBD37po-Sa6UArzhY1Tt5X4_nJadSdocFTsOw,5911
|
|
11
|
-
vaultapi_client-0.3.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
12
|
-
vaultapi_client-0.3.0.dist-info/entry_points.txt,sha256=P3CaBVJ9RvRJy7xvd9A4o3HYEfoM4wStZcQ8L6837NE,64
|
|
13
|
-
vaultapi_client-0.3.0.dist-info/top_level.txt,sha256=J0qf2Tuj66RGC_VTF9f3Ce137qPqL8n0V21-1xwp1nw,16
|
|
14
|
-
vaultapi_client-0.3.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|