pypomes-iam 0.4.3__tar.gz → 0.4.5__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.
- {pypomes_iam-0.4.3 → pypomes_iam-0.4.5}/PKG-INFO +1 -1
- {pypomes_iam-0.4.3 → pypomes_iam-0.4.5}/pyproject.toml +1 -1
- {pypomes_iam-0.4.3 → pypomes_iam-0.4.5}/src/pypomes_iam/iam_common.py +5 -4
- {pypomes_iam-0.4.3 → pypomes_iam-0.4.5}/src/pypomes_iam/iam_pomes.py +12 -14
- {pypomes_iam-0.4.3 → pypomes_iam-0.4.5}/src/pypomes_iam/iam_services.py +5 -5
- {pypomes_iam-0.4.3 → pypomes_iam-0.4.5}/.gitignore +0 -0
- {pypomes_iam-0.4.3 → pypomes_iam-0.4.5}/LICENSE +0 -0
- {pypomes_iam-0.4.3 → pypomes_iam-0.4.5}/README.md +0 -0
- {pypomes_iam-0.4.3 → pypomes_iam-0.4.5}/src/pypomes_iam/__init__.py +0 -0
- {pypomes_iam-0.4.3 → pypomes_iam-0.4.5}/src/pypomes_iam/jusbr_pomes.py +0 -0
- {pypomes_iam-0.4.3 → pypomes_iam-0.4.5}/src/pypomes_iam/keycloak_pomes.py +0 -0
- {pypomes_iam-0.4.3 → pypomes_iam-0.4.5}/src/pypomes_iam/provider_pomes.py +0 -0
- {pypomes_iam-0.4.3 → pypomes_iam-0.4.5}/src/pypomes_iam/token_pomes.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pypomes_iam
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.5
|
|
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
|
|
@@ -28,8 +28,7 @@ class IamServer(StrEnum):
|
|
|
28
28
|
# "pk-lifetime": <int>,
|
|
29
29
|
# "pk-expiration": <int>,
|
|
30
30
|
# "base-url": <str>,
|
|
31
|
-
# "cache": <FIFOCache
|
|
32
|
-
# "redirect-uri": <str> <-- transient
|
|
31
|
+
# "cache": <FIFOCache>
|
|
33
32
|
# },
|
|
34
33
|
# ...
|
|
35
34
|
# }
|
|
@@ -41,8 +40,10 @@ class IamServer(StrEnum):
|
|
|
41
40
|
# "refresh-token": <str>
|
|
42
41
|
# "access-expiration": <timestamp>,
|
|
43
42
|
# "refresh-expiration": <timestamp>,
|
|
44
|
-
#
|
|
45
|
-
# "login-
|
|
43
|
+
# # transient attributes:
|
|
44
|
+
# "login-expiration": <timestamp>,
|
|
45
|
+
# "login-id": <str>,
|
|
46
|
+
# "redirect-uri": <str>
|
|
46
47
|
# }
|
|
47
48
|
# },
|
|
48
49
|
# ...
|
|
@@ -5,7 +5,6 @@ import string
|
|
|
5
5
|
import sys
|
|
6
6
|
from datetime import datetime
|
|
7
7
|
from logging import Logger
|
|
8
|
-
from urllib import parse
|
|
9
8
|
from pypomes_core import TZ_LOCAL, exc_format
|
|
10
9
|
from typing import Any
|
|
11
10
|
|
|
@@ -63,18 +62,18 @@ def user_login(iam_server: IamServer,
|
|
|
63
62
|
user_data["login-expiration"] = int(datetime.now(tz=TZ_LOCAL).timestamp()) + timeout \
|
|
64
63
|
if timeout else None
|
|
65
64
|
redirect_uri: str = args.get("redirect-uri")
|
|
65
|
+
user_data["redirect-uri"] = redirect_uri
|
|
66
66
|
|
|
67
67
|
# build the login url
|
|
68
68
|
registry: dict[str, Any] = _get_iam_registry(iam_server=iam_server,
|
|
69
69
|
errors=errors,
|
|
70
70
|
logger=logger)
|
|
71
71
|
if registry:
|
|
72
|
-
registry["
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
f"&state={oauth_state}")
|
|
72
|
+
result = (f"{registry["base-url"]}/protocol/openid-connect/auth"
|
|
73
|
+
f"?response_type=code&scope=openid"
|
|
74
|
+
f"&client_id={registry["client-id"]}"
|
|
75
|
+
f"&redirect_uri={redirect_uri}"
|
|
76
|
+
f"&state={oauth_state}")
|
|
78
77
|
return result
|
|
79
78
|
|
|
80
79
|
|
|
@@ -204,7 +203,7 @@ def login_callback(iam_server: IamServer,
|
|
|
204
203
|
|
|
205
204
|
The relevant expected arguments in *args* are:
|
|
206
205
|
- *state*: used to enhance security during the authorization process, typically to provide *CSRF* protection
|
|
207
|
-
- *code*: the temporary authorization code
|
|
206
|
+
- *code*: the temporary authorization code provided by *iam_server*, to be exchanged for the token
|
|
208
207
|
|
|
209
208
|
:param iam_server: the reference registered *IAM* server
|
|
210
209
|
:param args: the arguments passed when requesting the service
|
|
@@ -216,11 +215,10 @@ def login_callback(iam_server: IamServer,
|
|
|
216
215
|
result: tuple[str, str] | None = None
|
|
217
216
|
|
|
218
217
|
with _iam_lock:
|
|
219
|
-
# retrieve the IAM server's
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
users: dict[str, dict[str, Any]] = (registry["cache"]["users"] or {}) if registry else {}
|
|
218
|
+
# retrieve the IAM server's data for all users
|
|
219
|
+
users: dict[str, dict[str, Any]] = _get_iam_users(iam_server=iam_server,
|
|
220
|
+
errors=errors,
|
|
221
|
+
logger=logger) or {}
|
|
224
222
|
# retrieve the OAuth2 state
|
|
225
223
|
oauth_state: str = args.get("state")
|
|
226
224
|
user_data: dict[str, Any] | None = None
|
|
@@ -241,7 +239,7 @@ def login_callback(iam_server: IamServer,
|
|
|
241
239
|
body_data: dict[str, Any] = {
|
|
242
240
|
"grant_type": "authorization_code",
|
|
243
241
|
"code": code,
|
|
244
|
-
"redirect_uri":
|
|
242
|
+
"redirect_uri": user_data["redirect-uri"]
|
|
245
243
|
}
|
|
246
244
|
now: int = int(datetime.now(tz=TZ_LOCAL).timestamp())
|
|
247
245
|
token_data: dict[str, Any] = __post_for_token(iam_server=iam_server,
|
|
@@ -72,7 +72,7 @@ def service_login() -> Response:
|
|
|
72
72
|
|
|
73
73
|
# log the response
|
|
74
74
|
if __IAM_LOGGER:
|
|
75
|
-
__IAM_LOGGER.debug(msg=f"Response {result}")
|
|
75
|
+
__IAM_LOGGER.debug(msg=f"Response {result}, {result.get_data(as_text=True)}")
|
|
76
76
|
|
|
77
77
|
return result
|
|
78
78
|
|
|
@@ -137,7 +137,7 @@ def service_callback() -> Response:
|
|
|
137
137
|
|
|
138
138
|
The relevant expected request arguments are:
|
|
139
139
|
- *state*: used to enhance security during the authorization process, typically to provide *CSRF* protection
|
|
140
|
-
- *code*: the temporary authorization code, to be exchanged for the token
|
|
140
|
+
- *code*: the temporary authorization code provided by the IAM server, to be exchanged for the token
|
|
141
141
|
|
|
142
142
|
On success, the returned *Response* will contain the following JSON:
|
|
143
143
|
{
|
|
@@ -173,7 +173,7 @@ def service_callback() -> Response:
|
|
|
173
173
|
"token": token_data[1]})
|
|
174
174
|
# log the response
|
|
175
175
|
if __IAM_LOGGER:
|
|
176
|
-
__IAM_LOGGER.debug(msg=f"Response {result}")
|
|
176
|
+
__IAM_LOGGER.debug(msg=f"Response {result}, {result.get_data(as_text=True)}")
|
|
177
177
|
|
|
178
178
|
return result
|
|
179
179
|
|
|
@@ -234,7 +234,7 @@ def service_token() -> Response:
|
|
|
234
234
|
"token": token})
|
|
235
235
|
# log the response
|
|
236
236
|
if __IAM_LOGGER:
|
|
237
|
-
__IAM_LOGGER.debug(msg=f"Response {result}")
|
|
237
|
+
__IAM_LOGGER.debug(msg=f"Response {result}, {result.get_data(as_text=True)}")
|
|
238
238
|
|
|
239
239
|
return result
|
|
240
240
|
|
|
@@ -291,7 +291,7 @@ def service_exchange() -> Response:
|
|
|
291
291
|
|
|
292
292
|
# log the response
|
|
293
293
|
if __IAM_LOGGER:
|
|
294
|
-
__IAM_LOGGER.debug(msg=f"Response {result}")
|
|
294
|
+
__IAM_LOGGER.debug(msg=f"Response {result}, {result.get_data(as_text=True)}")
|
|
295
295
|
|
|
296
296
|
return result
|
|
297
297
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|