Repository navigation
fix(api): restore accessible check on document preview - #15505
Conversation
Re-add DocumentService.accessible removed in infiniflow#15146 so GET /documents/{doc_id}/preview cannot leak cross-tenant files. Fixes infiniflow#15501
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe PR restores a missing authorization check in the document preview endpoint ( ChangesDocument Preview Authorization Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hi, @wangq8 , @Haruko386 , @JinHai-CN @yingfeng @xugangqiang |
|
@buua436 please help to review. |
buua436
left a comment
There was a problem hiding this comment.
This fix may affect the preview behavior of embedded chat.
|
@buua436 Thanks — understood. This restores the pre-#15146 If you have a failing setup, please share repro steps. Thanks again |
Resolve document_api import conflict: keep accessible check and AUTH_BETA embed auth from main.
9c8a414 to
dee365b
Compare
The /documents/<doc_id>/preview handler gained a duplicate DocumentService.accessible() check (infiniflow#15505) placed before get_by_id, on top of the canonical post-existence check (infiniflow#15508). The early call makes the handler probe access for a missing doc, which the infiniflow#15501 regression test forbids and which leaks a server_error instead of 'Document not found!'. Remove the redundant check (line 1928 still enforces access, so cross-tenant reads stay blocked). Also extend the test's api.apps stub with AUTH_JWT/AUTH_API/AUTH_BETA and a factory-aware login_required so loading document_api.py (which now imports those constants via infiniflow#15581) does not fail at import time.
Restore
DocumentService.accessibleonGET /api/v1/documents/{doc_id}/previewso cross-tenant users cannot stream documents by UUID.Fixes #15501
What problem does this PR solve?
PR #15146 (
71a52d579) moved the agent attachment download route and accidentally removed theDocumentService.accessible(doc_id, current_user.id)guard from the REST preview handler. The endpoint still requires login, but any authenticated user who knows another tenant'sdoc_idcan download the raw file bytes.This restores the same authorization check that existed before #15146, returning a generic
"Document not found!"when access is denied (no cross-tenant ID enumeration). SDK download routes tracked in #15125 are unchanged.Type of change