fix(knowledge): restrict source file download to Editor and above

Downloading exposes the original source file, which is more sensitive than viewing parsed content or previews. Align backend route guards, handler checks, and frontend UI so tenant Viewers and org-shared read-only access cannot download.
This commit is contained in:
wizardchen
2026-07-23 21:11:37 +08:00
committed by lyingbug
parent 697e0ae04e
commit 8cb43473e6
6 changed files with 136 additions and 5 deletions
+4 -1
View File
@@ -1276,7 +1276,10 @@ func (h *KnowledgeHandler) DownloadKnowledgeFile(c *gin.Context) {
return
}
_, effCtx, err := h.resolveKnowledgeAndValidateKBAccess(c, id, types.OrgRoleViewer)
// Keep a handler-level Editor check in addition to the route guard. The
// original file is more sensitive than parsed-content reads and must not
// be downloadable through a read-only organization share.
_, effCtx, err := h.resolveKnowledgeAndValidateKBAccess(c, id, types.OrgRoleEditor)
if err != nil {
c.Error(err)
return