feat(backend): enforce admin-only ops endpoints and cover destructive cleanup smoke
restrict ops endpoints to admin-only access block operator and viewer keys from admin maintenance routes cover destructive pricing cleanup in smoke execution, not only preview extend orchestration without regressing existing smoke stages
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from fastapi import Header, HTTPException, status
|
||||
from fastapi import Depends, Header, HTTPException, status
|
||||
|
||||
from app.core.config import settings
|
||||
from app.domain.roles import UserRole
|
||||
@@ -31,3 +31,12 @@ async def require_api_key(
|
||||
)
|
||||
|
||||
return role
|
||||
|
||||
|
||||
async def require_admin_api_key(role: str = Depends(require_api_key)) -> str:
|
||||
if role != UserRole.ADMIN.value:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="Admin role required",
|
||||
)
|
||||
return role
|
||||
|
||||
Reference in New Issue
Block a user