pypomes-iam 0.0.3__tar.gz → 0.0.4__tar.gz
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 pypomes-iam might be problematic. Click here for more details.
- {pypomes_iam-0.0.3 → pypomes_iam-0.0.4}/PKG-INFO +1 -1
- {pypomes_iam-0.0.3 → pypomes_iam-0.0.4}/pyproject.toml +1 -1
- {pypomes_iam-0.0.3 → pypomes_iam-0.0.4}/src/pypomes_iam/iam_jusbr.py +22 -12
- {pypomes_iam-0.0.3 → pypomes_iam-0.0.4}/.gitignore +0 -0
- {pypomes_iam-0.0.3 → pypomes_iam-0.0.4}/LICENSE +0 -0
- {pypomes_iam-0.0.3 → pypomes_iam-0.0.4}/README.md +0 -0
- {pypomes_iam-0.0.3 → pypomes_iam-0.0.4}/src/pypomes_iam/__init__.py +0 -0
- {pypomes_iam-0.0.3 → pypomes_iam-0.0.4}/src/pypomes_iam/iam_provider.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pypomes_iam
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.4
|
|
4
4
|
Summary: A collection of Python pomes, penyeach (IAM modules)
|
|
5
5
|
Project-URL: Homepage, https://github.com/TheWiseCoder/PyPomes-IAM
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/TheWiseCoder/PyPomes-IAM/issues
|
|
@@ -379,9 +379,17 @@ def __post_jusbr(user_data: dict[str, Any],
|
|
|
379
379
|
errors: list[str] | None,
|
|
380
380
|
logger: Logger | None) -> None:
|
|
381
381
|
"""
|
|
382
|
-
Send a POST request to JusBR to obtain the
|
|
382
|
+
Send a POST request to JusBR to obtain the authentication tokens.
|
|
383
383
|
|
|
384
|
-
|
|
384
|
+
For code for token exchange, *body_data* will have the attributes
|
|
385
|
+
- "grant_type": "authorization_code"
|
|
386
|
+
- "code": <16-character-random-code>
|
|
387
|
+
- "redirect_url": <callback-url>
|
|
388
|
+
For token refresh, *body_data* will have the attributes
|
|
389
|
+
- "grant_type": "refresh_token"
|
|
390
|
+
- "refresh_token": <current-refresh-token>
|
|
391
|
+
|
|
392
|
+
If the operation is successful, the token data is stored in the registry.
|
|
385
393
|
Otherwise, *errors* will contain the appropriate error message.
|
|
386
394
|
|
|
387
395
|
:param user_data: the user's data in the registry
|
|
@@ -411,28 +419,30 @@ def __post_jusbr(user_data: dict[str, Any],
|
|
|
411
419
|
# }
|
|
412
420
|
response: requests.Response = requests.post(url=url,
|
|
413
421
|
data=body_data)
|
|
414
|
-
if response.status_code
|
|
415
|
-
# request
|
|
416
|
-
err_msg = (f"POST '{url}': failed, "
|
|
417
|
-
f"status {response.status_code}, reason '{response.reason}'")
|
|
418
|
-
if response.status_code == 401 and "refresh_token" in body_data:
|
|
419
|
-
# refresh token is no longer valid
|
|
420
|
-
safe_cache["refresh-token"] = None
|
|
421
|
-
else:
|
|
422
|
+
if response.status_code == 200:
|
|
423
|
+
# request succeeded
|
|
422
424
|
reply: dict[str, Any] = response.json()
|
|
423
425
|
result = reply.get("access_token")
|
|
424
426
|
safe_cache: Cache = FIFOCache(maxsize=1024)
|
|
425
427
|
safe_cache["access-token"] = result
|
|
426
|
-
|
|
428
|
+
# on token refresh, keep current refresh token if a new one is not provided
|
|
429
|
+
safe_cache["refresh-token"] = reply.get("refresh_token") or body_data.get("refresh_token")
|
|
427
430
|
user_data["cache-obj"] = safe_cache
|
|
428
431
|
user_data["access-expiration"] = now + reply.get("expires_in")
|
|
429
432
|
if logger:
|
|
430
433
|
logger.debug(msg=f"POST '{url}': status {response.status_code}")
|
|
434
|
+
else:
|
|
435
|
+
# request resulted in error
|
|
436
|
+
err_msg = (f"POST '{url}': failed, "
|
|
437
|
+
f"status {response.status_code}, reason '{response.reason}'")
|
|
438
|
+
if response.status_code == 401 and "refresh_token" in body_data:
|
|
439
|
+
# refresh token is no longer valid
|
|
440
|
+
safe_cache["refresh-token"] = None
|
|
431
441
|
except Exception as e:
|
|
432
442
|
# the operation raised an exception
|
|
433
443
|
err_msg = exc_format(exc=e,
|
|
434
444
|
exc_info=sys.exc_info())
|
|
435
|
-
err_msg = f"POST '{url}': error
|
|
445
|
+
err_msg = f"POST '{url}': error '{err_msg}'"
|
|
436
446
|
|
|
437
447
|
if err_msg:
|
|
438
448
|
if isinstance(errors, list):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|