stackit-core 0.2.0__py3-none-any.whl → 0.3.0__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.
- stackit/core/auth_methods/key_auth.py +19 -11
- {stackit_core-0.2.0.dist-info → stackit_core-0.3.0.dist-info}/METADATA +14 -13
- stackit_core-0.3.0.dist-info/RECORD +10 -0
- {stackit_core-0.2.0.dist-info → stackit_core-0.3.0.dist-info}/WHEEL +1 -1
- stackit_core-0.2.0.dist-info/RECORD +0 -10
- {stackit_core-0.2.0.dist-info → stackit_core-0.3.0.dist-info/licenses}/LICENSE.md +0 -0
- {stackit_core-0.2.0.dist-info → stackit_core-0.3.0.dist-info/licenses}/NOTICE.txt +0 -0
|
@@ -42,6 +42,7 @@ class KeyAuth(AuthBase):
|
|
|
42
42
|
DEFAULT_TOKEN_ENDPOINT = "https://service-account.api.stackit.cloud/token" # noqa S105 false positive
|
|
43
43
|
TOKEN_EXPIRY_CHECK_INTERVAL = timedelta(seconds=60)
|
|
44
44
|
EXPIRATION_LEEWAY = timedelta(minutes=5)
|
|
45
|
+
MAX_REFRESH_RETRIES = 3
|
|
45
46
|
|
|
46
47
|
timeout: Optional[int] = 30
|
|
47
48
|
initial_token: Optional[str]
|
|
@@ -73,6 +74,8 @@ class KeyAuth(AuthBase):
|
|
|
73
74
|
|
|
74
75
|
def __call__(self, r: Request) -> Request:
|
|
75
76
|
with self.lock:
|
|
77
|
+
if self.refresh_future is not None and self.refresh_future.done():
|
|
78
|
+
self.refresh_future.result()
|
|
76
79
|
if self.__is_token_expired(self.access_token):
|
|
77
80
|
if self.refresh_future is None or self.refresh_future.done():
|
|
78
81
|
self.refresh_future = self.executor.submit(self.__refresh_token)
|
|
@@ -108,13 +111,15 @@ class KeyAuth(AuthBase):
|
|
|
108
111
|
self.access_token = response_json["access_token"]
|
|
109
112
|
self.refresh_token = response_json["refresh_token"]
|
|
110
113
|
except requests.RequestException as e:
|
|
111
|
-
|
|
114
|
+
raise requests.RequestException("Initial token fetch failed") from e
|
|
112
115
|
|
|
113
116
|
def __start_token_refresh_task(self):
|
|
114
117
|
def token_refresh_task():
|
|
115
118
|
while True:
|
|
116
119
|
time.sleep(self.TOKEN_EXPIRY_CHECK_INTERVAL.total_seconds())
|
|
117
120
|
with self.lock:
|
|
121
|
+
if self.refresh_future is not None and self.refresh_future.done():
|
|
122
|
+
self.refresh_future.result()
|
|
118
123
|
if self.__is_token_expired(self.access_token) and (
|
|
119
124
|
self.refresh_future is None or self.refresh_future.done()
|
|
120
125
|
):
|
|
@@ -135,16 +140,19 @@ class KeyAuth(AuthBase):
|
|
|
135
140
|
"refresh_token": self.refresh_token,
|
|
136
141
|
}
|
|
137
142
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
143
|
+
last_exception = None
|
|
144
|
+
for _ in range(self.MAX_REFRESH_RETRIES):
|
|
145
|
+
try:
|
|
146
|
+
response = requests.post(self.token_endpoint, data=body, timeout=self.timeout)
|
|
147
|
+
response.raise_for_status()
|
|
148
|
+
response_data = response.json()
|
|
149
|
+
new_token = response_data.get("access_token")
|
|
150
|
+
self.access_token = new_token
|
|
151
|
+
return
|
|
152
|
+
except requests.RequestException as e:
|
|
153
|
+
last_exception = e
|
|
154
|
+
|
|
155
|
+
raise requests.RequestException("Token refresh failed after retries") from last_exception
|
|
148
156
|
|
|
149
157
|
def __is_token_expired(self, token: str) -> bool:
|
|
150
158
|
try:
|
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: stackit-core
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Core functionality for the STACKIT SDK for Python
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
Project-URL: Homepage, https://github.com/stackitcloud/stackit-sdk-python
|
|
6
|
+
Project-URL: Issues, https://github.com/stackitcloud/stackit-sdk-python/issues
|
|
7
|
+
Author-email: STACKIT Developer Tools <developer-tools@stackit.cloud>
|
|
8
|
+
License-File: LICENSE.md
|
|
9
|
+
License-File: NOTICE.txt
|
|
8
10
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
9
11
|
Classifier: Operating System :: OS Independent
|
|
10
12
|
Classifier: Programming Language :: Python :: 3
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.10
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.11
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.12
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
-
|
|
18
|
-
Requires-
|
|
19
|
-
Requires-Dist:
|
|
20
|
-
Requires-Dist:
|
|
21
|
-
Requires-Dist:
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
+
Requires-Python: <4.0,>=3.10
|
|
19
|
+
Requires-Dist: cryptography>=46.0.5
|
|
20
|
+
Requires-Dist: pydantic>=2.9.2
|
|
21
|
+
Requires-Dist: pyjwt>=2.13.0
|
|
22
|
+
Requires-Dist: requests>=2.33.0
|
|
23
|
+
Requires-Dist: urllib3>=2.7.0
|
|
22
24
|
Description-Content-Type: text/markdown
|
|
23
25
|
|
|
24
26
|
> ⓘ INFO: The STACKIT Python SDK is in beta and in active development.
|
|
@@ -34,4 +36,3 @@ to use the [STACKIT Python SDK](https://github.com/stackitcloud/stackit-sdk-pyth
|
|
|
34
36
|
## Usage
|
|
35
37
|
|
|
36
38
|
The core package does nothing on its own and must be used in conjunction with the services of the [STACKIT Python SDK](https://github.com/stackitcloud/stackit-sdk-python).
|
|
37
|
-
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
stackit/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
stackit/core/authorization.py,sha256=36fyp2JKmJ6R2BZGJofXQi0nuY7jcY-dB6QF-I8dED8,4769
|
|
3
|
+
stackit/core/configuration.py,sha256=aQEPK81h9RpJ4A_xjZZTiOBymbBWfaR9t4UJoh4vQDI,2818
|
|
4
|
+
stackit/core/auth_methods/key_auth.py,sha256=-09IEdS2cLMPYoEoNF-5OMSbbA8KmJcGQVk9ECmg_rg,6345
|
|
5
|
+
stackit/core/auth_methods/token_auth.py,sha256=5QuqMWSGkQtmueqECXoJQioXTQROh_JKkgvev1B5Phs,342
|
|
6
|
+
stackit_core-0.3.0.dist-info/METADATA,sha256=bIu0pEGq896g0nmNpcViFaGqSQlft4qAREl1tvB8nAQ,1495
|
|
7
|
+
stackit_core-0.3.0.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
|
|
8
|
+
stackit_core-0.3.0.dist-info/licenses/LICENSE.md,sha256=3dF8Tb7yZn2tS4zyNa-yNe-68pH8qyWdGz4ioMd3MgE,10933
|
|
9
|
+
stackit_core-0.3.0.dist-info/licenses/NOTICE.txt,sha256=TaVw_C4ro-FZROF4NZ3ygwgwF-2QkyySIP9_CPy3kAg,56
|
|
10
|
+
stackit_core-0.3.0.dist-info/RECORD,,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
stackit/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
stackit/core/auth_methods/key_auth.py,sha256=RUiHk5n3lIWAZxVwMr-9XLRmLJjfy9q4AXOAHRdPfYM,5890
|
|
3
|
-
stackit/core/auth_methods/token_auth.py,sha256=5QuqMWSGkQtmueqECXoJQioXTQROh_JKkgvev1B5Phs,342
|
|
4
|
-
stackit/core/authorization.py,sha256=36fyp2JKmJ6R2BZGJofXQi0nuY7jcY-dB6QF-I8dED8,4769
|
|
5
|
-
stackit/core/configuration.py,sha256=aQEPK81h9RpJ4A_xjZZTiOBymbBWfaR9t4UJoh4vQDI,2818
|
|
6
|
-
stackit_core-0.2.0.dist-info/LICENSE.md,sha256=3dF8Tb7yZn2tS4zyNa-yNe-68pH8qyWdGz4ioMd3MgE,10933
|
|
7
|
-
stackit_core-0.2.0.dist-info/METADATA,sha256=YefBYn5J0kNgZF7kJGdUwyKuKCk1frcjAJgaOwWSOZ0,1361
|
|
8
|
-
stackit_core-0.2.0.dist-info/NOTICE.txt,sha256=TaVw_C4ro-FZROF4NZ3ygwgwF-2QkyySIP9_CPy3kAg,56
|
|
9
|
-
stackit_core-0.2.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
10
|
-
stackit_core-0.2.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|