File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3030from open_webui .models .chats import Chats
3131from open_webui .models .notes import Notes
3232from open_webui .models .access_grants import AccessGrants
33+ from open_webui .utils .access_control .files import has_access_to_file
3334
3435from open_webui .retrieval .vector .main import GetResult
3536from open_webui .utils .headers import include_user_info_headers
@@ -1042,7 +1043,11 @@ async def get_sources_from_items(
10421043 }
10431044 elif item .get ('id' ):
10441045 file_object = Files .get_file_by_id (item .get ('id' ))
1045- if file_object :
1046+ if file_object and (
1047+ user .role == 'admin'
1048+ or file_object .user_id == user .id
1049+ or has_access_to_file (item .get ('id' ), 'read' , user )
1050+ ):
10461051 query_result = {
10471052 'documents' : [[file_object .data .get ('content' , '' )]],
10481053 'metadatas' : [
Original file line number Diff line number Diff line change @@ -42,6 +42,12 @@ async def format_code(form_data: CodeForm, user=Depends(get_admin_user)):
4242
4343@router .post ('/code/execute' )
4444async def execute_code (request : Request , form_data : CodeForm , user = Depends (get_verified_user )):
45+ if not request .app .state .config .ENABLE_CODE_EXECUTION :
46+ raise HTTPException (
47+ status_code = 403 ,
48+ detail = 'Code execution is disabled' ,
49+ )
50+
4551 if request .app .state .config .CODE_EXECUTION_ENGINE == 'jupyter' :
4652 output = await execute_code_jupyter (
4753 request .app .state .config .CODE_EXECUTION_JUPYTER_URL ,
You can’t perform that action at this time.
0 commit comments