aiteamutils 0.2.95__py3-none-any.whl → 0.2.97__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.
- aiteamutils/base_service.py +22 -15
- aiteamutils/security.py +14 -2
- aiteamutils/version.py +1 -1
- {aiteamutils-0.2.95.dist-info → aiteamutils-0.2.97.dist-info}/METADATA +1 -1
- {aiteamutils-0.2.95.dist-info → aiteamutils-0.2.97.dist-info}/RECORD +6 -6
- {aiteamutils-0.2.95.dist-info → aiteamutils-0.2.97.dist-info}/WHEEL +0 -0
aiteamutils/base_service.py
CHANGED
@@ -45,9 +45,23 @@ class BaseService(Generic[ModelType]):
|
|
45
45
|
fk_check: List[Dict[str, Any]] | None = None,
|
46
46
|
org_ulid_position: str = "organization_ulid",
|
47
47
|
role_permission: str = "create",
|
48
|
-
token_settings: Dict[str, Any] = None
|
48
|
+
token_settings: Dict[str, Any] | None = None
|
49
49
|
) -> ModelType:
|
50
50
|
|
51
|
+
permission_result = await verify_role_permission(
|
52
|
+
request=request,
|
53
|
+
role_permission=role_permission,
|
54
|
+
token_settings=token_settings,
|
55
|
+
org_ulid_position=org_ulid_position
|
56
|
+
)
|
57
|
+
|
58
|
+
if not permission_result:
|
59
|
+
raise CustomException(
|
60
|
+
ErrorCode.FORBIDDEN,
|
61
|
+
detail=f"{role_permission}",
|
62
|
+
source_function=f"{self.__class__.__name__}.create"
|
63
|
+
)
|
64
|
+
|
51
65
|
try:
|
52
66
|
body = await request.json()
|
53
67
|
|
@@ -59,16 +73,6 @@ class BaseService(Generic[ModelType]):
|
|
59
73
|
if fk_check:
|
60
74
|
await validate_unique_fields(self.db_session, fk_check, find_value=False)
|
61
75
|
|
62
|
-
if org_ulid_position:
|
63
|
-
organization_ulid = body.get(org_ulid_position)
|
64
|
-
|
65
|
-
if not organization_ulid == payload.get("organization_ulid"):
|
66
|
-
raise CustomException(
|
67
|
-
ErrorCode.INVALID_INPUT,
|
68
|
-
detail="organization_ulid is required",
|
69
|
-
source_function=f"{self.__class__.__name__}.create"
|
70
|
-
)
|
71
|
-
|
72
76
|
result = await self.repository.create(
|
73
77
|
entity_data=entity_data,
|
74
78
|
exclude_entities=exclude_entities
|
@@ -102,7 +106,7 @@ class BaseService(Generic[ModelType]):
|
|
102
106
|
response_model: Any = None,
|
103
107
|
org_ulid_position: str = "organization_ulid",
|
104
108
|
role_permission: str = "update",
|
105
|
-
token_settings: Dict[str, Any] = None
|
109
|
+
token_settings: Dict[str, Any] | None = None
|
106
110
|
) -> ModelType:
|
107
111
|
try:
|
108
112
|
async with self.db_session.begin():
|
@@ -155,7 +159,7 @@ class BaseService(Generic[ModelType]):
|
|
155
159
|
conditions: Dict[str, Any] | None = None,
|
156
160
|
org_ulid_position: str = "organization_ulid",
|
157
161
|
role_permission: str = "delete",
|
158
|
-
token_settings: Dict[str, Any] = None
|
162
|
+
token_settings: Dict[str, Any] | None = None
|
159
163
|
) -> bool:
|
160
164
|
try:
|
161
165
|
if not ULID.from_str(ulid):
|
@@ -206,7 +210,7 @@ class BaseService(Generic[ModelType]):
|
|
206
210
|
explicit_joins: Optional[List[Any]] = None,
|
207
211
|
loading_joins: Optional[List[Any]] = None,
|
208
212
|
order: Optional[str] = None,
|
209
|
-
token_settings: Dict[str, Any] = None
|
213
|
+
token_settings: Dict[str, Any] | None = None
|
210
214
|
) -> List[Dict[str, Any]]:
|
211
215
|
permission_result = await verify_role_permission(
|
212
216
|
request=request,
|
@@ -215,6 +219,9 @@ class BaseService(Generic[ModelType]):
|
|
215
219
|
org_ulid_position=org_ulid_position
|
216
220
|
)
|
217
221
|
|
222
|
+
# 매번 새로운 리스트 생성
|
223
|
+
filters = list(filters) if filters is not None else []
|
224
|
+
|
218
225
|
if permission_result and isinstance(permission_result, dict):
|
219
226
|
filters.append(permission_result)
|
220
227
|
|
@@ -255,7 +262,7 @@ class BaseService(Generic[ModelType]):
|
|
255
262
|
loading_joins: Optional[List[Any]] = None,
|
256
263
|
org_ulid_position: str = "organization_ulid",
|
257
264
|
role_permission: str = "get",
|
258
|
-
token_settings: Dict[str, Any] = None
|
265
|
+
token_settings: Dict[str, Any] | None = None
|
259
266
|
):
|
260
267
|
try:
|
261
268
|
if not ulid and not conditions:
|
aiteamutils/security.py
CHANGED
@@ -315,5 +315,17 @@ async def verify_role_permission(
|
|
315
315
|
"operator": "eq",
|
316
316
|
"fields": [org_ulid_position]
|
317
317
|
}
|
318
|
-
|
319
|
-
|
318
|
+
elif "create" in role_permission:
|
319
|
+
body = await request.json()
|
320
|
+
body_org_ulid = body.get(org_ulid_position)
|
321
|
+
|
322
|
+
if not body_org_ulid or body_org_ulid != organization_ulid:
|
323
|
+
raise CustomException(
|
324
|
+
ErrorCode.FORBIDDEN,
|
325
|
+
detail=f"{org_ulid_position}|{body_org_ulid}",
|
326
|
+
source_function="security.verify_role_permission"
|
327
|
+
)
|
328
|
+
|
329
|
+
return True
|
330
|
+
else:
|
331
|
+
return False
|
aiteamutils/version.py
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
"""버전 정보"""
|
2
|
-
__version__ = "0.2.
|
2
|
+
__version__ = "0.2.97"
|
@@ -1,15 +1,15 @@
|
|
1
1
|
aiteamutils/__init__.py,sha256=kRBpRjark0M8ZwFfmKiMFol6CbIILN3WE4f6_P6iIq0,1089
|
2
2
|
aiteamutils/base_model.py,sha256=bnRJJaGXGS3TKxfCWWV3arFjdG0qLsPFDXuguYsDyVM,3008
|
3
3
|
aiteamutils/base_repository.py,sha256=HKcgYyEb0JypojoXBFcIT39hPC5CqnjBkHT__GV-lfQ,4615
|
4
|
-
aiteamutils/base_service.py,sha256
|
4
|
+
aiteamutils/base_service.py,sha256=e16_-cbMj5qJRunFdZvtMMpwHhdgMA2mq7QkQJk-S-4,10611
|
5
5
|
aiteamutils/cache.py,sha256=07xBGlgAwOTAdY5mnMOQJ5EBxVwe8glVD7DkGEkxCtw,1373
|
6
6
|
aiteamutils/config.py,sha256=YdalpJb70-txhGJAS4aaKglEZAFVWgfzw5BXSWpkUz4,3232
|
7
7
|
aiteamutils/database.py,sha256=b4fN0XHNWxMJeS5M95JcJ7tujAJ1x3SPTAfDvJdB4sE,19696
|
8
8
|
aiteamutils/enums.py,sha256=7WLqlcJqQWtETAga2WAxNp3dJTQIAd2TW-4WzkoHHa8,2498
|
9
9
|
aiteamutils/exceptions.py,sha256=wls-R8qbD7fWzEgDDY1Eiy1vXl59R5IsCXTRkZpBiGU,16021
|
10
|
-
aiteamutils/security.py,sha256=
|
10
|
+
aiteamutils/security.py,sha256=9mX6ivjxdaFgIfb-9YBZqXW8DZiZAvqJMLxCnbEf_mw,11715
|
11
11
|
aiteamutils/validators.py,sha256=PvI9hbMEAqTawgxPbiWRyx2r9yTUrpNBQs1AD3w4F2U,7726
|
12
|
-
aiteamutils/version.py,sha256=
|
13
|
-
aiteamutils-0.2.
|
14
|
-
aiteamutils-0.2.
|
15
|
-
aiteamutils-0.2.
|
12
|
+
aiteamutils/version.py,sha256=4paZn1JjWekVaaFRQRRPRldO0uHiadnKCMb-2RMWNyI,42
|
13
|
+
aiteamutils-0.2.97.dist-info/METADATA,sha256=PTIGPsXaqlkOu1TucLT8aoAQCeSXM7UDIafT-zxO6RM,1718
|
14
|
+
aiteamutils-0.2.97.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
15
|
+
aiteamutils-0.2.97.dist-info/RECORD,,
|
File without changes
|