feat: enforce permissions in backend (#20471)
* feat: enforce image generation permissions in backend * feat: enforce web search permissions in backend * feat: enforce audio (tts/stt) permissions in backend
This commit is contained in:
@@ -93,6 +93,7 @@ from open_webui.utils.misc import (
|
||||
sanitize_text_for_db,
|
||||
)
|
||||
from open_webui.utils.auth import get_admin_user, get_verified_user
|
||||
from open_webui.utils.access_control import has_permission
|
||||
|
||||
from open_webui.config import (
|
||||
ENV,
|
||||
@@ -2213,6 +2214,19 @@ def search_web(
|
||||
async def process_web_search(
|
||||
request: Request, form_data: SearchForm, user=Depends(get_verified_user)
|
||||
):
|
||||
if not request.app.state.config.ENABLE_WEB_SEARCH:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail=ERROR_MESSAGES.ACCESS_PROHIBITED,
|
||||
)
|
||||
|
||||
if user.role != "admin" and not has_permission(
|
||||
user.id, "features.web_search", request.app.state.config.USER_PERMISSIONS
|
||||
):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail=ERROR_MESSAGES.ACCESS_PROHIBITED,
|
||||
)
|
||||
|
||||
urls = []
|
||||
result_items = []
|
||||
|
||||
Reference in New Issue
Block a user