abs-auth-rbac-core 0.3.9__py3-none-any.whl → 0.3.11__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.

Potentially problematic release.


This version of abs-auth-rbac-core might be problematic. Click here for more details.

@@ -4,7 +4,7 @@ from pydantic import BaseModel
4
4
  import casbin
5
5
  from casbin_sqlalchemy_adapter import Adapter
6
6
  from casbin_redis_watcher import RedisWatcher, WatcherOptions,new_watcher
7
- from sqlalchemy import and_, select
7
+ from sqlalchemy import and_, or_, select
8
8
  from sqlalchemy.orm import Session, joinedload
9
9
  from ..schema import CreatePermissionSchema
10
10
  from ..models import (
@@ -182,23 +182,41 @@ class RBACService:
182
182
  except Exception as e:
183
183
  raise e
184
184
 
185
- async def get_permissions_by_condition(self, condition: dict, use_filter_by: bool = True):
185
+ def build_filter(self,cond: dict):
186
+ if "and" in cond:
187
+ return and_(*[self.build_filter(c) for c in cond["and"]])
188
+ elif "or" in cond:
189
+ return or_(*[self.build_filter(c) for c in cond["or"]])
190
+ else:
191
+ # Multiple simple field=value pairs in the same dict
192
+ return and_(*[
193
+ getattr(Permission, field) == value
194
+ for field, value in cond.items()
195
+ ])
196
+
197
+
198
+ async def get_permissions_by_condition(self, condition: dict):
186
199
  """
187
- Get permission(s) based on a condition dict.
188
- If use_filter_by is True, assumes all conditions are `==`.
200
+ Get permission(s) based on nested logical conditions.
201
+
202
+ Example:
203
+ {
204
+ "and": [
205
+ {"entity_id": "123"},
206
+ {"or": [
207
+ {"user_id": "456"},
208
+ {"group_id": "789"}
209
+ ]}
210
+ ]
211
+ }
189
212
  """
190
213
  with self.db() as session:
191
214
  try:
192
- query = session.query(Permission)
193
- if use_filter_by:
194
- query = query.filter_by(**condition)
195
- else:
196
- filters = [getattr(Permission, k) == v for k, v in condition.items()]
197
- query = query.filter(*filters)
215
+ query = session.query(Permission).filter(self.build_filter(condition))
198
216
  return query.all()
199
217
  except Exception as e:
200
218
  raise e
201
-
219
+
202
220
  async def delete_permission_by_uuids(self,permission_uuids:List[str]):
203
221
  """
204
222
  Delete a permission by uuids
@@ -153,6 +153,10 @@ class PermissionAction(str, Enum):
153
153
  VIEW_IMPORT_DATA = "VIEW_IMPORT_DATA"
154
154
  VIEW_WORKFLOW = "VIEW_WORKFLOW"
155
155
  VIEW_ERROR_DATA = "VIEW_ERROR_DATA"
156
+ VIEW_ENTITY_RECORD = "VIEW_ENTITY_RECORD"
157
+ EDIT_ENTITY_RECORD = "EDIT_ENTITY_RECORD"
158
+ DELETE_ENTITY_RECORD = "DELETE_ENTITY_RECORD"
159
+ CREATE_ENTITY_RECORD = "CREATE_ENTITY_RECORD"
156
160
 
157
161
 
158
162
 
@@ -172,12 +176,17 @@ class PermissionModule(str, Enum):
172
176
  ASL = "ASL"
173
177
  EDS = "EDS"
174
178
  WORKFORCE_AGENT = "WORKFORCE_AGENT"
175
-
179
+ ENTITY = "ENTITY"
180
+ ENTITY_VIEW = "ENTITY_VIEW"
181
+ ENTITY_RECORD = "ENTITY_RECORD"
182
+ CHATBOT = "CHATBOT"
176
183
 
177
184
 
178
185
  class PermissionResource(str, Enum):
186
+ ENTITIES = "ENTITIES"
179
187
  DASHBOARD = "DASHBOARDS"
180
188
  WORKFORCE_AGENT = "WORKFORCE_AGENT"
189
+ CHATBOT = "CHATBOT"
181
190
  EPAR = "EPAR"
182
191
  EPARS = "EPARS"
183
192
  OCFO = "OCFO"
@@ -1,16 +1,16 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.3
2
2
  Name: abs-auth-rbac-core
3
- Version: 0.3.9
3
+ Version: 0.3.11
4
4
  Summary: RBAC and Auth core utilities including JWT token management.
5
- License-Expression: MIT
5
+ License: MIT
6
6
  Author: AutoBridgeSystems
7
7
  Author-email: info@autobridgesystems.com
8
8
  Requires-Python: >=3.11,<4.0
9
+ Classifier: License :: OSI Approved :: MIT License
9
10
  Classifier: Programming Language :: Python :: 3
10
11
  Classifier: Programming Language :: Python :: 3.11
11
12
  Classifier: Programming Language :: Python :: 3.12
12
13
  Classifier: Programming Language :: Python :: 3.13
13
- Classifier: Programming Language :: Python :: 3.14
14
14
  Requires-Dist: abs-exception-core (>=0.2.0,<0.3.0)
15
15
  Requires-Dist: abs-repository-core (>=0.3.0,<0.4.0)
16
16
  Requires-Dist: abs-utils (>=0.4.1,<0.5.0)
@@ -17,7 +17,7 @@ abs_auth_rbac_core/models/user_role.py,sha256=20pqmtJPzlUrI9ulHGouk8XlFgrGG7I6ik
17
17
  abs_auth_rbac_core/rbac/__init__.py,sha256=oYjtpmfrkEbwWCBAWuRoU1fM4fCpBxkF_lwQrelK1As,79
18
18
  abs_auth_rbac_core/rbac/decorator.py,sha256=pEFAW0Nn2iE4KBctPhNOmO_VLeJFDX2V9v2LsCu6kHY,1824
19
19
  abs_auth_rbac_core/rbac/policy.conf,sha256=wghhhKxgZH0rPhh1QFrIpq9nevJT3s7OxxvXiU3zzuI,305
20
- abs_auth_rbac_core/rbac/service.py,sha256=4gwksJY9SfcMUN72pdxmruimFiSXmxoOQG6H_dhVY-g,38413
20
+ abs_auth_rbac_core/rbac/service.py,sha256=7hg1oW9n5omjOFndfICp0NYid-l86Db5gLRKnO_dFik,38792
21
21
  abs_auth_rbac_core/repository/__init__.py,sha256=tuEdEV5HsePiaEg2Jrakf-QOR3evTeS-2Tq5VqbywyU,154
22
22
  abs_auth_rbac_core/repository/permission_repository.py,sha256=SQJyyErrrMnTnLJjhwZythPbYVGt5z0N5GJ5fV6Gvuo,541
23
23
  abs_auth_rbac_core/repository/role_repository.py,sha256=OEPpWIm_61rOljPEcejqXyOvowYDK8Uh5K_pvRLfb3Y,562
@@ -27,7 +27,7 @@ abs_auth_rbac_core/service/__init__.py,sha256=zzzxVCUYYb4heFksjbktWqbST3IcTcTfOM
27
27
  abs_auth_rbac_core/service/permission_service.py,sha256=tWasmKe0lr1QokmKzjD08O251_ppTnfN9amqVZX_CCU,661
28
28
  abs_auth_rbac_core/service/role_service.py,sha256=Q68igKS-cArHaq-tqrjWPpptnrXYImRAEwKQep0ZOBQ,633
29
29
  abs_auth_rbac_core/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
- abs_auth_rbac_core/util/permission_constants.py,sha256=EHM4ZkQmMWR-AyoSEf-pJL-EC_eZ4Q_JEp9w62GknHY,102747
31
- abs_auth_rbac_core-0.3.9.dist-info/METADATA,sha256=UvfY5nUeih_TnTo3j1pKrRiP3zne6zLV392313UaPBM,23654
32
- abs_auth_rbac_core-0.3.9.dist-info/WHEEL,sha256=M5asmiAlL6HEcOq52Yi5mmk9KmTVjY2RDPtO4p9DMrc,88
33
- abs_auth_rbac_core-0.3.9.dist-info/RECORD,,
30
+ abs_auth_rbac_core/util/permission_constants.py,sha256=h53UMo_FCgMfDgKpHTChP4tQphp4_3qqm-284vzsJYA,103102
31
+ abs_auth_rbac_core-0.3.11.dist-info/METADATA,sha256=GJnVlgoDQECmuPvXUrleuhUQz0DEkCz_rmwFDBZ0g5s,23644
32
+ abs_auth_rbac_core-0.3.11.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
33
+ abs_auth_rbac_core-0.3.11.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.2.0
2
+ Generator: poetry-core 2.1.2
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any