mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-02 22:01:05 +02:00
fix(authz):publish zero parent tables
This commit is contained in:
parent
2b6bf504ec
commit
08c1d12eb1
3 changed files with 57 additions and 0 deletions
|
|
@ -80,6 +80,28 @@ async def get_user_permissions(
|
|||
return []
|
||||
|
||||
|
||||
async def get_allowed_read_space_ids(
|
||||
session: AsyncSession,
|
||||
auth: AuthContext,
|
||||
) -> list[int]:
|
||||
"""Return search spaces the principal may read through sync transports.
|
||||
|
||||
This mirrors the basic REST search-space access rule: membership is required,
|
||||
and PAT principals are additionally constrained by the per-space API gate.
|
||||
"""
|
||||
stmt = (
|
||||
select(SearchSpaceMembership.search_space_id)
|
||||
.join(SearchSpace, SearchSpace.id == SearchSpaceMembership.search_space_id)
|
||||
.filter(SearchSpaceMembership.user_id == auth.user.id)
|
||||
.order_by(SearchSpaceMembership.search_space_id)
|
||||
)
|
||||
if auth.is_gated:
|
||||
stmt = stmt.filter(SearchSpace.api_access_enabled == True) # noqa: E712
|
||||
|
||||
result = await session.execute(stmt)
|
||||
return list(result.scalars().all())
|
||||
|
||||
|
||||
async def _enforce_api_access_gate(
|
||||
session: AsyncSession,
|
||||
auth: AuthContext,
|
||||
|
|
|
|||
|
|
@ -52,6 +52,16 @@ AUTOMATION_RUN_COLS = [
|
|||
"created_at",
|
||||
]
|
||||
|
||||
AUTOMATION_COLS = [
|
||||
"id",
|
||||
"search_space_id",
|
||||
]
|
||||
|
||||
NEW_CHAT_THREAD_COLS = [
|
||||
"id",
|
||||
"search_space_id",
|
||||
]
|
||||
|
||||
# Enough to drive the lifecycle UI by push: status, the reviewable brief, and
|
||||
# its version. The bulky source_content and transcript are deliberately excluded
|
||||
# and fetched over REST when a gate opens.
|
||||
|
|
@ -73,10 +83,12 @@ ZERO_PUBLICATION: Mapping[str, Sequence[str] | None] = {
|
|||
"documents": DOCUMENT_COLS,
|
||||
"folders": None,
|
||||
"search_source_connectors": None,
|
||||
"new_chat_threads": NEW_CHAT_THREAD_COLS,
|
||||
"new_chat_messages": None,
|
||||
"chat_comments": None,
|
||||
"chat_session_state": None,
|
||||
"user": USER_COLS,
|
||||
"automations": AUTOMATION_COLS,
|
||||
"automation_runs": AUTOMATION_RUN_COLS,
|
||||
"podcasts": PODCAST_COLS,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue