pypomes-iam 0.4.4__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pypomes_iam
3
- Version: 0.4.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
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
6
6
 
7
7
  [project]
8
8
  name = "pypomes_iam"
9
- version = "0.4.4"
9
+ version = "0.4.5"
10
10
  authors = [
11
11
  { name="GT Nunes", email="wisecoder01@gmail.com" }
12
12
  ]
@@ -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
- # "login-expiration": <timestamp>, <-- transient
45
- # "login-id": <str>, <-- transient
43
+ # # transient attributes:
44
+ # "login-expiration": <timestamp>,
45
+ # "login-id": <str>,
46
+ # "redirect-uri": <str>
46
47
  # }
47
48
  # },
48
49
  # ...
@@ -62,13 +62,13 @@ def user_login(iam_server: IamServer,
62
62
  user_data["login-expiration"] = int(datetime.now(tz=TZ_LOCAL).timestamp()) + timeout \
63
63
  if timeout else None
64
64
  redirect_uri: str = args.get("redirect-uri")
65
+ user_data["redirect-uri"] = redirect_uri
65
66
 
66
67
  # build the login url
67
68
  registry: dict[str, Any] = _get_iam_registry(iam_server=iam_server,
68
69
  errors=errors,
69
70
  logger=logger)
70
71
  if registry:
71
- registry["redirect-uri"] = redirect_uri
72
72
  result = (f"{registry["base-url"]}/protocol/openid-connect/auth"
73
73
  f"?response_type=code&scope=openid"
74
74
  f"&client_id={registry["client-id"]}"
@@ -203,7 +203,7 @@ def login_callback(iam_server: IamServer,
203
203
 
204
204
  The relevant expected arguments in *args* are:
205
205
  - *state*: used to enhance security during the authorization process, typically to provide *CSRF* protection
206
- - *code*: the temporary authorization code, to be exchanged for the token
206
+ - *code*: the temporary authorization code provided by *iam_server*, to be exchanged for the token
207
207
 
208
208
  :param iam_server: the reference registered *IAM* server
209
209
  :param args: the arguments passed when requesting the service
@@ -215,11 +215,10 @@ def login_callback(iam_server: IamServer,
215
215
  result: tuple[str, str] | None = None
216
216
 
217
217
  with _iam_lock:
218
- # retrieve the IAM server's registry and the data for all users therein
219
- registry: dict[str, Any] = _get_iam_registry(iam_server=iam_server,
220
- errors=errors,
221
- logger=logger)
222
- 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 {}
223
222
  # retrieve the OAuth2 state
224
223
  oauth_state: str = args.get("state")
225
224
  user_data: dict[str, Any] | None = None
@@ -240,7 +239,7 @@ def login_callback(iam_server: IamServer,
240
239
  body_data: dict[str, Any] = {
241
240
  "grant_type": "authorization_code",
242
241
  "code": code,
243
- "redirect_uri": registry["redirect-uri"]
242
+ "redirect_uri": user_data["redirect-uri"]
244
243
  }
245
244
  now: int = int(datetime.now(tz=TZ_LOCAL).timestamp())
246
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