Skip to content

Commit

Permalink
Admins bypass rbac
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchop committed Jan 3, 2025
1 parent 5958ace commit bee98e1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions core/schemas/rbac.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def permission_on_target(permission: int):
def decorator(func):
@wraps(func)
async def wrapper(*args, httpreq: Request, **kwargs):
if not RBAC_ENABLED:
if not RBAC_ENABLED or httpreq.state.user.admin:
return func(*args, httpreq=httpreq, **kwargs)
if httpreq.state.user.global_role & permission == permission:
return func(*args, httpreq=httpreq, **kwargs)
Expand All @@ -59,7 +59,7 @@ def decorator(func):
@wraps(func)
async def wrapper(*args, httpreq: Request, **kwargs):
ids: list[str] = kwargs["request"].ids
if not RBAC_ENABLED:
if not RBAC_ENABLED or httpreq.state.user.admin:
return func(*args, httpreq=httpreq, **kwargs)
if httpreq.state.user.global_role & permission == permission:
return func(*args, httpreq=httpreq, **kwargs)
Expand All @@ -83,7 +83,7 @@ def global_permission(permission: int):
def decorator(func):
@wraps(func)
async def wrapper(*args, httpreq: Request, **kwargs):
if not RBAC_ENABLED:
if not RBAC_ENABLED or httpreq.state.user.admin:
return func(*args, httpreq=httpreq, **kwargs)
if httpreq.state.user.global_role & permission == permission:
return func(*args, httpreq=httpreq, **kwargs)
Expand Down

0 comments on commit bee98e1

Please sign in to comment.