abs-auth-rbac-core 0.3.4__tar.gz → 0.3.6__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.

Potentially problematic release.


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

Files changed (33) hide show
  1. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/PKG-INFO +4 -4
  2. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/abs_auth_rbac_core/rbac/service.py +36 -39
  3. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/pyproject.toml +1 -1
  4. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/README.md +0 -0
  5. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/abs_auth_rbac_core/__init__.py +0 -0
  6. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/abs_auth_rbac_core/auth/__init__.py +0 -0
  7. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/abs_auth_rbac_core/auth/auth_functions.py +0 -0
  8. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/abs_auth_rbac_core/auth/jwt_functions.py +0 -0
  9. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/abs_auth_rbac_core/auth/middleware.py +0 -0
  10. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/abs_auth_rbac_core/models/__init__.py +0 -0
  11. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/abs_auth_rbac_core/models/base_model.py +0 -0
  12. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/abs_auth_rbac_core/models/gov_casbin_rule.py +0 -0
  13. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/abs_auth_rbac_core/models/permissions.py +0 -0
  14. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/abs_auth_rbac_core/models/rbac_model.py +0 -0
  15. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/abs_auth_rbac_core/models/role_permission.py +0 -0
  16. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/abs_auth_rbac_core/models/roles.py +0 -0
  17. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/abs_auth_rbac_core/models/seeder/permission_seeder.py +0 -0
  18. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/abs_auth_rbac_core/models/user.py +0 -0
  19. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/abs_auth_rbac_core/models/user_permission.py +0 -0
  20. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/abs_auth_rbac_core/models/user_role.py +0 -0
  21. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/abs_auth_rbac_core/rbac/__init__.py +0 -0
  22. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/abs_auth_rbac_core/rbac/decorator.py +0 -0
  23. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/abs_auth_rbac_core/rbac/policy.conf +0 -0
  24. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/abs_auth_rbac_core/repository/__init__.py +0 -0
  25. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/abs_auth_rbac_core/repository/permission_repository.py +0 -0
  26. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/abs_auth_rbac_core/repository/role_repository.py +0 -0
  27. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/abs_auth_rbac_core/schema/__init__.py +0 -0
  28. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/abs_auth_rbac_core/schema/permission.py +0 -0
  29. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/abs_auth_rbac_core/service/__init__.py +0 -0
  30. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/abs_auth_rbac_core/service/permission_service.py +0 -0
  31. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/abs_auth_rbac_core/service/role_service.py +0 -0
  32. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/abs_auth_rbac_core/util/__init__.py +0 -0
  33. {abs_auth_rbac_core-0.3.4 → abs_auth_rbac_core-0.3.6}/abs_auth_rbac_core/util/permission_constants.py +0 -0
@@ -1,16 +1,16 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: abs-auth-rbac-core
3
- Version: 0.3.4
3
+ Version: 0.3.6
4
4
  Summary: RBAC and Auth core utilities including JWT token management.
5
- License: MIT
5
+ License-Expression: 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
10
9
  Classifier: Programming Language :: Python :: 3
11
10
  Classifier: Programming Language :: Python :: 3.11
12
11
  Classifier: Programming Language :: Python :: 3.12
13
12
  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)
@@ -43,8 +43,8 @@ class RBACService:
43
43
  """
44
44
  self.db = session
45
45
  self.enforcer = None
46
- self.watcher = None
47
46
  self._initialize_casbin(redis_config)
47
+ self.watcher = None
48
48
 
49
49
 
50
50
  def _initialize_casbin(self,redis_config:Optional[RedisWatcherSchema]=None):
@@ -392,7 +392,7 @@ class RBACService:
392
392
  if not role:
393
393
  raise NotFoundError(detail="Requested role does not exist")
394
394
 
395
- return role
395
+ return role
396
396
 
397
397
  def update_role_permissions(
398
398
  self,
@@ -402,6 +402,7 @@ class RBACService:
402
402
  description: Optional[str] = None,
403
403
  ) -> Any:
404
404
  """Update role permissions by replacing all existing permissions with new ones"""
405
+
405
406
  with self.db() as session:
406
407
  try:
407
408
  if not session.is_active:
@@ -438,49 +439,45 @@ class RBACService:
438
439
  role.description = description
439
440
 
440
441
  if permissions is not None:
441
- existing_permissions = role.permissions
442
-
443
- # Remove Casbin policies for existing permissions
444
- remove_policies = [
445
- [role_uuid, existing_permission.resource, existing_permission.action, existing_permission.module]
446
- for existing_permission in existing_permissions
447
- ]
448
- self.enforcer.remove_policies(remove_policies)
449
- self.enforcer.save_policy()
450
-
451
- # Delete existing role permissions
442
+ # Remove ALL existing policies for this role from Casbin
443
+ self.enforcer.remove_filtered_policy(0, str(role_uuid))
444
+
445
+ # Delete existing role permissions from database
452
446
  session.query(RolePermission).filter(
453
447
  RolePermission.role_uuid == role_uuid
454
448
  ).delete(synchronize_session=False)
455
449
 
456
- if permissions:
457
- # Fetch all permissions in a single query
458
- permissions_objs = (
459
- session.query(Permission)
460
- .filter(Permission.uuid.in_(permissions))
461
- .all()
462
- )
463
-
464
- found_permission_ids = {p.uuid for p in permissions_objs}
465
- missing_permission_ids = set(permissions) - found_permission_ids
466
- if missing_permission_ids:
467
- raise NotFoundError(
468
- detail=f"Permissions with UUIDs '{', '.join(missing_permission_ids)}' not found"
450
+ # Add new permissions if provided
451
+ if permissions:
452
+ # Fetch all permissions in a single query
453
+ permissions_objs = (
454
+ session.query(Permission)
455
+ .filter(Permission.uuid.in_(permissions))
456
+ .all()
469
457
  )
470
458
 
471
- # Bulk insert role permissions
472
- role_permissions = [
473
- {"role_uuid": role_uuid, "permission_uuid": permission.uuid}
474
- for permission in permissions_objs
475
- ]
476
- session.bulk_insert_mappings(RolePermission, role_permissions)
477
-
478
- # Add Casbin policies
479
- policies = [
480
- [role_uuid, permission.resource, permission.action, permission.module]
481
- for permission in permissions_objs
482
- ]
483
- self.enforcer.add_policies(policies)
459
+ found_permission_ids = {p.uuid for p in permissions_objs}
460
+ missing_permission_ids = set(permissions) - found_permission_ids
461
+ if missing_permission_ids:
462
+ raise NotFoundError(
463
+ detail=f"Permissions with UUIDs '{', '.join(missing_permission_ids)}' not found"
464
+ )
465
+
466
+ # Bulk insert role permissions
467
+ role_permissions = [
468
+ {"role_uuid": role_uuid, "permission_uuid": permission.uuid}
469
+ for permission in permissions_objs
470
+ ]
471
+ session.bulk_insert_mappings(RolePermission, role_permissions)
472
+
473
+ # Add new Casbin policies
474
+ policies = [
475
+ [role_uuid, permission.resource, permission.action, permission.module]
476
+ for permission in permissions_objs
477
+ ]
478
+ self.enforcer.add_policies(policies)
479
+
480
+ # Save all Casbin changes
484
481
  self.enforcer.save_policy()
485
482
 
486
483
  session.commit()
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "abs-auth-rbac-core"
3
- version = "0.3.4"
3
+ version = "0.3.6"
4
4
  description = "RBAC and Auth core utilities including JWT token management."
5
5
  authors = [
6
6
  {name = "AutoBridgeSystems", email = "info@autobridgesystems.com"}