abs-auth-rbac-core 0.1.3__py3-none-any.whl → 0.1.5__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.
- abs_auth_rbac_core/auth/middleware.py +1 -1
- abs_auth_rbac_core/rbac/decorator.py +7 -6
- {abs_auth_rbac_core-0.1.3.dist-info → abs_auth_rbac_core-0.1.5.dist-info}/METADATA +1 -1
- {abs_auth_rbac_core-0.1.3.dist-info → abs_auth_rbac_core-0.1.5.dist-info}/RECORD +5 -5
- {abs_auth_rbac_core-0.1.3.dist-info → abs_auth_rbac_core-0.1.5.dist-info}/WHEEL +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from functools import wraps
|
|
2
2
|
from typing import Dict, List, Union
|
|
3
|
-
|
|
3
|
+
from fastapi import Request
|
|
4
4
|
from abs_exception_core.exceptions import PermissionDeniedError
|
|
5
5
|
from .service import RBACService
|
|
6
6
|
|
|
@@ -20,10 +20,11 @@ def rbac_require_permission(permissions: Union[str, List[str]]):
|
|
|
20
20
|
def decorator(func):
|
|
21
21
|
@wraps(func)
|
|
22
22
|
async def wrapper(
|
|
23
|
-
|
|
23
|
+
request:Request,
|
|
24
|
+
*args,rbac_service:RBACService, **kwargs,
|
|
24
25
|
):
|
|
25
|
-
|
|
26
|
-
if not
|
|
26
|
+
current_user_uuid = request.state.user.uuid
|
|
27
|
+
if not current_user_uuid:
|
|
27
28
|
raise PermissionDeniedError(
|
|
28
29
|
detail="User not found (missing 'uuid')."
|
|
29
30
|
)
|
|
@@ -36,13 +37,13 @@ def rbac_require_permission(permissions: Union[str, List[str]]):
|
|
|
36
37
|
)
|
|
37
38
|
|
|
38
39
|
has_permission = rbac_service.check_permission(
|
|
39
|
-
user_uuid=
|
|
40
|
+
user_uuid=current_user_uuid, resource=resource, action=action,module=module
|
|
40
41
|
)
|
|
41
42
|
|
|
42
43
|
if not has_permission:
|
|
43
44
|
raise PermissionDeniedError(
|
|
44
45
|
detail=f"Permission denied: {action} on {resource} in {module}"
|
|
45
46
|
)
|
|
46
|
-
return await func(*args,
|
|
47
|
+
return await func(*args,request=request,rbac_service=rbac_service, **kwargs)
|
|
47
48
|
return wrapper
|
|
48
49
|
return decorator
|
|
@@ -2,7 +2,7 @@ abs_auth_rbac_core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
|
|
|
2
2
|
abs_auth_rbac_core/auth/__init__.py,sha256=Pvetd98VD9jsok1F9e82yS9kLZMFqTpbN51hkxZQHzw,67
|
|
3
3
|
abs_auth_rbac_core/auth/auth_functions.py,sha256=fhfKRhtpE_J9MHu2jSsIA-cy77A3wCAQKbGGZeh4pe4,947
|
|
4
4
|
abs_auth_rbac_core/auth/jwt_functions.py,sha256=9vhjWrxXdE8fVQ4FGrPj9y6PoSEsaeFohPhgI-3hToI,4111
|
|
5
|
-
abs_auth_rbac_core/auth/middleware.py,sha256=
|
|
5
|
+
abs_auth_rbac_core/auth/middleware.py,sha256=Hn5EoDE2zEWXHXTgrSFgE85s0ivzFNTxYIqtgLBdtGE,1849
|
|
6
6
|
abs_auth_rbac_core/models/__init__.py,sha256=HHnXZ1wIq6Us3MP9YywjHVeCViXD_zyMWl8mBglqFBc,231
|
|
7
7
|
abs_auth_rbac_core/models/base_model.py,sha256=AaWObslm8sTetv4H1Ia_gPpi_75uF5z1o7Et9WAvstU,612
|
|
8
8
|
abs_auth_rbac_core/models/gov_casbin_rule.py,sha256=uWkzOgtG0_8CXR4YLBz_JINA8apcB1D4aWiCgSkuTCs,789
|
|
@@ -14,11 +14,11 @@ abs_auth_rbac_core/models/seeder/permission_seeder.py,sha256=j-aUy8uLHnUWpMmw1Dq
|
|
|
14
14
|
abs_auth_rbac_core/models/user.py,sha256=t_ardJOsfBiyedPg6Z4WywLiZRTPmAGYkMealZcEqJc,833
|
|
15
15
|
abs_auth_rbac_core/models/user_role.py,sha256=20pqmtJPzlUrI9ulHGouk8XlFgrGG7I6ikctb8sMUGs,706
|
|
16
16
|
abs_auth_rbac_core/rbac/__init__.py,sha256=oYjtpmfrkEbwWCBAWuRoU1fM4fCpBxkF_lwQrelK1As,79
|
|
17
|
-
abs_auth_rbac_core/rbac/decorator.py,sha256=
|
|
17
|
+
abs_auth_rbac_core/rbac/decorator.py,sha256=pEFAW0Nn2iE4KBctPhNOmO_VLeJFDX2V9v2LsCu6kHY,1824
|
|
18
18
|
abs_auth_rbac_core/rbac/policy.conf,sha256=wghhhKxgZH0rPhh1QFrIpq9nevJT3s7OxxvXiU3zzuI,305
|
|
19
19
|
abs_auth_rbac_core/rbac/service.py,sha256=C0LTqnyecePrLSh2bAAhO9xcwZ_UAfi4CREczgcQNWc,25206
|
|
20
20
|
abs_auth_rbac_core/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
21
21
|
abs_auth_rbac_core/util/permission_constants.py,sha256=JFavEKkAJ5mtltttCwRTTtpRlu_mJiVPB_MwsP-bIAg,65337
|
|
22
|
-
abs_auth_rbac_core-0.1.
|
|
23
|
-
abs_auth_rbac_core-0.1.
|
|
24
|
-
abs_auth_rbac_core-0.1.
|
|
22
|
+
abs_auth_rbac_core-0.1.5.dist-info/METADATA,sha256=u8NkhHcDG7OTAs079Azw3bv-pXGCJU3UnDJNmZyJTs4,6586
|
|
23
|
+
abs_auth_rbac_core-0.1.5.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
|
24
|
+
abs_auth_rbac_core-0.1.5.dist-info/RECORD,,
|
|
File without changes
|