Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
fix(router): allow scoped API keys to poll FAQ import progress
wizardchenabcecc870a78
diff --git a/internal/router/router.go b/internal/router/router.goindex 22b0883fa..5a3fe2d2e 100644--- a/internal/router/router.go+++ b/internal/router/router.go@@ -387,11 +387,14 @@ func RegisterFAQRoutes(r *gin.RouterGroup, handler *handler.FAQHandler, g *rbacG// FAQ import result display statusfaq.PUT("/import/last-result/display", g.OwnedKBOrAdmin(), g.KBAccessWrite("id"), handler.UpdateLastImportResultDisplayStatus)}- // FAQ import progress route (outside of knowledge-base scope) — Viewer+- faqImport := r.Group("/faq/import")- {- faqImport.GET("/progress/:task_id", g.Viewer(), handler.GetImportProgress)- }+ // FAQ import progress route (outside of knowledge-base scope) — Viewer+.+ // Scoped API keys that can ingest (they start the import) or retrieve may+ // poll their own import/dry-run progress. The task is tenant-scoped by+ // requireTaskProgressTenant, so a key only ever sees its own tenant's+ // tasks. Declared through apiKeyRoute so the APIKeyGate doesn't fail-closed+ // and 403 the poller with "scope does not allow this operation".+ g.apiKeyRoute(r, http.MethodGet, "/faq/import/progress/:task_id",+ apiKeyRetrieve(apiKeyIngest(apiKeyFullAccess())), g.Viewer(), handler.GetImportProgress)}// RegisterKnowledgeBaseRoutes 注册知识库相关的路由diff --git a/internal/router/router_api_key_capabilities_test.go b/internal/router/router_api_key_capabilities_test.goindex 3b4df336c..46b0c989b 100644--- a/internal/router/router_api_key_capabilities_test.go+++ b/internal/router/router_api_key_capabilities_test.go@@ -401,6 +401,25 @@ func TestChunkerPreviewRouteRequiresRetrieveOrIngestCapability(t *testing.T) {}}+func TestFAQImportProgressRouteRequiresRetrieveOrIngestCapability(t *testing.T) {+ gin.SetMode(gin.TestMode)+ g := &rbacGuards{}+ v1 := gin.New().Group("/api/v1")++ RegisterFAQRoutes(v1, &handler.FAQHandler{}, g)++ policy := mustLookupAPIKeyPolicy(t, g, http.MethodGet, "/api/v1/faq/import/progress/:task_id")+ if !policy.RequireFullAccess {+ t.Fatal("policy should require full access without a matching capability")+ }+ if !policyHasCapability(policy, types.APIKeyCapabilityRetrieve) {+ t.Fatalf("policy capabilities = %#v, want retrieve", policy.Capabilities)+ }+ if !policyHasCapability(policy, types.APIKeyCapabilityIngest) {+ t.Fatalf("policy capabilities = %#v, want ingest", policy.Capabilities)+ }+}+func mustLookupAPIKeyPolicy(t *testing.T,g *rbacGuards,