pypomes-iam 0.1.6__tar.gz → 0.1.7__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.1.6 → pypomes_iam-0.1.7}/PKG-INFO +1 -1
- {pypomes_iam-0.1.6 → pypomes_iam-0.1.7}/pyproject.toml +1 -1
- {pypomes_iam-0.1.6 → pypomes_iam-0.1.7}/src/pypomes_iam/jusbr_pomes.py +53 -7
- {pypomes_iam-0.1.6 → pypomes_iam-0.1.7}/.gitignore +0 -0
- {pypomes_iam-0.1.6 → pypomes_iam-0.1.7}/LICENSE +0 -0
- {pypomes_iam-0.1.6 → pypomes_iam-0.1.7}/README.md +0 -0
- {pypomes_iam-0.1.6 → pypomes_iam-0.1.7}/src/pypomes_iam/__init__.py +0 -0
- {pypomes_iam-0.1.6 → pypomes_iam-0.1.7}/src/pypomes_iam/keycloak_pomes.py +0 -0
- {pypomes_iam-0.1.6 → pypomes_iam-0.1.7}/src/pypomes_iam/provider_pomes.py +0 -0
- {pypomes_iam-0.1.6 → pypomes_iam-0.1.7}/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.1.
|
|
3
|
+
Version: 0.1.7
|
|
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
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import json
|
|
1
2
|
import requests
|
|
2
3
|
import secrets
|
|
3
4
|
import string
|
|
4
5
|
import sys
|
|
5
6
|
from cachetools import Cache, FIFOCache, TTLCache
|
|
6
7
|
from datetime import datetime
|
|
7
|
-
from flask import Flask, Response, redirect, request, jsonify
|
|
8
|
+
from flask import Flask, Request, Response, redirect, request, jsonify
|
|
8
9
|
from logging import Logger
|
|
9
10
|
from pypomes_core import (
|
|
10
11
|
APP_PREFIX, TZ_LOCAL, env_get_int, env_get_str, exc_format
|
|
@@ -138,6 +139,11 @@ def service_login() -> Response:
|
|
|
138
139
|
"""
|
|
139
140
|
global _jusbr_registry
|
|
140
141
|
|
|
142
|
+
# log the request
|
|
143
|
+
if _logger:
|
|
144
|
+
msg: str = __log_init(request=request)
|
|
145
|
+
_logger.debug(msg=msg)
|
|
146
|
+
|
|
141
147
|
# retrieve user data (if not provided, 'user_id' is temporarily set to 'oauth_state'
|
|
142
148
|
input_params: dict[str, Any] = request.values
|
|
143
149
|
oauth_state: str = "".join(secrets.choice(string.ascii_letters + string.digits) for _ in range(16))
|
|
@@ -162,8 +168,14 @@ def service_login() -> Response:
|
|
|
162
168
|
if user_data.get("oauth-scope"):
|
|
163
169
|
auth_url += f"&scope={user_data.get("oauth-scope")}"
|
|
164
170
|
|
|
165
|
-
# redirect request
|
|
166
|
-
|
|
171
|
+
# redirect the request
|
|
172
|
+
result: Response = redirect(location=auth_url)
|
|
173
|
+
|
|
174
|
+
# log the response
|
|
175
|
+
if _logger:
|
|
176
|
+
_logger.debug(msg=f"Response {result}")
|
|
177
|
+
|
|
178
|
+
return result
|
|
167
179
|
|
|
168
180
|
|
|
169
181
|
# @flask_app.route(rule=<login_endpoint>, # JUSBR_LOGIN_ENDPOINT: /iam/jusbr:logout
|
|
@@ -178,6 +190,11 @@ def service_logout() -> Response:
|
|
|
178
190
|
"""
|
|
179
191
|
global _jusbr_registry
|
|
180
192
|
|
|
193
|
+
# log the request
|
|
194
|
+
if _logger:
|
|
195
|
+
msg: str = __log_init(request=request)
|
|
196
|
+
_logger.debug(msg=msg)
|
|
197
|
+
|
|
181
198
|
# retrieve user id
|
|
182
199
|
input_params: dict[str, Any] = request.args
|
|
183
200
|
user_id: str = input_params.get("user-id") or input_params.get("login")
|
|
@@ -188,7 +205,13 @@ def service_logout() -> Response:
|
|
|
188
205
|
if _logger:
|
|
189
206
|
_logger.debug(f"User '{user_id}' removed from the registry")
|
|
190
207
|
|
|
191
|
-
|
|
208
|
+
result: Response = Response(status=200)
|
|
209
|
+
|
|
210
|
+
# log the response
|
|
211
|
+
if _logger:
|
|
212
|
+
_logger.debug(msg=f"Response {result}")
|
|
213
|
+
|
|
214
|
+
return result
|
|
192
215
|
|
|
193
216
|
|
|
194
217
|
# @flask_app.route(rule=<callback_endpoint>, # JUSBR_CALLBACK_ENDPOINT: /iam/jusbr:callback
|
|
@@ -202,6 +225,11 @@ def service_callback() -> Response:
|
|
|
202
225
|
global _jusbr_registry
|
|
203
226
|
from .token_pomes import token_validate
|
|
204
227
|
|
|
228
|
+
# log the request
|
|
229
|
+
if _logger:
|
|
230
|
+
msg: str = __log_init(request=request)
|
|
231
|
+
_logger.debug(msg=msg)
|
|
232
|
+
|
|
205
233
|
# validate the OAuth2 state
|
|
206
234
|
oauth_state: str = request.args.get("state")
|
|
207
235
|
user_id: str | None = None
|
|
@@ -260,6 +288,10 @@ def service_callback() -> Response:
|
|
|
260
288
|
"user_id": user_id,
|
|
261
289
|
"access_token": token})
|
|
262
290
|
|
|
291
|
+
# log the response
|
|
292
|
+
if _logger:
|
|
293
|
+
_logger.debug(msg=f"Response {result}")
|
|
294
|
+
|
|
263
295
|
return result
|
|
264
296
|
|
|
265
297
|
|
|
@@ -271,11 +303,14 @@ def service_token() -> Response:
|
|
|
271
303
|
|
|
272
304
|
:return: the response containing the token, or *UNAUTHORIZED*
|
|
273
305
|
"""
|
|
274
|
-
#
|
|
275
|
-
|
|
276
|
-
|
|
306
|
+
# log the request
|
|
307
|
+
if _logger:
|
|
308
|
+
msg: str = __log_init(request=request)
|
|
309
|
+
_logger.debug(msg=msg)
|
|
277
310
|
|
|
278
311
|
# retrieve the token
|
|
312
|
+
input_params: dict[str, Any] = request.args
|
|
313
|
+
user_id: str = input_params.get("user-id") or input_params.get("login")
|
|
279
314
|
errors: list[str] = []
|
|
280
315
|
token: str = jusbr_get_token(user_id=user_id,
|
|
281
316
|
logger=_logger)
|
|
@@ -286,6 +321,10 @@ def service_token() -> Response:
|
|
|
286
321
|
result = Response("; ".join(errors))
|
|
287
322
|
result.status_code = 401
|
|
288
323
|
|
|
324
|
+
# log the response
|
|
325
|
+
if _logger:
|
|
326
|
+
_logger.debug(msg=f"Response {result}")
|
|
327
|
+
|
|
289
328
|
return result
|
|
290
329
|
|
|
291
330
|
|
|
@@ -513,3 +552,10 @@ def __post_jusbr(user_data: dict[str, Any],
|
|
|
513
552
|
logger.error(msg=err_msg)
|
|
514
553
|
|
|
515
554
|
return result
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
def __log_init(request: Request) -> str:
|
|
558
|
+
|
|
559
|
+
params: str = json.dumps(obj=request.args,
|
|
560
|
+
ensure_ascii=False)
|
|
561
|
+
return f"Request {request.method}:{request.path}, params {params}"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|