Refine scoped API key capabilities

This commit is contained in:
wizardchen
2026-07-07 11:09:10 +08:00
committed by lyingbug
parent b5cc7d2a28
commit 2c6f082062
38 changed files with 1718 additions and 655 deletions
+3 -5
View File
@@ -54,6 +54,9 @@ func (h *DataSourceHandler) getOwnedKnowledgeBase(
if kb.TenantID != tenantID {
return nil, http.StatusForbidden, "access denied"
}
if err := types.AuthorizeTenantAPIKeyKnowledgeBases(ctx, kbID); err != nil {
return nil, http.StatusForbidden, err.Error()
}
return kb, http.StatusOK, ""
}
@@ -170,11 +173,6 @@ func (h *DataSourceHandler) ListDataSources(c *gin.Context) {
c.JSON(status, gin.H{"error": msg})
return
}
if err := types.AuthorizeTenantAPIKeyKnowledgeBases(ctx, kbID); err != nil {
c.JSON(http.StatusForbidden, gin.H{"error": err.Error()})
return
}
dataSources, err := h.service.ListDataSources(ctx, kbID)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to list data sources"})