elody 0.0.222__py3-none-any.whl → 0.0.224__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.
- elody/loader.py +5 -2
- elody/object_configurations/elody_configuration.py +0 -12
- elody/policies/authentication/x_user_headers_policy.py +34 -0
- {elody-0.0.222.dist-info → elody-0.0.224.dist-info}/METADATA +1 -1
- {elody-0.0.222.dist-info → elody-0.0.224.dist-info}/RECORD +8 -7
- {elody-0.0.222.dist-info → elody-0.0.224.dist-info}/WHEEL +0 -0
- {elody-0.0.222.dist-info → elody-0.0.224.dist-info}/licenses/LICENSE +0 -0
- {elody-0.0.222.dist-info → elody-0.0.224.dist-info}/top_level.txt +0 -0
elody/loader.py
CHANGED
|
@@ -13,8 +13,11 @@ def load_apps(flask_app, logger):
|
|
|
13
13
|
apps = util.read_json_as_dict(os.getenv("APPS_MANIFEST"), logger)
|
|
14
14
|
for app in apps:
|
|
15
15
|
for resource in apps[app].get("resources", []):
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
try:
|
|
17
|
+
api_bp = import_module(f"apps.{app}.resources.{resource}").api_bp
|
|
18
|
+
flask_app.register_blueprint(api_bp)
|
|
19
|
+
except AttributeError:
|
|
20
|
+
pass
|
|
18
21
|
|
|
19
22
|
|
|
20
23
|
def load_jobs(scheduler, logger):
|
|
@@ -51,7 +51,6 @@ class ElodyConfiguration(BaseObjectConfiguration):
|
|
|
51
51
|
post_body if isinstance(post_body, dict) else {},
|
|
52
52
|
)
|
|
53
53
|
_id = document_defaults.get("_id", str(uuid4()))
|
|
54
|
-
timestamp = datetime.now(timezone.utc)
|
|
55
54
|
|
|
56
55
|
identifiers = (
|
|
57
56
|
post_body.pop("identifiers", []) if isinstance(post_body, dict) else []
|
|
@@ -87,17 +86,6 @@ class ElodyConfiguration(BaseObjectConfiguration):
|
|
|
87
86
|
document = {**template, **document_defaults, **post_body}
|
|
88
87
|
else:
|
|
89
88
|
document = {**template, **document_defaults}
|
|
90
|
-
document = self._pre_crud_hook(
|
|
91
|
-
crud="create",
|
|
92
|
-
timestamp=timestamp,
|
|
93
|
-
document=document,
|
|
94
|
-
audit_override={
|
|
95
|
-
"date_created": document_defaults.get("date_created"),
|
|
96
|
-
"created_by": document_defaults.get("created_by"),
|
|
97
|
-
"date_updated": document_defaults.get("date_updated"),
|
|
98
|
-
"last_editor": document_defaults.get("last_editor"),
|
|
99
|
-
},
|
|
100
|
-
)
|
|
101
89
|
return document
|
|
102
90
|
|
|
103
91
|
def _document_content_patcher(self, *, document, content, overwrite=False, **_):
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
from configuration import get_object_configuration_mapper
|
|
2
|
+
from flask import Request
|
|
3
|
+
from inuits_policy_based_auth.authentication.base_authentication_policy import (
|
|
4
|
+
BaseAuthenticationPolicy,
|
|
5
|
+
)
|
|
6
|
+
from os import getenv
|
|
7
|
+
from storage.storagemanager import StorageManager
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class XUserHeadersPolicy(BaseAuthenticationPolicy):
|
|
11
|
+
def authenticate(self, user_context, request_context):
|
|
12
|
+
request: Request = request_context.http_request
|
|
13
|
+
|
|
14
|
+
auth_header = request.headers.get("Authorization", "")
|
|
15
|
+
if auth_header.startswith("Bearer "):
|
|
16
|
+
token = auth_header.removeprefix("Bearer ")
|
|
17
|
+
static_jwt = getenv("STATIC_JWT")
|
|
18
|
+
|
|
19
|
+
if static_jwt and token == static_jwt:
|
|
20
|
+
user_email = request.headers.get("X-User-Email")
|
|
21
|
+
if user_email:
|
|
22
|
+
config = get_object_configuration_mapper().get("user")
|
|
23
|
+
storage_manager = StorageManager()
|
|
24
|
+
user = (
|
|
25
|
+
storage_manager.get_db_engine().get_item_from_collection_by_id(
|
|
26
|
+
config.crud()["collection"], user_email
|
|
27
|
+
)
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
if user:
|
|
31
|
+
user_context.id = user.get("_id", user.get("id"))
|
|
32
|
+
user_context.email = user_email
|
|
33
|
+
|
|
34
|
+
return user_context
|
|
@@ -5,7 +5,7 @@ elody/csv.py,sha256=f8HphE-KC2OqKFzV0HiifWBgMHb3g0EA_Y82o_6JEiE,16761
|
|
|
5
5
|
elody/error_codes.py,sha256=d3wNPZU0HFMyl8xN95ciNd6QD94al1tX18h6HiqiAHo,4310
|
|
6
6
|
elody/exceptions.py,sha256=5KSw2sPCZz3lDIJX4LiR2iL9n4m4KIil04D1d3X5rd0,968
|
|
7
7
|
elody/job.py,sha256=EGfYozNxyx2iLC-j_L5XLzV3hUAOM9UIFuYzyqKpS1w,1908
|
|
8
|
-
elody/loader.py,sha256=
|
|
8
|
+
elody/loader.py,sha256=xm7BsuZB3VAETMKze4_JRWC3Kyejk-gGDL_wc9jZeio,5500
|
|
9
9
|
elody/schemas.py,sha256=WtKdZEAX-PtEuAaRohyS3Md8H4-8yKVXMkHfCQ2SDR4,4676
|
|
10
10
|
elody/util.py,sha256=Qcoe49DsoJwXLFNevR67U_04iuJkmX4Pl0bcJ0Alrh0,9325
|
|
11
11
|
elody/validator.py,sha256=G7Ya538EJHCFzOxEri2OcFMabfLBCtTKxuf4os_KuNw,260
|
|
@@ -13,7 +13,7 @@ elody/migration/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
13
13
|
elody/migration/base_object_migrator.py,sha256=n8uvgGfjEUy60G47RD7Y-oxp1vHLOauwPMDl87LcxtU,436
|
|
14
14
|
elody/object_configurations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
15
|
elody/object_configurations/base_object_configuration.py,sha256=4lk6BmhRSYxwuD2qqGfE8d9H9ak7iwoOM5gqw7EntTI,7905
|
|
16
|
-
elody/object_configurations/elody_configuration.py,sha256=
|
|
16
|
+
elody/object_configurations/elody_configuration.py,sha256=Bchwd1roBnrMDTdFkJUlUTS_FkrzhAq2kVdphLCdu2M,10621
|
|
17
17
|
elody/object_configurations/job_configuration.py,sha256=T6QI2wE-u7ZcNpYE5XjmrCzIJglyKUGJsifaTn0WGyg,7512
|
|
18
18
|
elody/object_configurations/saved_search_configuration.py,sha256=ddOry4EqYOeEKRF7q2M_fHoqZv8DXpQjFq8VaZ7jhVI,732
|
|
19
19
|
elody/policies/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -22,6 +22,7 @@ elody/policies/permission_handler.py,sha256=9vxiYjkPrnqIxWi8X9qoGwb09SQaZmQeF4f_
|
|
|
22
22
|
elody/policies/authentication/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
23
23
|
elody/policies/authentication/base_user_tenant_validation_policy.py,sha256=p7draxPCqly1vy7vnJX-gpmRfDeyaTxt9Cf0YpH9PZI,5829
|
|
24
24
|
elody/policies/authentication/multi_tenant_policy.py,sha256=g4ZYUQMmCjgLg09wj0-0lGKsJsRt7h4ppI25o1VdZHw,4039
|
|
25
|
+
elody/policies/authentication/x_user_headers_policy.py,sha256=AoOZH7cbVI9X7JTWmbH3HdXV2UUf0NJpAiuSI0qnQCI,1350
|
|
25
26
|
elody/policies/authorization/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
27
|
elody/policies/authorization/filter_generic_objects_policy.py,sha256=mF32moh8hRetBgG8vQW-rz4xjoRQD2yOxdI740SFSUo,6522
|
|
27
28
|
elody/policies/authorization/filter_generic_objects_policy_v2.py,sha256=2IkESYMfne1bX1I8Yvn3yoNmlfn_Jm6zVlVBknoW1_c,6412
|
|
@@ -35,13 +36,13 @@ elody/policies/authorization/mediafile_derivatives_policy.py,sha256=OwNpbS8i7-Lz
|
|
|
35
36
|
elody/policies/authorization/mediafile_download_policy.py,sha256=XMsKavBucmTh4W1kWOzpFWxJ_ZXgHVK1RS7JB4HjtQo,1979
|
|
36
37
|
elody/policies/authorization/multi_tenant_policy.py,sha256=SA9H7SBjzuh8mY3gYN7pDG8TV7hdI3GEUtNeiZeNL3M,3164
|
|
37
38
|
elody/policies/authorization/tenant_request_policy.py,sha256=dEgblwRAqwWVcE-O7Jn8hVL3OnwDlQhDEOcPlcElBrk,1185
|
|
38
|
-
elody-0.0.
|
|
39
|
+
elody-0.0.224.dist-info/licenses/LICENSE,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
|
|
39
40
|
tests/__init_.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
40
41
|
tests/data.py,sha256=Q3oxduf-E3m-Z5G_p3fcs8jVy6g10I7zXKL1m94UVMI,2906
|
|
41
42
|
tests/unit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
42
43
|
tests/unit/test_csv.py,sha256=NQaOhehfQ4GuXku0Y1SA8DYjJeqqidbF50zEHAi8RZA,15923
|
|
43
44
|
tests/unit/test_utils.py,sha256=g63szcEZyHhCOtrW4BnNbcgVca3oYPIOLjBdIzNwwN0,8784
|
|
44
|
-
elody-0.0.
|
|
45
|
-
elody-0.0.
|
|
46
|
-
elody-0.0.
|
|
47
|
-
elody-0.0.
|
|
45
|
+
elody-0.0.224.dist-info/METADATA,sha256=rYmZn_xC-VjjsiCd3kugfnmQ1JdI2GYmyV6RNZ_EpgI,23358
|
|
46
|
+
elody-0.0.224.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
47
|
+
elody-0.0.224.dist-info/top_level.txt,sha256=E0mImupLj0KmtUUCXRYEoLDRaSkuiGaOIIseAa0oQ-M,21
|
|
48
|
+
elody-0.0.224.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|