Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Add Authorization checks (#2209)

LiuHua4d9e9f0dbb00
diff --git a/api/apps/kb_app.py b/api/apps/kb_app.py
index 5072d14a97..6bbd02ee5b 100644
--- a/api/apps/kb_app.py
+++ b/api/apps/kb_app.py
@@ -100,6 +100,15 @@ def update():
def detail():
kb_id = request.args["kb_id"]
try:
+ tenants = TenantService.get_joined_tenants_by_user_id(current_user.id)
+ for m in tenants:
+ if KnowledgebaseService.query(
+ tenant_id=m["tenant_id"], id=kb_id):
+ break
+ else:
+ return get_json_result(
+ data=False, retmsg=f'Only owner of knowledgebase authorized for this operation.',
+ retcode=RetCode.OPERATING_ERROR)
kb = KnowledgebaseService.get_detail(kb_id)
if not kb:
return get_data_error_result(