jogosultsági szintek RBAC beállítva tesztelve
This commit is contained in:
@@ -5,6 +5,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from sqlalchemy import select, update, and_
|
||||
from typing import List, Optional, Dict, Any
|
||||
|
||||
from app.api import deps
|
||||
from app.api.deps import get_db, get_current_user
|
||||
from app.schemas.system import (
|
||||
SystemParameterResponse,
|
||||
@@ -114,20 +115,14 @@ async def update_system_parameter(
|
||||
param_in: SystemParameterUpdate,
|
||||
db: AsyncSession = Depends(get_db),
|
||||
current_user=Depends(get_current_user),
|
||||
_ = Depends(deps.RequirePermission("system:manage")),
|
||||
scope_level: ParameterScope = Query("global", description="Scope szint (alapértelmezett: global)"),
|
||||
scope_id: Optional[str] = Query(None, description="Scope azonosító"),
|
||||
):
|
||||
"""
|
||||
Módosítja egy létező paraméter value (JSONB) vagy is_active mezőjét (Admin funkció).
|
||||
Csak superadmin vagy admin jogosultságú felhasználók használhatják.
|
||||
Protected by RequirePermission("system:manage").
|
||||
"""
|
||||
# Jogosultság ellenőrzése
|
||||
if current_user.role not in (UserRole.SUPERADMIN, UserRole.ADMIN):
|
||||
raise HTTPException(
|
||||
status_code=403,
|
||||
detail="Insufficient permissions. Only superadmin or admin can update system parameters."
|
||||
)
|
||||
|
||||
# Paraméter keresése
|
||||
query = select(SystemParameter).where(
|
||||
SystemParameter.key == key,
|
||||
|
||||
Reference in New Issue
Block a user