pypomes-iam 0.2.0__py3-none-any.whl → 0.2.1__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 +4 -4
- pypomes_iam/common_pomes.py +2 -28
- pypomes_iam/jusbr_pomes.py +1 -24
- pypomes_iam/keycloak_pomes.py +1 -24
- {pypomes_iam-0.2.0.dist-info → pypomes_iam-0.2.1.dist-info}/METADATA +1 -1
- pypomes_iam-0.2.1.dist-info/RECORD +11 -0
- pypomes_iam-0.2.0.dist-info/RECORD +0 -11
- {pypomes_iam-0.2.0.dist-info → pypomes_iam-0.2.1.dist-info}/WHEEL +0 -0
- {pypomes_iam-0.2.0.dist-info → pypomes_iam-0.2.1.dist-info}/licenses/LICENSE +0 -0
pypomes_iam/__init__.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
from .jusbr_pomes import (
|
|
2
|
-
jusbr_setup, jusbr_get_token
|
|
2
|
+
jusbr_setup, jusbr_get_token
|
|
3
3
|
)
|
|
4
4
|
from .keycloak_pomes import (
|
|
5
|
-
keycloak_setup, keycloak_get_token
|
|
5
|
+
keycloak_setup, keycloak_get_token
|
|
6
6
|
)
|
|
7
7
|
from .provider_pomes import (
|
|
8
8
|
provider_register, provider_get_token
|
|
@@ -13,9 +13,9 @@ from .token_pomes import (
|
|
|
13
13
|
|
|
14
14
|
__all__ = [
|
|
15
15
|
# jusbr_pomes
|
|
16
|
-
"jusbr_setup", "jusbr_get_token",
|
|
16
|
+
"jusbr_setup", "jusbr_get_token",
|
|
17
17
|
# keycloak_pomes
|
|
18
|
-
"keycloak_setup", "keycloak_get_token",
|
|
18
|
+
"keycloak_setup", "keycloak_get_token",
|
|
19
19
|
# provider_pomes
|
|
20
20
|
"provider_register", "provider_get_token",
|
|
21
21
|
# token_pomes
|
pypomes_iam/common_pomes.py
CHANGED
|
@@ -31,7 +31,6 @@ from typing import Any
|
|
|
31
31
|
# "access-expiration": <timestamp>,
|
|
32
32
|
# "login-expiration": <timestamp>, <-- transient
|
|
33
33
|
# "login-id": <str>, <-- transient
|
|
34
|
-
# "oauth-scope": <str> <-- optional
|
|
35
34
|
# }
|
|
36
35
|
# }
|
|
37
36
|
# }
|
|
@@ -132,15 +131,11 @@ def _service_login(registry: dict[str, Any],
|
|
|
132
131
|
user_data["login-expiration"] = int(datetime.now(tz=TZ_LOCAL).timestamp()) + timeout if timeout else None
|
|
133
132
|
|
|
134
133
|
# build the redirect url
|
|
135
|
-
result: str = (f"{registry["base-url"]}/protocol/openid-connect/auth
|
|
134
|
+
result: str = (f"{registry["base-url"]}/protocol/openid-connect/auth"
|
|
135
|
+
f"?response_type=code&scope=openid"
|
|
136
136
|
f"&client_id={registry["client-id"]}"
|
|
137
137
|
f"&redirect_uri={registry["callback-url"]}"
|
|
138
138
|
f"&state={oauth_state}")
|
|
139
|
-
scope: str = _get_user_scope(registry=registry,
|
|
140
|
-
user_id=user_id)
|
|
141
|
-
if scope:
|
|
142
|
-
user_data["oauth-scope"] = scope
|
|
143
|
-
result += f"&scope={scope}"
|
|
144
139
|
|
|
145
140
|
# logout the user
|
|
146
141
|
_service_logout(registry=registry,
|
|
@@ -304,27 +299,6 @@ def _get_user_data(registry: dict[str, Any],
|
|
|
304
299
|
return result
|
|
305
300
|
|
|
306
301
|
|
|
307
|
-
def _get_user_scope(registry: dict[str, Any],
|
|
308
|
-
user_id: str) -> str | None:
|
|
309
|
-
"""
|
|
310
|
-
Retrieve the OAuth2 scope associated with *user_id*.
|
|
311
|
-
|
|
312
|
-
:param registry: the registry holding the authentication data
|
|
313
|
-
:param user_id:
|
|
314
|
-
:return: the OAuth2 scope associated with *user_id*, or *None* if it does not exist
|
|
315
|
-
"""
|
|
316
|
-
# initialize the return variable
|
|
317
|
-
result: str | None = None
|
|
318
|
-
|
|
319
|
-
if user_id:
|
|
320
|
-
cache: Cache = registry["safe-cache"]
|
|
321
|
-
users: dict[str, dict[str, Any]] = cache.get("users")
|
|
322
|
-
if user_id in users:
|
|
323
|
-
result = users[user_id].get("oauth2-scope")
|
|
324
|
-
|
|
325
|
-
return result
|
|
326
|
-
|
|
327
|
-
|
|
328
302
|
def _post_for_token(registry: dict[str, Any],
|
|
329
303
|
user_data: dict[str, Any],
|
|
330
304
|
body_data: dict[str, Any],
|
pypomes_iam/jusbr_pomes.py
CHANGED
|
@@ -7,7 +7,7 @@ from pypomes_core import (
|
|
|
7
7
|
)
|
|
8
8
|
from typing import Any, Final
|
|
9
9
|
|
|
10
|
-
from .common_pomes import _service_token
|
|
10
|
+
from .common_pomes import _service_token
|
|
11
11
|
|
|
12
12
|
JUSBR_CLIENT_ID: Final[str] = env_get_str(key=f"{APP_PREFIX}_JUSBR_CLIENT_ID")
|
|
13
13
|
JUSBR_CLIENT_SECRET: Final[str] = env_get_str(key=f"{APP_PREFIX}_JUSBR_CLIENT_SECRET")
|
|
@@ -48,7 +48,6 @@ JUSBR_URL_AUTH_CALLBACK: Final[str] = env_get_str(key=f"{APP_PREFIX}_JUSBR_URL_A
|
|
|
48
48
|
# "access-expiration": <timestamp>,
|
|
49
49
|
# "login-expiration": <timestamp>, <-- transient
|
|
50
50
|
# "login-id": <str>, <-- transient
|
|
51
|
-
# "oauth-scope": <str> <-- optional
|
|
52
51
|
# }
|
|
53
52
|
# }
|
|
54
53
|
# }
|
|
@@ -148,25 +147,3 @@ def jusbr_get_token(user_id: str,
|
|
|
148
147
|
args=args,
|
|
149
148
|
errors=errors,
|
|
150
149
|
logger=logger)
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
def jusbr_set_scope(user_id: str,
|
|
154
|
-
scope: str,
|
|
155
|
-
logger: Logger = None) -> None:
|
|
156
|
-
"""
|
|
157
|
-
Set the OAuth2 scope of *user_id* to *scope*.
|
|
158
|
-
|
|
159
|
-
:param user_id: the user's identification
|
|
160
|
-
:param scope: the OAuth2 scope to set to the user
|
|
161
|
-
:param logger: optional logger
|
|
162
|
-
"""
|
|
163
|
-
global _jusbr_registry
|
|
164
|
-
|
|
165
|
-
# retrieve user data
|
|
166
|
-
user_data: dict[str, Any] = _get_user_data(registry=_jusbr_registry,
|
|
167
|
-
user_id=user_id,
|
|
168
|
-
logger=logger)
|
|
169
|
-
# set the OAuth2 scope
|
|
170
|
-
user_data["oauth-scope"] = scope
|
|
171
|
-
if logger:
|
|
172
|
-
logger.debug(msg=f"Scope for user '{user_id}' set to '{scope}'")
|
pypomes_iam/keycloak_pomes.py
CHANGED
|
@@ -7,7 +7,7 @@ from pypomes_core import (
|
|
|
7
7
|
)
|
|
8
8
|
from typing import Any, Final
|
|
9
9
|
|
|
10
|
-
from .common_pomes import _service_token
|
|
10
|
+
from .common_pomes import _service_token
|
|
11
11
|
|
|
12
12
|
KEYCLOAK_CLIENT_ID: Final[str] = env_get_str(key=f"{APP_PREFIX}_KEYCLOAK_CLIENT_ID")
|
|
13
13
|
KEYCLOAK_CLIENT_SECRET: Final[str] = env_get_str(key=f"{APP_PREFIX}_KEYCLOAK_CLIENT_SECRET")
|
|
@@ -49,7 +49,6 @@ KEYCLOAK_URL_AUTH_CALLBACK: Final[str] = env_get_str(key=f"{APP_PREFIX}_KEYCLOAK
|
|
|
49
49
|
# "access-expiration": <timestamp>,
|
|
50
50
|
# "login-expiration": <timestamp>, <-- transient
|
|
51
51
|
# "login-id": <str>, <-- transient
|
|
52
|
-
# "oauth-scope": <str> <-- optional
|
|
53
52
|
# }
|
|
54
53
|
# }
|
|
55
54
|
# }
|
|
@@ -151,25 +150,3 @@ def keycloak_get_token(user_id: str,
|
|
|
151
150
|
args=args,
|
|
152
151
|
errors=errors,
|
|
153
152
|
logger=logger)
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
def keycloak_set_scope(user_id: str,
|
|
157
|
-
scope: str,
|
|
158
|
-
logger: Logger | None) -> None:
|
|
159
|
-
"""
|
|
160
|
-
Set the OAuth2 scope of *user_id* to *scope*.
|
|
161
|
-
|
|
162
|
-
:param user_id: the user's identification
|
|
163
|
-
:param scope: the OAuth2 scope to set to the user
|
|
164
|
-
:param logger: optional logger
|
|
165
|
-
"""
|
|
166
|
-
global _keycloak_registry
|
|
167
|
-
|
|
168
|
-
# retrieve user data
|
|
169
|
-
user_data: dict[str, Any] = _get_user_data(registry=_keycloak_registry,
|
|
170
|
-
user_id=user_id,
|
|
171
|
-
logger=logger)
|
|
172
|
-
# set the OAuth2 scope
|
|
173
|
-
user_data["oauth-scope"] = scope
|
|
174
|
-
if logger:
|
|
175
|
-
logger.debug(msg=f"Scope for user '{user_id}' set to '{scope}'")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pypomes_iam
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
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,11 @@
|
|
|
1
|
+
pypomes_iam/__init__.py,sha256=u-gNGbsayMf-2SWTB8VcoTCADoczZuwNEH50BPxTZZ8,682
|
|
2
|
+
pypomes_iam/common_pomes.py,sha256=wzyXM0lK7eXuUaGow88872wxbYpJ8DcXjVAVKZnTkmU,15533
|
|
3
|
+
pypomes_iam/iam_pomes.py,sha256=THztlEWObDY4_L8GHQem2uX5J8_44XEP-mUg2Fi_Gx0,5527
|
|
4
|
+
pypomes_iam/jusbr_pomes.py,sha256=ioJSZhuPR5xMzomT2zomNH90uIdbwT6GoracIClgsh0,6261
|
|
5
|
+
pypomes_iam/keycloak_pomes.py,sha256=UpHSr4bhNdDl7sr8GSCIDTdPsXEgX3N11qOiR48TvjA,6652
|
|
6
|
+
pypomes_iam/provider_pomes.py,sha256=eP8XzjTUEpwejTkO0wmDiqKjqbIEOzRNCR2ju5E15og,5856
|
|
7
|
+
pypomes_iam/token_pomes.py,sha256=McjKB8omCjuicenwvDVPiWYu3-7gQeLg1AzgAVKK32M,4309
|
|
8
|
+
pypomes_iam-0.2.1.dist-info/METADATA,sha256=XkLYRIQ6OK6TUGH2SKUsrWIG_zwZHQ9tm0ud_YEEef0,694
|
|
9
|
+
pypomes_iam-0.2.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
10
|
+
pypomes_iam-0.2.1.dist-info/licenses/LICENSE,sha256=YvUELgV8qvXlaYsy9hXG5EW3Bmsrkw-OJmmILZnonAc,1086
|
|
11
|
+
pypomes_iam-0.2.1.dist-info/RECORD,,
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
pypomes_iam/__init__.py,sha256=ieysDaKOQc3B50PvChh8DLDG5R3XgbTzX3bU0ekGoUk,760
|
|
2
|
-
pypomes_iam/common_pomes.py,sha256=bLDaoWM5KLccxsNSyiK5UbXRNBgqsQ7TB0Q4Nc72QoI,16415
|
|
3
|
-
pypomes_iam/iam_pomes.py,sha256=THztlEWObDY4_L8GHQem2uX5J8_44XEP-mUg2Fi_Gx0,5527
|
|
4
|
-
pypomes_iam/jusbr_pomes.py,sha256=R-i0FatmlvTp3UszUrrz2L3BQRkZue8F9Nfy0i4cKHw,7084
|
|
5
|
-
pypomes_iam/keycloak_pomes.py,sha256=TCye3E4xijyisgG-vKoJOhXywNgdyzTuuVzFjNbaJ3I,7490
|
|
6
|
-
pypomes_iam/provider_pomes.py,sha256=eP8XzjTUEpwejTkO0wmDiqKjqbIEOzRNCR2ju5E15og,5856
|
|
7
|
-
pypomes_iam/token_pomes.py,sha256=McjKB8omCjuicenwvDVPiWYu3-7gQeLg1AzgAVKK32M,4309
|
|
8
|
-
pypomes_iam-0.2.0.dist-info/METADATA,sha256=nnSivBbIIMIyu5rSSXr5aQq8S1HhcF9xgb3WFeIx-jA,694
|
|
9
|
-
pypomes_iam-0.2.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
10
|
-
pypomes_iam-0.2.0.dist-info/licenses/LICENSE,sha256=YvUELgV8qvXlaYsy9hXG5EW3Bmsrkw-OJmmILZnonAc,1086
|
|
11
|
-
pypomes_iam-0.2.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|