feat: add support for SearXNG HTTP basic authentication

This commit is contained in:
Michael
2026-06-30 22:37:05 +02:00
parent 5203cf89a0
commit 031c3461df
3 changed files with 41 additions and 7 deletions
+9 -2
View File
@@ -26,7 +26,7 @@ from duckduckgo_search.exceptions import ( # type: ignore[import-untyped]
RatelimitException,
)
from gitea.config import SEARXNG_URL
from gitea.config import SEARXNG_URL, SEARXNG_USERNAME, SEARXNG_PASSWORD
logger: logging.Logger = logging.getLogger("research-tools")
@@ -38,6 +38,9 @@ _USER_AGENT: str = (
)
# SearXNG instance
_SEARXNG_URL: str = SEARXNG_URL
_SEARXNG_USERNAME: str = SEARXNG_USERNAME
_SEARXNG_PASSWORD: str = SEARXNG_PASSWORD
@@ -196,9 +199,13 @@ class ResearchTools:
if time_range:
params["time_range"] = time_range
auth = None
if _SEARXNG_USERNAME and _SEARXNG_PASSWORD:
auth = (_SEARXNG_USERNAME, _SEARXNG_PASSWORD)
try:
with httpx.Client(
timeout=_DEFAULT_TIMEOUT, follow_redirects=True
timeout=_DEFAULT_TIMEOUT, follow_redirects=True, auth=auth
) as client:
response = client.get(
f"{_SEARXNG_URL}/search",