From 5fb7e692e54589b353306257f3f474671758508b Mon Sep 17 00:00:00 2001 From: wizardchen Date: Mon, 11 May 2026 16:21:01 +0800 Subject: [PATCH] refactor(web-search): drop dead api_key path in SearXNG provider The SearXNG provider forwarded `parameters.api_key` as `Authorization: Bearer ` for reverse-proxy auth, but the frontend never rendered the API key input for self-hosted providers (`requires_api_key=false`), so the path was unreachable from the UI. Rather than expose another UI knob for a niche reverse-proxy setup that the project does not currently support, remove the Authorization header branch and the `apiKey` field on `SearxngProvider`. Tenants who put SearXNG behind an authenticating reverse proxy can still front it with network-level auth (mTLS, IP allowlist) without changes here. `WebSearchProviderParameters.APIKey` is generic and used by other providers, so it stays. --- internal/infrastructure/web_search/searxng.go | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/internal/infrastructure/web_search/searxng.go b/internal/infrastructure/web_search/searxng.go index e240bf0b..b9d505fb 100644 --- a/internal/infrastructure/web_search/searxng.go +++ b/internal/infrastructure/web_search/searxng.go @@ -27,13 +27,9 @@ const defaultSearxngTimeout = 12 * time.Second // supplied by the tenant via WebSearchProviderParameters.BaseURL. The URL is // validated with utils.ValidateURLForSSRF; private/loopback hosts must be added // to the SSRF_WHITELIST environment variable. -// -// API key is optional and only required when the SearXNG instance enables it -// (server.secret_key with limiter / json format restrictions). type SearxngProvider struct { client *http.Client baseURL string - apiKey string } // ValidateSearxngBaseURL validates a SearXNG instance URL: must be a non-empty, @@ -75,7 +71,6 @@ func NewSearxngProvider(params types.WebSearchProviderParameters) (interfaces.We return &SearxngProvider{ client: client, baseURL: strings.TrimRight(base, "/"), - apiKey: strings.TrimSpace(params.APIKey), }, nil } @@ -115,11 +110,6 @@ func (p *SearxngProvider) Search( } req.Header.Set("Accept", "application/json") req.Header.Set("User-Agent", "WeKnora/1.0") - if p.apiKey != "" { - // SearXNG does not have a built-in auth header; the api_key field is reused - // to support reverse-proxies that gate access via Authorization. - req.Header.Set("Authorization", "Bearer "+p.apiKey) - } resp, err := p.client.Do(req) if err != nil {