digitalhub 0.11.0b2__py3-none-any.whl → 0.11.0b3__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.
Potentially problematic release.
This version of digitalhub might be problematic. Click here for more details.
- digitalhub/stores/client/dhcore/configurator.py +60 -10
- digitalhub/stores/configurator/ini_module.py +3 -3
- {digitalhub-0.11.0b2.dist-info → digitalhub-0.11.0b3.dist-info}/METADATA +1 -1
- {digitalhub-0.11.0b2.dist-info → digitalhub-0.11.0b3.dist-info}/RECORD +6 -6
- {digitalhub-0.11.0b2.dist-info → digitalhub-0.11.0b3.dist-info}/WHEEL +0 -0
- {digitalhub-0.11.0b2.dist-info → digitalhub-0.11.0b3.dist-info}/licenses/LICENSE.txt +0 -0
|
@@ -22,8 +22,8 @@ AUTH_KEY = "_auth"
|
|
|
22
22
|
|
|
23
23
|
# API levels that are supported
|
|
24
24
|
MAX_API_LEVEL = 20
|
|
25
|
-
MIN_API_LEVEL =
|
|
26
|
-
LIB_VERSION =
|
|
25
|
+
MIN_API_LEVEL = 11
|
|
26
|
+
LIB_VERSION = 11
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
class ClientDHCoreConfigurator:
|
|
@@ -159,10 +159,10 @@ class ClientDHCoreConfigurator:
|
|
|
159
159
|
None
|
|
160
160
|
"""
|
|
161
161
|
# Give priority to access token
|
|
162
|
-
access_token =
|
|
162
|
+
access_token = self._load_dhcore_oauth_vars(DhcoreEnvVar.ACCESS_TOKEN.value)
|
|
163
163
|
if access_token is not None:
|
|
164
164
|
configurator.set_credential(AUTH_KEY, AuthType.OAUTH2.value)
|
|
165
|
-
configurator.set_credential(DhcoreEnvVar.ACCESS_TOKEN.value, access_token)
|
|
165
|
+
configurator.set_credential(DhcoreEnvVar.ACCESS_TOKEN.value.removeprefix("DHCORE_"), access_token)
|
|
166
166
|
|
|
167
167
|
# Fallback to basic
|
|
168
168
|
else:
|
|
@@ -223,7 +223,7 @@ class ClientDHCoreConfigurator:
|
|
|
223
223
|
elif self.oauth2_auth():
|
|
224
224
|
if "headers" not in kwargs:
|
|
225
225
|
kwargs["headers"] = {}
|
|
226
|
-
access_token = creds[DhcoreEnvVar.ACCESS_TOKEN.value]
|
|
226
|
+
access_token = creds[DhcoreEnvVar.ACCESS_TOKEN.value.removeprefix("DHCORE_")]
|
|
227
227
|
kwargs["headers"]["Authorization"] = f"Bearer {access_token}"
|
|
228
228
|
return kwargs
|
|
229
229
|
|
|
@@ -246,7 +246,7 @@ class ClientDHCoreConfigurator:
|
|
|
246
246
|
|
|
247
247
|
# Otherwise try token from file
|
|
248
248
|
if response.status_code in (400, 401, 403):
|
|
249
|
-
refresh_token = configurator.load_from_file(DhcoreEnvVar.REFRESH_TOKEN.value)
|
|
249
|
+
refresh_token = configurator.load_from_file(DhcoreEnvVar.REFRESH_TOKEN.value.removeprefix("DHCORE_"))
|
|
250
250
|
response = self._call_refresh_token_endpoint(url, refresh_token)
|
|
251
251
|
|
|
252
252
|
response.raise_for_status()
|
|
@@ -267,12 +267,42 @@ class ClientDHCoreConfigurator:
|
|
|
267
267
|
-------
|
|
268
268
|
None
|
|
269
269
|
"""
|
|
270
|
-
keys =
|
|
270
|
+
keys = [
|
|
271
|
+
*self._remove_prefix_dhcore(list_enum(DhcoreEnvVar)),
|
|
272
|
+
*list_enum(S3StoreEnv),
|
|
273
|
+
*list_enum(SqlStoreEnv),
|
|
274
|
+
]
|
|
271
275
|
for key in keys:
|
|
272
|
-
if (value := response.get(key.lower()
|
|
276
|
+
if (value := response.get(key.lower())) is not None:
|
|
273
277
|
configurator.set_credential(key, value)
|
|
274
278
|
configurator.write_env(keys)
|
|
275
279
|
|
|
280
|
+
def _remove_prefix_dhcore(self, keys: list[str]) -> list[str]:
|
|
281
|
+
"""
|
|
282
|
+
Remove prefix from selected keys. (Compatibility with CLI)
|
|
283
|
+
|
|
284
|
+
Parameters
|
|
285
|
+
----------
|
|
286
|
+
keys : list[str]
|
|
287
|
+
List of keys.
|
|
288
|
+
|
|
289
|
+
Returns
|
|
290
|
+
-------
|
|
291
|
+
list[str]
|
|
292
|
+
List of keys without prefix.
|
|
293
|
+
"""
|
|
294
|
+
new_list = []
|
|
295
|
+
for key in keys:
|
|
296
|
+
if key in (DhcoreEnvVar.REFRESH_TOKEN.value,
|
|
297
|
+
DhcoreEnvVar.ACCESS_TOKEN.value,
|
|
298
|
+
DhcoreEnvVar.ISSUER.value,
|
|
299
|
+
#DhcoreEnvVar.CLIENT_ID.value,
|
|
300
|
+
):
|
|
301
|
+
new_list.append(key.removeprefix("DHCORE_"))
|
|
302
|
+
else:
|
|
303
|
+
new_list.append(key)
|
|
304
|
+
return new_list
|
|
305
|
+
|
|
276
306
|
def _get_refresh_endpoint(self) -> str:
|
|
277
307
|
"""
|
|
278
308
|
Get the refresh endpoint.
|
|
@@ -283,11 +313,11 @@ class ClientDHCoreConfigurator:
|
|
|
283
313
|
Refresh endpoint.
|
|
284
314
|
"""
|
|
285
315
|
# Get issuer endpoint
|
|
286
|
-
endpoint_issuer =
|
|
316
|
+
endpoint_issuer = self._load_dhcore_oauth_vars(DhcoreEnvVar.ISSUER.value)
|
|
287
317
|
if endpoint_issuer is None:
|
|
288
318
|
raise ClientError("Issuer endpoint not set.")
|
|
289
319
|
endpoint_issuer = self._sanitize_endpoint(endpoint_issuer)
|
|
290
|
-
configurator.set_credential(DhcoreEnvVar.ISSUER.value, endpoint_issuer)
|
|
320
|
+
configurator.set_credential(DhcoreEnvVar.ISSUER.value.removeprefix("DHCORE_"), endpoint_issuer)
|
|
291
321
|
|
|
292
322
|
# Standard issuer endpoint path
|
|
293
323
|
url = endpoint_issuer + "/.well-known/openid-configuration"
|
|
@@ -315,6 +345,7 @@ class ClientDHCoreConfigurator:
|
|
|
315
345
|
"""
|
|
316
346
|
# Get client id
|
|
317
347
|
client_id = configurator.load_var(DhcoreEnvVar.CLIENT_ID.value)
|
|
348
|
+
#client_id = self._load_dhcore_oauth_vars(DhcoreEnvVar.CLIENT_ID.value)
|
|
318
349
|
if client_id is None:
|
|
319
350
|
raise ClientError("Client id not set.")
|
|
320
351
|
|
|
@@ -327,3 +358,22 @@ class ClientDHCoreConfigurator:
|
|
|
327
358
|
}
|
|
328
359
|
headers = {"Content-Type": "application/x-www-form-urlencoded"}
|
|
329
360
|
return request("POST", url, data=payload, headers=headers, timeout=60)
|
|
361
|
+
|
|
362
|
+
def _load_dhcore_oauth_vars(self, oauth_var: str) -> str | None:
|
|
363
|
+
"""
|
|
364
|
+
Load DHCore oauth variables.
|
|
365
|
+
|
|
366
|
+
Parameters
|
|
367
|
+
----------
|
|
368
|
+
oauth_var : str
|
|
369
|
+
The oauth variable to load.
|
|
370
|
+
|
|
371
|
+
Returns
|
|
372
|
+
-------
|
|
373
|
+
str
|
|
374
|
+
The oauth variable.
|
|
375
|
+
"""
|
|
376
|
+
read_var = configurator.load_from_env(oauth_var)
|
|
377
|
+
if read_var is None:
|
|
378
|
+
read_var = configurator.load_from_file(oauth_var.removeprefix("DHCORE_"))
|
|
379
|
+
return read_var
|
|
@@ -112,7 +112,7 @@ def set_current_env(environment: str) -> None:
|
|
|
112
112
|
raise ClientError(f"Failed to write env file: {e}")
|
|
113
113
|
|
|
114
114
|
|
|
115
|
-
def read_env_from_file() -> str:
|
|
115
|
+
def read_env_from_file() -> str | None:
|
|
116
116
|
"""
|
|
117
117
|
Read the current credentials set from the .dhcore.ini file.
|
|
118
118
|
|
|
@@ -124,5 +124,5 @@ def read_env_from_file() -> str:
|
|
|
124
124
|
try:
|
|
125
125
|
cfg = load_file()
|
|
126
126
|
return cfg["DEFAULT"]["current_environment"]
|
|
127
|
-
except Exception
|
|
128
|
-
|
|
127
|
+
except Exception:
|
|
128
|
+
return None
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: digitalhub
|
|
3
|
-
Version: 0.11.
|
|
3
|
+
Version: 0.11.0b3
|
|
4
4
|
Summary: Python SDK for Digitalhub
|
|
5
5
|
Project-URL: Homepage, https://github.com/scc-digitalhub/digitalhub-sdk
|
|
6
6
|
Author-email: Fondazione Bruno Kessler <dslab@fbk.eu>, Matteo Martini <mmartini@fbk.eu>
|
|
@@ -190,7 +190,7 @@ digitalhub/stores/client/_base/params_builder.py,sha256=lCk4WE6DqvGP7-cx0anZEC8G
|
|
|
190
190
|
digitalhub/stores/client/dhcore/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
191
191
|
digitalhub/stores/client/dhcore/api_builder.py,sha256=J1kOMw4B4_PZKkEs7GPNcEkd1w-ZyJeB9G1UBZiMbl0,3975
|
|
192
192
|
digitalhub/stores/client/dhcore/client.py,sha256=SdwtCZ3HsQIxzYGUI3BPbwDEeRbcdpMliQNMWMEV4MA,9890
|
|
193
|
-
digitalhub/stores/client/dhcore/configurator.py,sha256=
|
|
193
|
+
digitalhub/stores/client/dhcore/configurator.py,sha256=_U4AjS7KKEixOjaRnSfIOIbHVWa00d8BXBwBjh9ptE4,11286
|
|
194
194
|
digitalhub/stores/client/dhcore/enums.py,sha256=kaVXZTTa2WmsFbcc1CKWNLOM0JtUtcjL-KpspnTOhEE,523
|
|
195
195
|
digitalhub/stores/client/dhcore/error_parser.py,sha256=GJUUkhp12cvC_LBIrC0teh4msmyb5WFxY2g4WNOkUwM,3305
|
|
196
196
|
digitalhub/stores/client/dhcore/key_builder.py,sha256=YuSS5tRNRJTYlH14buetFSCU_bLuBBKLqMFO3MQ6r4g,1324
|
|
@@ -208,7 +208,7 @@ digitalhub/stores/configurator/api.py,sha256=-dRdkXh99SztWaeRfqztVXhT8f95aVBjDK7
|
|
|
208
208
|
digitalhub/stores/configurator/configurator.py,sha256=z9RaQ_xKm_d1S3GdrSqfbV3ikEfHg6XogQMWDL7xc84,4762
|
|
209
209
|
digitalhub/stores/configurator/credentials_store.py,sha256=kiaCm37Sl1SN9OaMbsfZA1l1a9Xg6R6a00H7Upcf8Vg,1508
|
|
210
210
|
digitalhub/stores/configurator/enums.py,sha256=3Sf6UbYWYiJK4LaDzfgS2ay8Jxh-jIzR_3WRLt6m9do,288
|
|
211
|
-
digitalhub/stores/configurator/ini_module.py,sha256=
|
|
211
|
+
digitalhub/stores/configurator/ini_module.py,sha256=VfBPFo-EVrFokDk2j9CtzstlKuxTXtsG1ro-nfTPSfs,2923
|
|
212
212
|
digitalhub/stores/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
213
213
|
digitalhub/stores/data/api.py,sha256=R-yBTWpLDrFfcFAju0PJVl0_CDROM8lV2QHKtIMwGrI,543
|
|
214
214
|
digitalhub/stores/data/builder.py,sha256=fh1JFFos7TpfgWlEWL9WmIEdrpt4t1dQU2Ivq8qE4QE,2291
|
|
@@ -250,7 +250,7 @@ digitalhub/utils/io_utils.py,sha256=8jD4Rp_b7LZEpY5JSMxVUowZsnifKnbGpHT5Hijx9-g,
|
|
|
250
250
|
digitalhub/utils/logger.py,sha256=ml3ne6D8wuRdNZ4F6ywmvWotSxjmZWnmKgNiuHb4R5M,437
|
|
251
251
|
digitalhub/utils/types.py,sha256=x8zXsbivD8vdaNeNRZLKOPvGbz6d-59nncuvO0FsueY,109
|
|
252
252
|
digitalhub/utils/uri_utils.py,sha256=wVkA2OcfHG5EcQOr9YxLJzo--VV6sjFjgXDNx-gP94I,4021
|
|
253
|
-
digitalhub-0.11.
|
|
254
|
-
digitalhub-0.11.
|
|
255
|
-
digitalhub-0.11.
|
|
256
|
-
digitalhub-0.11.
|
|
253
|
+
digitalhub-0.11.0b3.dist-info/METADATA,sha256=aaqK7yjXNErABxVJh3OMUYtufydkfo0JMljz4MYcp2E,15037
|
|
254
|
+
digitalhub-0.11.0b3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
255
|
+
digitalhub-0.11.0b3.dist-info/licenses/LICENSE.txt,sha256=qmrTTXPlgU0kSRlRVbjhlyGs1IXs2QPxo_Y-Mn06J0k,11589
|
|
256
|
+
digitalhub-0.11.0b3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|