elody 0.0.222__py3-none-any.whl → 0.0.223__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.
@@ -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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: elody
3
- Version: 0.0.222
3
+ Version: 0.0.223
4
4
  Summary: elody SDK for Python
5
5
  Author-email: Inuits <developers@inuits.eu>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -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=Gf_59TfqjvlkufnkfzTtE4p8cBly613ieJ5beemtv00,11131
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.222.dist-info/licenses/LICENSE,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
39
+ elody-0.0.223.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.222.dist-info/METADATA,sha256=N8xZrzgeNCwpRTo8WLIlxfFE9ZYEegaEJIloyTDXlHw,23358
45
- elody-0.0.222.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
46
- elody-0.0.222.dist-info/top_level.txt,sha256=E0mImupLj0KmtUUCXRYEoLDRaSkuiGaOIIseAa0oQ-M,21
47
- elody-0.0.222.dist-info/RECORD,,
45
+ elody-0.0.223.dist-info/METADATA,sha256=u1QFifFzK7nwVddOPF0pfjnAdb51hP0OuNuGiMiwJac,23358
46
+ elody-0.0.223.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
47
+ elody-0.0.223.dist-info/top_level.txt,sha256=E0mImupLj0KmtUUCXRYEoLDRaSkuiGaOIIseAa0oQ-M,21
48
+ elody-0.0.223.dist-info/RECORD,,