pypomes-iam 0.7.9__tar.gz → 0.8.1__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.7.9 → pypomes_iam-0.8.1}/PKG-INFO +2 -2
- {pypomes_iam-0.7.9 → pypomes_iam-0.8.1}/pyproject.toml +2 -2
- {pypomes_iam-0.7.9 → pypomes_iam-0.8.1}/src/pypomes_iam/iam_pomes.py +6 -3
- {pypomes_iam-0.7.9 → pypomes_iam-0.8.1}/src/pypomes_iam/iam_services.py +5 -2
- {pypomes_iam-0.7.9 → pypomes_iam-0.8.1}/src/pypomes_iam/provider_pomes.py +11 -9
- {pypomes_iam-0.7.9 → pypomes_iam-0.8.1}/.gitignore +0 -0
- {pypomes_iam-0.7.9 → pypomes_iam-0.8.1}/LICENSE +0 -0
- {pypomes_iam-0.7.9 → pypomes_iam-0.8.1}/README.md +0 -0
- {pypomes_iam-0.7.9 → pypomes_iam-0.8.1}/src/__init__.py +0 -0
- {pypomes_iam-0.7.9 → pypomes_iam-0.8.1}/src/pypomes_iam/__init__.py +0 -0
- {pypomes_iam-0.7.9 → pypomes_iam-0.8.1}/src/pypomes_iam/iam_actions.py +0 -0
- {pypomes_iam-0.7.9 → pypomes_iam-0.8.1}/src/pypomes_iam/iam_common.py +0 -0
- {pypomes_iam-0.7.9 → pypomes_iam-0.8.1}/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.
|
|
3
|
+
Version: 0.8.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
|
|
@@ -12,6 +12,6 @@ Classifier: Programming Language :: Python :: 3
|
|
|
12
12
|
Requires-Python: >=3.12
|
|
13
13
|
Requires-Dist: flask>=3.1.2
|
|
14
14
|
Requires-Dist: pyjwt>=2.10.1
|
|
15
|
-
Requires-Dist: pypomes-core>=2.8.
|
|
15
|
+
Requires-Dist: pypomes-core>=2.8.6
|
|
16
16
|
Requires-Dist: pypomes-crypto>=0.4.8
|
|
17
17
|
Requires-Dist: requests>=2.32.5
|
|
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
|
|
|
6
6
|
|
|
7
7
|
[project]
|
|
8
8
|
name = "pypomes_iam"
|
|
9
|
-
version = "0.
|
|
9
|
+
version = "0.8.1"
|
|
10
10
|
authors = [
|
|
11
11
|
{ name="GT Nunes", email="wisecoder01@gmail.com" }
|
|
12
12
|
]
|
|
@@ -21,7 +21,7 @@ classifiers = [
|
|
|
21
21
|
dependencies = [
|
|
22
22
|
"Flask>=3.1.2",
|
|
23
23
|
"PyJWT>=2.10.1",
|
|
24
|
-
"pypomes-core>=2.8.
|
|
24
|
+
"pypomes-core>=2.8.6",
|
|
25
25
|
"pypomes-crypto>=0.4.8",
|
|
26
26
|
"requests>=2.32.5"
|
|
27
27
|
]
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
from flask import Flask
|
|
2
2
|
from pypomes_core import (
|
|
3
3
|
APP_PREFIX,
|
|
4
|
-
env_get_int, env_get_str,
|
|
4
|
+
env_get_int, env_get_str,
|
|
5
|
+
func_capture_params, func_defaulted_params
|
|
5
6
|
)
|
|
6
7
|
|
|
7
8
|
from .iam_common import (
|
|
@@ -13,6 +14,7 @@ from .iam_services import (
|
|
|
13
14
|
)
|
|
14
15
|
|
|
15
16
|
|
|
17
|
+
@func_capture_params
|
|
16
18
|
def iam_setup_server(iam_server: IamServer,
|
|
17
19
|
admin_id: str = None,
|
|
18
20
|
admin_secret: str = None,
|
|
@@ -50,7 +52,7 @@ def iam_setup_server(iam_server: IamServer,
|
|
|
50
52
|
:param url_base: base URL to request services
|
|
51
53
|
"""
|
|
52
54
|
# obtain the defaulted parameters
|
|
53
|
-
defaulted_params: list[str] =
|
|
55
|
+
defaulted_params: list[str] = func_defaulted_params.get()
|
|
54
56
|
|
|
55
57
|
# read from the environment variables
|
|
56
58
|
prefix: str = iam_server.name
|
|
@@ -92,6 +94,7 @@ def iam_setup_server(iam_server: IamServer,
|
|
|
92
94
|
}
|
|
93
95
|
|
|
94
96
|
|
|
97
|
+
@func_capture_params
|
|
95
98
|
def iam_setup_endpoints(flask_app: Flask,
|
|
96
99
|
iam_server: IamServer,
|
|
97
100
|
callback_endpoint: str = None,
|
|
@@ -116,7 +119,7 @@ def iam_setup_endpoints(flask_app: Flask,
|
|
|
116
119
|
:param token_endpoint: endpoint for retrieving authentication token
|
|
117
120
|
"""
|
|
118
121
|
# obtain the defaulted parameters
|
|
119
|
-
defaulted_params: list[str] =
|
|
122
|
+
defaulted_params: list[str] = func_defaulted_params.get()
|
|
120
123
|
|
|
121
124
|
# read from the environment variables
|
|
122
125
|
prefix: str = iam_server.name
|
|
@@ -12,7 +12,6 @@ from .iam_actions import (
|
|
|
12
12
|
iam_login, iam_logout,
|
|
13
13
|
iam_get_token, iam_exchange, iam_callback
|
|
14
14
|
)
|
|
15
|
-
from .iam_pomes import iam_setup_server
|
|
16
15
|
from .token_pomes import token_get_claims, token_validate
|
|
17
16
|
|
|
18
17
|
# the logger for IAM service operations
|
|
@@ -24,7 +23,10 @@ def jwt_required(func: callable) -> callable:
|
|
|
24
23
|
"""
|
|
25
24
|
Create a decorator to authenticate service endpoints with JWT tokens.
|
|
26
25
|
|
|
26
|
+
The decorated function must be a registered endpoint to a *Flask* application.
|
|
27
|
+
|
|
27
28
|
:param func: the function being decorated
|
|
29
|
+
:return: the return from the call to *func*, or a *Response NOT AUTHORIZED* if the authentication failed
|
|
28
30
|
"""
|
|
29
31
|
# ruff: noqa: ANN003 - Missing type annotation for *{name}
|
|
30
32
|
def wrapper(*args, **kwargs) -> Response:
|
|
@@ -45,7 +47,7 @@ def __request_validate(request: Request) -> Response:
|
|
|
45
47
|
Because this code has a high usage frequency, only authentication failures are logged.
|
|
46
48
|
|
|
47
49
|
:param request: the *request* to be verified
|
|
48
|
-
:return: *None* if the *request* is valid, otherwise a *Response
|
|
50
|
+
:return: *None* if the *request* is valid, otherwise a *Response NOT AUTHORIZED*
|
|
49
51
|
"""
|
|
50
52
|
# initialize the return variable
|
|
51
53
|
result: Response | None = None
|
|
@@ -151,6 +153,7 @@ def service_setup_server() -> Response:
|
|
|
151
153
|
args: dict[str, Any] = request.json if request.is_json else request.form
|
|
152
154
|
|
|
153
155
|
# setup the server
|
|
156
|
+
from .iam_pomes import iam_setup_server
|
|
154
157
|
iam_setup_server(**args)
|
|
155
158
|
result = Response(status=200)
|
|
156
159
|
|
|
@@ -8,8 +8,8 @@ from flask import Flask, Response, request, jsonify
|
|
|
8
8
|
from logging import Logger
|
|
9
9
|
from pypomes_core import (
|
|
10
10
|
APP_PREFIX, TZ_LOCAL,
|
|
11
|
-
env_get_str, env_get_strs, env_get_obj,
|
|
12
|
-
|
|
11
|
+
env_get_str, env_get_strs, env_get_obj, exc_format,
|
|
12
|
+
func_capture_params, func_defaulted_params
|
|
13
13
|
)
|
|
14
14
|
from threading import Lock
|
|
15
15
|
from typing import Any, Final
|
|
@@ -53,10 +53,10 @@ def __get_provider_data() -> dict[str, dict[ProviderParam, Any]]:
|
|
|
53
53
|
- *<APP_PREFIX>_<JWT>_USER_SECRET* (required)
|
|
54
54
|
- *<APP_PREFIX>_<JWT>_URL_TOKEN* (required)
|
|
55
55
|
|
|
56
|
-
2. The special environment variable *<APP_PREFIX>
|
|
57
|
-
to obtain JWT tokens. It is not part of the *JWT* providers' setup, but is meant to be
|
|
58
|
-
by function *provider_setup_endpoint()*, wherein the value in that variable would represent
|
|
59
|
-
default value for its parameter.
|
|
56
|
+
2. The special environment variable *<APP_PREFIX>_IAM_PROVIDER_ENDPOINT_TOKEN* identifies the endpoint
|
|
57
|
+
from which to obtain JWT tokens. It is not part of the *JWT* providers' setup, but is meant to be
|
|
58
|
+
used by function *provider_setup_endpoint()*, wherein the value in that variable would represent
|
|
59
|
+
the default value for its parameter.
|
|
60
60
|
|
|
61
61
|
:return: the configuration data for the select *JWT* providers.
|
|
62
62
|
"""
|
|
@@ -104,6 +104,7 @@ _provider_registry: Final[dict[str, dict[str, Any]]] = __get_provider_data()
|
|
|
104
104
|
_provider_lock: Final[Lock] = Lock()
|
|
105
105
|
|
|
106
106
|
|
|
107
|
+
@func_capture_params
|
|
107
108
|
def provider_setup_server(provider_id: str,
|
|
108
109
|
user_id: str = None,
|
|
109
110
|
user_secret: str = None,
|
|
@@ -136,7 +137,7 @@ def provider_setup_server(provider_id: str,
|
|
|
136
137
|
global _provider_registry
|
|
137
138
|
|
|
138
139
|
# obtain the defaulted parameters
|
|
139
|
-
defaulted_params: list[str] =
|
|
140
|
+
defaulted_params: list[str] = func_defaulted_params.get()
|
|
140
141
|
|
|
141
142
|
# read from the environment variables
|
|
142
143
|
prefix: str = provider_id.upper()
|
|
@@ -169,6 +170,7 @@ def provider_setup_server(provider_id: str,
|
|
|
169
170
|
}
|
|
170
171
|
|
|
171
172
|
|
|
173
|
+
@func_capture_params
|
|
172
174
|
def provider_setup_endpoint(flask_app: Flask,
|
|
173
175
|
provider_endpoint: str = None) -> None:
|
|
174
176
|
"""
|
|
@@ -181,11 +183,11 @@ def provider_setup_endpoint(flask_app: Flask,
|
|
|
181
183
|
:param provider_endpoint: endpoint for requenting tokens to provider
|
|
182
184
|
"""
|
|
183
185
|
# obtain the defaulted parameters
|
|
184
|
-
defaulted_params: list[str] =
|
|
186
|
+
defaulted_params: list[str] = func_defaulted_params.get()
|
|
185
187
|
|
|
186
188
|
# read from the environment variable
|
|
187
189
|
if "provider_endpoint" in defaulted_params:
|
|
188
|
-
provider_endpoint = env_get_str(key=f"{APP_PREFIX}
|
|
190
|
+
provider_endpoint = env_get_str(key=f"{APP_PREFIX}_IAM_PROVIDER_ENDPOINT_TOKEN")
|
|
189
191
|
|
|
190
192
|
# establish the endpoints
|
|
191
193
|
if provider_endpoint:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|