소스 검색

refac: api key auth allowed paths

Timothy Jaeryang Baek 4 달 전
부모
커밋
a2366a20ba
1개의 변경된 파일7개의 추가작업 그리고 0개의 파일을 삭제
  1. 7 0
      backend/open_webui/utils/auth.py

+ 7 - 0
backend/open_webui/utils/auth.py

@@ -95,6 +95,13 @@ def get_current_user(
             raise HTTPException(
                 status.HTTP_403_FORBIDDEN, detail=ERROR_MESSAGES.API_KEY_NOT_ALLOWED
             )
+
+        allowed_paths = ["/api/models", "/api/chat/completions"]
+        if request.url.path not in allowed_paths:
+            raise HTTPException(
+                status.HTTP_403_FORBIDDEN, detail=ERROR_MESSAGES.API_KEY_NOT_ALLOWED
+            )
+
         return get_current_user_by_api_key(token)
 
     # auth by jwt token