mirror of
https://github.com/idrainformatica/PecFlow.git
synced 2026-06-16 12:45:42 +02:00
Ruolo supervisor
This commit is contained in:
@@ -153,6 +153,20 @@ async def require_super_admin(
|
||||
return current_user
|
||||
|
||||
|
||||
async def require_supervisor_or_admin(
|
||||
current_user: Annotated[User, Depends(get_current_user)],
|
||||
) -> User:
|
||||
"""
|
||||
Richiede ruolo supervisor, admin o super_admin.
|
||||
|
||||
Il supervisor ha accesso in lettura implicito a tutte le caselle del tenant
|
||||
ma non puo' gestire la configurazione (caselle, utenti, permessi, impostazioni).
|
||||
"""
|
||||
if not current_user.is_supervisor_or_admin:
|
||||
raise ForbiddenError("Richiesto ruolo supervisore o amministratore")
|
||||
return current_user
|
||||
|
||||
|
||||
# ─── Protezione endpoint admin con X-Admin-Key header ─────────────────────────
|
||||
|
||||
async def verify_admin_key(
|
||||
@@ -176,4 +190,5 @@ CurrentUser = Annotated[User, Depends(get_current_user)]
|
||||
CurrentTenant = Annotated[Tenant, Depends(get_current_tenant)]
|
||||
AdminUser = Annotated[User, Depends(require_admin)]
|
||||
SuperAdminUser = Annotated[User, Depends(require_super_admin)]
|
||||
SupervisorOrAdminUser = Annotated[User, Depends(require_supervisor_or_admin)]
|
||||
DB = Annotated[AsyncSession, Depends(get_db)]
|
||||
|
||||
Reference in New Issue
Block a user