pypomes-iam 0.3.9__py3-none-any.whl → 0.4.0__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 pypomes-iam might be problematic. Click here for more details.
- pypomes_iam/__init__.py +7 -2
- pypomes_iam/iam_common.py +0 -26
- pypomes_iam/iam_pomes.py +1 -10
- pypomes_iam/iam_services.py +54 -53
- {pypomes_iam-0.3.9.dist-info → pypomes_iam-0.4.0.dist-info}/METADATA +1 -1
- pypomes_iam-0.4.0.dist-info/RECORD +12 -0
- pypomes_iam-0.3.9.dist-info/RECORD +0 -12
- {pypomes_iam-0.3.9.dist-info → pypomes_iam-0.4.0.dist-info}/WHEEL +0 -0
- {pypomes_iam-0.3.9.dist-info → pypomes_iam-0.4.0.dist-info}/licenses/LICENSE +0 -0
pypomes_iam/__init__.py
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
from .iam_pomes import (
|
|
2
|
-
IamServer,
|
|
2
|
+
IamServer,
|
|
3
3
|
login_callback, token_exchange,
|
|
4
4
|
user_login, user_logout, user_token
|
|
5
5
|
)
|
|
6
|
+
from .iam_services import (
|
|
7
|
+
logger_register
|
|
8
|
+
)
|
|
6
9
|
from .jusbr_pomes import (
|
|
7
10
|
jusbr_setup, jusbr_get_token
|
|
8
11
|
)
|
|
@@ -18,9 +21,11 @@ from .token_pomes import (
|
|
|
18
21
|
|
|
19
22
|
__all__ = [
|
|
20
23
|
# iam_pomes
|
|
21
|
-
"IamServer",
|
|
24
|
+
"IamServer",
|
|
22
25
|
"login_callback", "token_exchange",
|
|
23
26
|
"user_login", "user_logout", "user_token",
|
|
27
|
+
# iam_services
|
|
28
|
+
"logger_register",
|
|
24
29
|
# jusbr_pomes
|
|
25
30
|
"jusbr_setup", "jusbr_get_token",
|
|
26
31
|
# keycloak_pomes
|
pypomes_iam/iam_common.py
CHANGED
|
@@ -17,10 +17,6 @@ class IamServer(StrEnum):
|
|
|
17
17
|
IAM_KEYCLOAK = "iam-keycloak"
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
# the logger for IAM service operations
|
|
21
|
-
# (used exclusively at the HTTP endpoint - all other functions receive the lgger as parameter)
|
|
22
|
-
__IAM_LOGGER: Logger | None = None
|
|
23
|
-
|
|
24
20
|
# registry structure:
|
|
25
21
|
# { <IamServer>:
|
|
26
22
|
# {
|
|
@@ -58,28 +54,6 @@ _IAM_SERVERS: Final[dict[IamServer, dict[str, Any]]] = {}
|
|
|
58
54
|
_iam_lock: Final[Lock] = Lock()
|
|
59
55
|
|
|
60
56
|
|
|
61
|
-
def _get_logger() -> Logger | None:
|
|
62
|
-
"""
|
|
63
|
-
Retrieve the registered logger for *IAM* operations.
|
|
64
|
-
|
|
65
|
-
This function is invoked exclusively from the HTTP endpoints.
|
|
66
|
-
All other functions receive the logger as parameter.
|
|
67
|
-
|
|
68
|
-
:return: the registered logger for *IAM* operations.
|
|
69
|
-
"""
|
|
70
|
-
return __IAM_LOGGER
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
def _register_logger(logger: Logger) -> None:
|
|
74
|
-
"""
|
|
75
|
-
Register the logger for *IAM* operations
|
|
76
|
-
|
|
77
|
-
:param logger: the logger to be rergistered
|
|
78
|
-
"""
|
|
79
|
-
global __IAM_LOGGER
|
|
80
|
-
__IAM_LOGGER = logger
|
|
81
|
-
|
|
82
|
-
|
|
83
57
|
def _get_public_key(iam_server: IamServer,
|
|
84
58
|
errors: list[str] | None,
|
|
85
59
|
logger: Logger | None) -> str:
|
pypomes_iam/iam_pomes.py
CHANGED
|
@@ -10,21 +10,12 @@ from typing import Any
|
|
|
10
10
|
|
|
11
11
|
from .iam_common import (
|
|
12
12
|
IamServer, _iam_lock,
|
|
13
|
-
|
|
13
|
+
_get_iam_users, _get_iam_registry,
|
|
14
14
|
_get_login_timeout, _get_user_data, _get_public_key
|
|
15
15
|
)
|
|
16
16
|
from .token_pomes import token_validate
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
def logger_register(logger: Logger) -> None:
|
|
20
|
-
"""
|
|
21
|
-
Register the logger for IAM operations.
|
|
22
|
-
|
|
23
|
-
:param logger: the logger to be registered
|
|
24
|
-
"""
|
|
25
|
-
_register_logger(logger=logger)
|
|
26
|
-
|
|
27
|
-
|
|
28
19
|
def user_login(iam_server: IamServer,
|
|
29
20
|
args: dict[str, Any],
|
|
30
21
|
errors: list[str] = None,
|
pypomes_iam/iam_services.py
CHANGED
|
@@ -3,15 +3,26 @@ from flask import Request, Response, request, jsonify
|
|
|
3
3
|
from logging import Logger
|
|
4
4
|
from typing import Any
|
|
5
5
|
|
|
6
|
-
from .iam_common import
|
|
7
|
-
IamServer, _iam_lock,
|
|
8
|
-
_get_logger, _get_iam_server
|
|
9
|
-
)
|
|
6
|
+
from .iam_common import IamServer, _iam_lock, _get_iam_server
|
|
10
7
|
from .iam_pomes import (
|
|
11
8
|
user_login, user_logout,
|
|
12
9
|
user_token, token_exchange, login_callback
|
|
13
10
|
)
|
|
14
11
|
|
|
12
|
+
# the logger for IAM service operations
|
|
13
|
+
# (used exclusively at the HTTP endpoints - all other functions receive the logger as parameter)
|
|
14
|
+
__IAM_LOGGER: Logger | None = None
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def logger_register(logger: Logger) -> None:
|
|
18
|
+
"""
|
|
19
|
+
Register the logger for HTTP services.
|
|
20
|
+
|
|
21
|
+
:param logger: the logger to be registered
|
|
22
|
+
"""
|
|
23
|
+
global __IAM_LOGGER
|
|
24
|
+
__IAM_LOGGER = logger
|
|
25
|
+
|
|
15
26
|
|
|
16
27
|
# @flask_app.route(rule=<login_endpoint>, # JUSBR_ENDPOINT_LOGIN
|
|
17
28
|
# methods=["GET"])
|
|
@@ -28,24 +39,22 @@ def service_login() -> Response:
|
|
|
28
39
|
# declare the return variable
|
|
29
40
|
result: Response | None = None
|
|
30
41
|
|
|
31
|
-
#
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
# log the request
|
|
35
|
-
logger.debug(msg=_log_init(request=request))
|
|
42
|
+
# log the request
|
|
43
|
+
if __IAM_LOGGER:
|
|
44
|
+
__IAM_LOGGER.debug(msg=_log_init(request=request))
|
|
36
45
|
|
|
37
46
|
errors: list[str] = []
|
|
38
47
|
with _iam_lock:
|
|
39
48
|
# retrieve the IAM server
|
|
40
49
|
iam_server: IamServer = _get_iam_server(endpoint=request.endpoint,
|
|
41
50
|
errors=errors,
|
|
42
|
-
logger=
|
|
51
|
+
logger=__IAM_LOGGER)
|
|
43
52
|
if iam_server:
|
|
44
53
|
# obtain the login URL
|
|
45
54
|
login_data: dict[str, str] = user_login(iam_server=iam_server,
|
|
46
55
|
args=request.args,
|
|
47
56
|
errors=errors,
|
|
48
|
-
logger=
|
|
57
|
+
logger=__IAM_LOGGER)
|
|
49
58
|
if login_data:
|
|
50
59
|
result = jsonify(login_data)
|
|
51
60
|
|
|
@@ -54,8 +63,8 @@ def service_login() -> Response:
|
|
|
54
63
|
result.status_code = 400
|
|
55
64
|
|
|
56
65
|
# log the response
|
|
57
|
-
if
|
|
58
|
-
|
|
66
|
+
if __IAM_LOGGER:
|
|
67
|
+
__IAM_LOGGER.debug(msg=f"Response {result}")
|
|
59
68
|
|
|
60
69
|
return result
|
|
61
70
|
|
|
@@ -75,24 +84,22 @@ def service_logout() -> Response:
|
|
|
75
84
|
# declare the return variable
|
|
76
85
|
result: Response | None
|
|
77
86
|
|
|
78
|
-
#
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
# log the request
|
|
82
|
-
logger.debug(msg=_log_init(request=request))
|
|
87
|
+
# log the request
|
|
88
|
+
if __IAM_LOGGER:
|
|
89
|
+
__IAM_LOGGER.debug(msg=_log_init(request=request))
|
|
83
90
|
|
|
84
91
|
errors: list[str] = []
|
|
85
92
|
with _iam_lock:
|
|
86
93
|
# retrieve the IAM server
|
|
87
94
|
iam_server: IamServer = _get_iam_server(endpoint=request.endpoint,
|
|
88
95
|
errors=errors,
|
|
89
|
-
logger=
|
|
96
|
+
logger=__IAM_LOGGER)
|
|
90
97
|
if iam_server:
|
|
91
98
|
# logout the user
|
|
92
99
|
user_logout(iam_server=iam_server,
|
|
93
100
|
args=request.args,
|
|
94
101
|
errors=errors,
|
|
95
|
-
logger=
|
|
102
|
+
logger=__IAM_LOGGER)
|
|
96
103
|
if errors:
|
|
97
104
|
result = Response("; ".join(errors))
|
|
98
105
|
result.status_code = 400
|
|
@@ -100,8 +107,8 @@ def service_logout() -> Response:
|
|
|
100
107
|
result = Response(status=204)
|
|
101
108
|
|
|
102
109
|
# log the response
|
|
103
|
-
if
|
|
104
|
-
|
|
110
|
+
if __IAM_LOGGER:
|
|
111
|
+
__IAM_LOGGER.debug(msg=f"Response {result}")
|
|
105
112
|
|
|
106
113
|
return result
|
|
107
114
|
|
|
@@ -126,11 +133,9 @@ def service_callback() -> Response:
|
|
|
126
133
|
|
|
127
134
|
:return: *Response* containing the reference user identification and the token, or *BAD REQUEST*
|
|
128
135
|
"""
|
|
129
|
-
#
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
# log the request
|
|
133
|
-
logger.debug(msg=_log_init(request=request))
|
|
136
|
+
# log the request
|
|
137
|
+
if __IAM_LOGGER:
|
|
138
|
+
__IAM_LOGGER.debug(msg=_log_init(request=request))
|
|
134
139
|
|
|
135
140
|
errors: list[str] = []
|
|
136
141
|
token_data: tuple[str, str] | None = None
|
|
@@ -138,25 +143,25 @@ def service_callback() -> Response:
|
|
|
138
143
|
# retrieve the IAM server
|
|
139
144
|
iam_server: IamServer = _get_iam_server(endpoint=request.endpoint,
|
|
140
145
|
errors=errors,
|
|
141
|
-
logger=
|
|
146
|
+
logger=__IAM_LOGGER)
|
|
142
147
|
if iam_server:
|
|
143
148
|
# process the callback operation
|
|
144
149
|
token_data = login_callback(iam_server=iam_server,
|
|
145
150
|
args=request.args,
|
|
146
151
|
errors=errors,
|
|
147
|
-
logger=
|
|
152
|
+
logger=__IAM_LOGGER)
|
|
148
153
|
result: Response
|
|
149
154
|
if errors:
|
|
150
155
|
result = jsonify({"errors": "; ".join(errors)})
|
|
151
156
|
result.status_code = 400
|
|
152
|
-
if
|
|
153
|
-
|
|
157
|
+
if __IAM_LOGGER:
|
|
158
|
+
__IAM_LOGGER.error(msg=json.dumps(obj=result))
|
|
154
159
|
else:
|
|
155
160
|
result = jsonify({"user-id": token_data[0],
|
|
156
161
|
"token": token_data[1]})
|
|
157
162
|
# log the response
|
|
158
|
-
if
|
|
159
|
-
|
|
163
|
+
if __IAM_LOGGER:
|
|
164
|
+
__IAM_LOGGER.debug(msg=f"Response {result}")
|
|
160
165
|
|
|
161
166
|
return result
|
|
162
167
|
|
|
@@ -177,11 +182,9 @@ def service_token() -> Response:
|
|
|
177
182
|
|
|
178
183
|
:return: *Response* containing the user reference identification and the token, or *BAD REQUEST*
|
|
179
184
|
"""
|
|
180
|
-
#
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
# log the request
|
|
184
|
-
logger.debug(msg=_log_init(request=request))
|
|
185
|
+
# log the request
|
|
186
|
+
if __IAM_LOGGER:
|
|
187
|
+
__IAM_LOGGER.debug(msg=_log_init(request=request))
|
|
185
188
|
|
|
186
189
|
# obtain the user's identification
|
|
187
190
|
args: dict[str, Any] = request.args
|
|
@@ -194,19 +197,19 @@ def service_token() -> Response:
|
|
|
194
197
|
# retrieve the IAM server
|
|
195
198
|
iam_server: IamServer = _get_iam_server(endpoint=request.endpoint,
|
|
196
199
|
errors=errors,
|
|
197
|
-
logger=
|
|
200
|
+
logger=__IAM_LOGGER)
|
|
198
201
|
if iam_server:
|
|
199
202
|
# retrieve the token
|
|
200
203
|
errors: list[str] = []
|
|
201
204
|
token: str = user_token(iam_server=iam_server,
|
|
202
205
|
args=args,
|
|
203
206
|
errors=errors,
|
|
204
|
-
logger=
|
|
207
|
+
logger=__IAM_LOGGER)
|
|
205
208
|
else:
|
|
206
209
|
msg: str = "User identification not provided"
|
|
207
210
|
errors.append(msg)
|
|
208
|
-
if
|
|
209
|
-
|
|
211
|
+
if __IAM_LOGGER:
|
|
212
|
+
__IAM_LOGGER.error(msg=msg)
|
|
210
213
|
|
|
211
214
|
result: Response
|
|
212
215
|
if errors:
|
|
@@ -216,8 +219,8 @@ def service_token() -> Response:
|
|
|
216
219
|
result = jsonify({"user-id": user_id,
|
|
217
220
|
"token": token})
|
|
218
221
|
# log the response
|
|
219
|
-
if
|
|
220
|
-
|
|
222
|
+
if __IAM_LOGGER:
|
|
223
|
+
__IAM_LOGGER.debug(msg=f"Response {result}")
|
|
221
224
|
|
|
222
225
|
return result
|
|
223
226
|
|
|
@@ -247,18 +250,16 @@ def service_exchange() -> Response:
|
|
|
247
250
|
|
|
248
251
|
:return: *Response* containing the token data, or *BAD REQUEST*
|
|
249
252
|
"""
|
|
250
|
-
#
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
# log the request
|
|
254
|
-
logger.debug(msg=_log_init(request=request))
|
|
253
|
+
# log the request
|
|
254
|
+
if __IAM_LOGGER:
|
|
255
|
+
__IAM_LOGGER.debug(msg=_log_init(request=request))
|
|
255
256
|
|
|
256
257
|
errors: list[str] = []
|
|
257
258
|
with _iam_lock:
|
|
258
259
|
# retrieve the IAM server (currently, only 'IAM_KEYCLOAK' is supported)
|
|
259
260
|
iam_server: IamServer = _get_iam_server(endpoint=request.endpoint,
|
|
260
261
|
errors=errors,
|
|
261
|
-
logger=
|
|
262
|
+
logger=__IAM_LOGGER)
|
|
262
263
|
# exchange the token
|
|
263
264
|
token_data: dict[str, Any] | None = None
|
|
264
265
|
if iam_server:
|
|
@@ -266,7 +267,7 @@ def service_exchange() -> Response:
|
|
|
266
267
|
token_data = token_exchange(iam_server=iam_server,
|
|
267
268
|
args=request.args,
|
|
268
269
|
errors=errors,
|
|
269
|
-
logger=
|
|
270
|
+
logger=__IAM_LOGGER)
|
|
270
271
|
result: Response
|
|
271
272
|
if errors:
|
|
272
273
|
result = Response("; ".join(errors))
|
|
@@ -275,8 +276,8 @@ def service_exchange() -> Response:
|
|
|
275
276
|
result = jsonify(token_data)
|
|
276
277
|
|
|
277
278
|
# log the response
|
|
278
|
-
if
|
|
279
|
-
|
|
279
|
+
if __IAM_LOGGER:
|
|
280
|
+
__IAM_LOGGER.debug(msg=f"Response {result}")
|
|
280
281
|
|
|
281
282
|
return result
|
|
282
283
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pypomes_iam
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
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
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
pypomes_iam/__init__.py,sha256=KX_QLdqAD-dNUl3G1mDeutxL9e58S9OsMoJlrgM9R28,1027
|
|
2
|
+
pypomes_iam/iam_common.py,sha256=qFX_Fv-NbFvQomTid0bTVImlRuMt6s7cqBLVL4CHF_Y,9327
|
|
3
|
+
pypomes_iam/iam_pomes.py,sha256=s0bvf4zAt4-zZbfPw7Y_nACEK50Qq4ZDhEleEHbiWO8,23748
|
|
4
|
+
pypomes_iam/iam_services.py,sha256=81GrfIg-Hc_lK4BAotSkfopzSzkmuRce_aPNKdvyNnI,10612
|
|
5
|
+
pypomes_iam/jusbr_pomes.py,sha256=G-COBstBeQeD7dPgvf2MI1E8r2-ACHHwzhyfsphhKgw,5758
|
|
6
|
+
pypomes_iam/keycloak_pomes.py,sha256=JxVVFdhXJypK5x9ocn7283pB1xJbS-yPgStkSFS12HM,6775
|
|
7
|
+
pypomes_iam/provider_pomes.py,sha256=3Rui68hmj8zwY0tnw4aWurz-yQ-niacJFQpi6nWzh-M,6355
|
|
8
|
+
pypomes_iam/token_pomes.py,sha256=1g6PMNNMbmdwLrsvSXvpO8-zdRhso1IFnwAyndNmV4Q,5332
|
|
9
|
+
pypomes_iam-0.4.0.dist-info/METADATA,sha256=s-mJs59CXX3DLWclmDvP-MDZCKnVI8I7ZR6hthh5fWU,694
|
|
10
|
+
pypomes_iam-0.4.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
11
|
+
pypomes_iam-0.4.0.dist-info/licenses/LICENSE,sha256=YvUELgV8qvXlaYsy9hXG5EW3Bmsrkw-OJmmILZnonAc,1086
|
|
12
|
+
pypomes_iam-0.4.0.dist-info/RECORD,,
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
pypomes_iam/__init__.py,sha256=vl7Frit5Xte3deOSwBSkg462lIhirwU0Rb0QMY3X2pM,965
|
|
2
|
-
pypomes_iam/iam_common.py,sha256=f74FUDcnMM2cgzJg-AF17GwCKwbfoezS8LppwxYwPys,10049
|
|
3
|
-
pypomes_iam/iam_pomes.py,sha256=Qlg78xv4e1WJSX2CMNluZRnHov6lqabeD45-bJ2JZSM,23966
|
|
4
|
-
pypomes_iam/iam_services.py,sha256=xs0y0FUBTDiVu_B_kP900Kp1D77wyphUBxb_-QlD07Y,10445
|
|
5
|
-
pypomes_iam/jusbr_pomes.py,sha256=G-COBstBeQeD7dPgvf2MI1E8r2-ACHHwzhyfsphhKgw,5758
|
|
6
|
-
pypomes_iam/keycloak_pomes.py,sha256=JxVVFdhXJypK5x9ocn7283pB1xJbS-yPgStkSFS12HM,6775
|
|
7
|
-
pypomes_iam/provider_pomes.py,sha256=3Rui68hmj8zwY0tnw4aWurz-yQ-niacJFQpi6nWzh-M,6355
|
|
8
|
-
pypomes_iam/token_pomes.py,sha256=1g6PMNNMbmdwLrsvSXvpO8-zdRhso1IFnwAyndNmV4Q,5332
|
|
9
|
-
pypomes_iam-0.3.9.dist-info/METADATA,sha256=fvTKxq9nwZGvQAcE0uQxMa9BLjgZomapgkn6OwplsWk,694
|
|
10
|
-
pypomes_iam-0.3.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
11
|
-
pypomes_iam-0.3.9.dist-info/licenses/LICENSE,sha256=YvUELgV8qvXlaYsy9hXG5EW3Bmsrkw-OJmmILZnonAc,1086
|
|
12
|
-
pypomes_iam-0.3.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|