feat: tenant isolation Phase 0 — app-layer filters, UUID audit, CI gate #132
@@ -762,13 +762,13 @@ async def search_sessions(
|
|||||||
limit: int = Query(5, ge=1, le=20),
|
limit: int = Query(5, ge=1, le=20),
|
||||||
):
|
):
|
||||||
"""Search AI sessions by content using full-text search. Used by Command Palette."""
|
"""Search AI sessions by content using full-text search. Used by Command Palette."""
|
||||||
|
# Sessions are user-scoped. The list endpoint uses user_id only;
|
||||||
|
# search must be consistent. Cross-user access requires explicit
|
||||||
|
# escalation or session sharing — not ambient account membership.
|
||||||
result = await db.execute(
|
result = await db.execute(
|
||||||
select(AISession)
|
select(AISession)
|
||||||
.where(
|
.where(
|
||||||
or_(
|
AISession.user_id == current_user.id,
|
||||||
AISession.user_id == current_user.id,
|
|
||||||
AISession.account_id == current_user.account_id,
|
|
||||||
),
|
|
||||||
text("ai_sessions.search_vector @@ plainto_tsquery('english', :q)"),
|
text("ai_sessions.search_vector @@ plainto_tsquery('english', :q)"),
|
||||||
)
|
)
|
||||||
.params(q=q)
|
.params(q=q)
|
||||||
|
|||||||
Reference in New Issue
Block a user