refactor(web-search): drop dead api_key path in SearXNG provider
The SearXNG provider forwarded `parameters.api_key` as `Authorization: Bearer <key>` 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.
This commit is contained in:
@@ -27,13 +27,9 @@ const defaultSearxngTimeout = 12 * time.Second
|
|||||||
// supplied by the tenant via WebSearchProviderParameters.BaseURL. The URL is
|
// supplied by the tenant via WebSearchProviderParameters.BaseURL. The URL is
|
||||||
// validated with utils.ValidateURLForSSRF; private/loopback hosts must be added
|
// validated with utils.ValidateURLForSSRF; private/loopback hosts must be added
|
||||||
// to the SSRF_WHITELIST environment variable.
|
// 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 {
|
type SearxngProvider struct {
|
||||||
client *http.Client
|
client *http.Client
|
||||||
baseURL string
|
baseURL string
|
||||||
apiKey string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateSearxngBaseURL validates a SearXNG instance URL: must be a non-empty,
|
// ValidateSearxngBaseURL validates a SearXNG instance URL: must be a non-empty,
|
||||||
@@ -75,7 +71,6 @@ func NewSearxngProvider(params types.WebSearchProviderParameters) (interfaces.We
|
|||||||
return &SearxngProvider{
|
return &SearxngProvider{
|
||||||
client: client,
|
client: client,
|
||||||
baseURL: strings.TrimRight(base, "/"),
|
baseURL: strings.TrimRight(base, "/"),
|
||||||
apiKey: strings.TrimSpace(params.APIKey),
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,11 +110,6 @@ func (p *SearxngProvider) Search(
|
|||||||
}
|
}
|
||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
req.Header.Set("User-Agent", "WeKnora/1.0")
|
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)
|
resp, err := p.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user