elody 0.0.214__tar.gz → 0.0.216__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.
- {elody-0.0.214 → elody-0.0.216}/PKG-INFO +1 -1
- {elody-0.0.214 → elody-0.0.216}/pyproject.toml +1 -1
- {elody-0.0.214 → elody-0.0.216}/src/elody/object_configurations/elody_configuration.py +4 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/policies/authentication/base_user_tenant_validation_policy.py +34 -23
- {elody-0.0.214 → elody-0.0.216}/src/elody/policies/helpers.py +9 -1
- {elody-0.0.214 → elody-0.0.216}/src/elody/policies/permission_handler.py +6 -2
- {elody-0.0.214 → elody-0.0.216}/src/elody.egg-info/PKG-INFO +1 -1
- {elody-0.0.214 → elody-0.0.216}/LICENSE +0 -0
- {elody-0.0.214 → elody-0.0.216}/README.md +0 -0
- {elody-0.0.214 → elody-0.0.216}/setup.cfg +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/__init__.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/__init__.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/client.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/csv.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/error_codes.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/exceptions.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/job.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/loader.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/migration/__init__.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/migration/base_object_migrator.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/object_configurations/__init__.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/object_configurations/base_object_configuration.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/object_configurations/job_configuration.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/object_configurations/saved_search_configuration.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/policies/__init__.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/policies/authentication/__init__.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/policies/authentication/multi_tenant_policy.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/policies/authorization/__init__.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/policies/authorization/filter_generic_objects_policy.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/policies/authorization/filter_generic_objects_policy_v2.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/policies/authorization/generic_object_detail_policy.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/policies/authorization/generic_object_mediafiles_policy.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/policies/authorization/generic_object_metadata_policy.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/policies/authorization/generic_object_relations_policy.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/policies/authorization/generic_object_request_policy.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/policies/authorization/generic_object_request_policy_v2.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/policies/authorization/mediafile_derivatives_policy.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/policies/authorization/mediafile_download_policy.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/policies/authorization/multi_tenant_policy.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/policies/authorization/tenant_request_policy.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/schemas.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/util.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody/validator.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody.egg-info/SOURCES.txt +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody.egg-info/dependency_links.txt +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody.egg-info/requires.txt +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/elody.egg-info/top_level.txt +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/tests/__init_.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/tests/data.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/tests/unit/__init__.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/tests/unit/test_csv.py +0 -0
- {elody-0.0.214 → elody-0.0.216}/src/tests/unit/test_utils.py +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from copy import deepcopy
|
|
1
2
|
from datetime import datetime, timezone
|
|
2
3
|
from elody.object_configurations.base_object_configuration import (
|
|
3
4
|
BaseObjectConfiguration,
|
|
@@ -158,6 +159,9 @@ class ElodyConfiguration(BaseObjectConfiguration):
|
|
|
158
159
|
lines = value.splitlines()
|
|
159
160
|
value = "\n".join(line.strip() for line in lines).strip()
|
|
160
161
|
element[object_list_value_field_name] = value.strip()
|
|
162
|
+
for key, value in deepcopy(element).items():
|
|
163
|
+
if not value:
|
|
164
|
+
del element[key]
|
|
161
165
|
return sanitized_document
|
|
162
166
|
|
|
163
167
|
def __patch_document_audit_info(self, crud, document, timestamp):
|
|
@@ -35,6 +35,10 @@ class BaseUserTenantValidationPolicy(ABC):
|
|
|
35
35
|
|
|
36
36
|
return self.user
|
|
37
37
|
|
|
38
|
+
@abstractmethod
|
|
39
|
+
def promote_role(self, user_context: UserContext):
|
|
40
|
+
pass
|
|
41
|
+
|
|
38
42
|
@abstractmethod
|
|
39
43
|
def build_user_context_for_anonymous_user(
|
|
40
44
|
self, request, user_context: UserContext
|
|
@@ -86,30 +90,37 @@ class BaseUserTenantValidationPolicy(ABC):
|
|
|
86
90
|
"""
|
|
87
91
|
|
|
88
92
|
roles = []
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
try:
|
|
94
|
+
for metadata in self.user.get("metadata", []):
|
|
95
|
+
if (
|
|
96
|
+
metadata["key"]
|
|
97
|
+
== user_context.bag["user_metadata_key_for_global_roles"]
|
|
98
|
+
):
|
|
99
|
+
roles.extend(metadata["value"])
|
|
100
|
+
|
|
101
|
+
if user_context.x_tenant.id:
|
|
102
|
+
tenant_ids = user_context.x_tenant.id.split(",")
|
|
103
|
+
for tenant_id in tenant_ids:
|
|
104
|
+
try:
|
|
105
|
+
user_tenant_relation = self.__get_user_tenant_relation(
|
|
106
|
+
tenant_id, user_context.bag["user_tenant_relation_type"]
|
|
107
|
+
)
|
|
108
|
+
except Forbidden as error:
|
|
109
|
+
user_tenant_relation = {}
|
|
110
|
+
if len(roles) == 0:
|
|
111
|
+
raise Forbidden(error.description)
|
|
112
|
+
roles.extend(user_tenant_relation.get("roles", []))
|
|
113
|
+
|
|
114
|
+
if len(roles) == 0 and not regex.match(
|
|
115
|
+
"(/[^/]+/v[0-9]+)?/tenants$", request.path
|
|
93
116
|
):
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
tenant_id, user_context.bag["user_tenant_relation_type"]
|
|
102
|
-
)
|
|
103
|
-
except Forbidden as error:
|
|
104
|
-
user_tenant_relation = {}
|
|
105
|
-
if len(roles) == 0:
|
|
106
|
-
raise Forbidden(error.description)
|
|
107
|
-
roles.extend(user_tenant_relation.get("roles", []))
|
|
108
|
-
|
|
109
|
-
if len(roles) == 0 and not regex.match(
|
|
110
|
-
"(/[^/]+/v[0-9]+)?/tenants$", request.path
|
|
111
|
-
):
|
|
112
|
-
raise Forbidden("User has no global roles, switch to a specific tenant.")
|
|
117
|
+
raise Forbidden(
|
|
118
|
+
"User has no global roles, switch to a specific tenant."
|
|
119
|
+
)
|
|
120
|
+
except Forbidden as exception:
|
|
121
|
+
if not (promoted_role := self.promote_role(user_context)):
|
|
122
|
+
raise exception
|
|
123
|
+
roles.append(promoted_role)
|
|
113
124
|
|
|
114
125
|
return list(set(roles))
|
|
115
126
|
|
|
@@ -44,7 +44,15 @@ def get_item(storage_manager, user_context_bag, view_args) -> dict:
|
|
|
44
44
|
view_args = view_args or {}
|
|
45
45
|
if id := view_args.get("id"):
|
|
46
46
|
resolve_collections = user_context_bag.get("collection_resolver")
|
|
47
|
-
|
|
47
|
+
collection = (
|
|
48
|
+
get_object_configuration_mapper()
|
|
49
|
+
.get(view_args.get("type"))
|
|
50
|
+
.crud()
|
|
51
|
+
.get("collection")
|
|
52
|
+
)
|
|
53
|
+
collections = resolve_collections(
|
|
54
|
+
collection=view_args.get("collection", collection), id=id
|
|
55
|
+
)
|
|
48
56
|
for collection in collections:
|
|
49
57
|
if item := storage_manager.get_db_engine().get_item_from_collection_by_id(
|
|
50
58
|
collection, id
|
|
@@ -222,7 +222,7 @@ def __is_allowed_to_crud_item_keys(
|
|
|
222
222
|
if key_to_check and key_to_check == restricted_key:
|
|
223
223
|
user_context.bag["restricted_keys"].append(restricted_key)
|
|
224
224
|
else:
|
|
225
|
-
if flat_request_body.get(restricted_key):
|
|
225
|
+
if flat_request_body.get(restricted_key) is not None:
|
|
226
226
|
user_context.bag["restricted_keys"].append(restricted_key)
|
|
227
227
|
|
|
228
228
|
user_context.bag["requested_item"] = item
|
|
@@ -260,7 +260,11 @@ def __item_value_in_values(
|
|
|
260
260
|
if key_of_relation:
|
|
261
261
|
if isinstance(item_value, list):
|
|
262
262
|
item_value = item_value[0]
|
|
263
|
-
item = get_item(
|
|
263
|
+
item = get_item(
|
|
264
|
+
StorageManager(),
|
|
265
|
+
user_context.bag,
|
|
266
|
+
{"type": keys[1].split("-", 1)[0], "id": item_value},
|
|
267
|
+
)
|
|
264
268
|
flat_item, _ = get_flat_item_and_object_lists(item)
|
|
265
269
|
return __item_value_in_values(
|
|
266
270
|
flat_item, key_of_relation, values, flat_request_body, user_context
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{elody-0.0.214 → elody-0.0.216}/src/elody/object_configurations/base_object_configuration.py
RENAMED
|
File without changes
|
|
File without changes
|
{elody-0.0.214 → elody-0.0.216}/src/elody/object_configurations/saved_search_configuration.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{elody-0.0.214 → elody-0.0.216}/src/elody/policies/authorization/filter_generic_objects_policy.py
RENAMED
|
File without changes
|
{elody-0.0.214 → elody-0.0.216}/src/elody/policies/authorization/filter_generic_objects_policy_v2.py
RENAMED
|
File without changes
|
{elody-0.0.214 → elody-0.0.216}/src/elody/policies/authorization/generic_object_detail_policy.py
RENAMED
|
File without changes
|
{elody-0.0.214 → elody-0.0.216}/src/elody/policies/authorization/generic_object_mediafiles_policy.py
RENAMED
|
File without changes
|
{elody-0.0.214 → elody-0.0.216}/src/elody/policies/authorization/generic_object_metadata_policy.py
RENAMED
|
File without changes
|
{elody-0.0.214 → elody-0.0.216}/src/elody/policies/authorization/generic_object_relations_policy.py
RENAMED
|
File without changes
|
{elody-0.0.214 → elody-0.0.216}/src/elody/policies/authorization/generic_object_request_policy.py
RENAMED
|
File without changes
|
{elody-0.0.214 → elody-0.0.216}/src/elody/policies/authorization/generic_object_request_policy_v2.py
RENAMED
|
File without changes
|
{elody-0.0.214 → elody-0.0.216}/src/elody/policies/authorization/mediafile_derivatives_policy.py
RENAMED
|
File without changes
|
{elody-0.0.214 → elody-0.0.216}/src/elody/policies/authorization/mediafile_download_policy.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|