瀏覽代碼

fix: model update access

Timothy Jaeryang Baek 3 月之前
父節點
當前提交
dd6de749d5
共有 1 個文件被更改,包括 10 次插入0 次删除
  1. 10 0
      backend/open_webui/routers/models.py

+ 10 - 0
backend/open_webui/routers/models.py

@@ -155,6 +155,16 @@ async def update_model_by_id(
             detail=ERROR_MESSAGES.NOT_FOUND,
         )
 
+    if (
+        model.user_id != user.id
+        and not has_access(user.id, "write", model.access_control)
+        and user.role != "admin"
+    ):
+        raise HTTPException(
+            status_code=status.HTTP_400_BAD_REQUEST,
+            detail=ERROR_MESSAGES.ACCESS_PROHIBITED,
+        )
+
     model = Models.update_model_by_id(id, form_data)
     return model