4646 VerticesOrderResponse ,
4747)
4848from langflow .exceptions .component import ComponentBuildError
49- from langflow .services .auth .utils import get_current_active_user , get_current_user_optional
49+ from langflow .services .auth .utils import get_current_user_optional
5050from langflow .services .authorization import FlowAction , ensure_flow_permission
5151from langflow .services .authorization .fetch import deny_to_404
5252from langflow .services .chat .service import ChatService
@@ -690,12 +690,12 @@ async def _stream_vertex(flow_id: str, vertex_id: str, chat_service: ChatService
690690 "/build/{flow_id}/{vertex_id}/stream" ,
691691 response_class = StreamingResponse ,
692692 deprecated = True ,
693- dependencies = [Depends (get_current_active_user )],
694693 include_in_schema = False ,
695694)
696695async def build_vertex_stream (
697696 flow_id : uuid .UUID ,
698697 vertex_id : str ,
698+ current_user : CurrentActiveUser ,
699699):
700700 """Build a vertex instead of the entire graph.
701701
@@ -722,6 +722,28 @@ async def build_vertex_stream(
722722 Raises:
723723 HTTPException: If an error occurs while building the vertex.
724724 """
725+ # The cache is keyed only by flow UUID and may contain another user's
726+ # in-memory graph. Authorize before constructing the streaming response so
727+ # an authenticated non-owner cannot read a built result or invoke
728+ # ``vertex.stream()`` on that cached graph.
729+ async with session_scope () as session :
730+ stmt = (
731+ select (Flow )
732+ .where (Flow .id == flow_id )
733+ .where ((Flow .user_id == current_user .id ) | (Flow .access_type == AccessTypeEnum .PUBLIC ))
734+ )
735+ flow = (await session .exec (stmt )).first ()
736+ if not flow :
737+ raise HTTPException (status_code = 404 , detail = f"Flow with id { flow_id } not found" )
738+ await ensure_flow_permission (
739+ current_user ,
740+ FlowAction .EXECUTE ,
741+ flow_id = flow_id ,
742+ flow_user_id = flow .user_id ,
743+ workspace_id = flow .workspace_id ,
744+ folder_id = flow .folder_id ,
745+ )
746+
725747 try :
726748 return StreamingResponse (
727749 _stream_vertex (str (flow_id ), vertex_id , get_chat_service ()),
0 commit comments