mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-17 10:15:27 -04:00
fix: scope chat active-document lookup to the session owner (#569)
This commit is contained in:
@@ -23,6 +23,7 @@ from src.prompt_security import untrusted_context_message
|
||||
from core.exceptions import SessionNotFoundError
|
||||
from src.auth_helpers import get_current_user
|
||||
from routes.session_routes import _verify_session_owner
|
||||
from routes.document_helpers import _owner_session_filter
|
||||
from core.database import SessionLocal, get_session_mode, set_session_mode
|
||||
from core.database import Session as DBSession, ChatMessage as DBChatMessage
|
||||
from core.database import Document as DBDocument, ModelEndpoint
|
||||
@@ -424,9 +425,12 @@ def setup_chat_routes(
|
||||
try:
|
||||
if active_doc_id:
|
||||
logger.info(f"[doc-inject] active_doc_id from frontend: {active_doc_id}")
|
||||
active_doc = _doc_db.query(DBDocument).filter(
|
||||
DBDocument.id == active_doc_id,
|
||||
).first()
|
||||
# Scope to the caller's documents. The session and in-memory
|
||||
# fallbacks below are already owner/session-bound; this
|
||||
# explicit-id path looked up by id alone, so a user could
|
||||
# inject another user's document by passing its id.
|
||||
_doc_q = _doc_db.query(DBDocument).filter(DBDocument.id == active_doc_id)
|
||||
active_doc = _owner_session_filter(_doc_q, ctx.user).first()
|
||||
if active_doc:
|
||||
logger.info(f"[doc-inject] found by ID: title={active_doc.title!r}, lang={active_doc.language!r}, is_active={active_doc.is_active}, content_len={len(active_doc.current_content or '')}")
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user