File tree Expand file tree Collapse file tree
backend/open_webui/socket Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -697,6 +697,31 @@ async def yjs_document_update(sid, data):
697697 log .warning (f'Session { sid } not in room { room } . Rejecting update.' )
698698 return
699699
700+ # Verify write permission — room membership only proves read access
701+ user = SESSION_POOL .get (sid )
702+ if not user :
703+ return
704+
705+ if document_id .startswith ('note:' ):
706+ note_id = document_id .split (':' )[1 ]
707+ note = await Notes .get_note_by_id (note_id )
708+ if not note :
709+ log .error (f'Note { note_id } not found' )
710+ return
711+
712+ if (
713+ user .get ('role' ) != 'admin'
714+ and user .get ('id' ) != note .user_id
715+ and not await AccessGrants .has_access (
716+ user_id = user .get ('id' ),
717+ resource_type = 'note' ,
718+ resource_id = note .id ,
719+ permission = 'write' ,
720+ )
721+ ):
722+ log .warning (f'User { user .get ("id" )} does not have write access to note { note_id } . Rejecting update.' )
723+ return
724+
700725 try :
701726 await stop_item_tasks (REDIS , document_id )
702727 except Exception :
@@ -724,10 +749,6 @@ async def yjs_document_update(sid, data):
724749 skip_sid = sid ,
725750 )
726751
727- user = SESSION_POOL .get (sid )
728- if not user :
729- return
730-
731752 async def debounced_save ():
732753 await asyncio .sleep (0.5 )
733754 await document_save_handler (document_id , data .get ('data' , {}), user )
You can’t perform that action at this time.
0 commit comments