From f9fc61456357288d31deb11ea39b37cc783bbfa2 Mon Sep 17 00:00:00 2001 From: Alishahryar1 Date: Sun, 10 May 2026 16:02:45 -0700 Subject: [PATCH] Allow unauthenticated root probes --- api/routes.py | 4 ++-- tests/api/test_auth.py | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/api/routes.py b/api/routes.py index d56625da..63455de1 100644 --- a/api/routes.py +++ b/api/routes.py @@ -207,8 +207,8 @@ async def root( @router.api_route("/", methods=["HEAD", "OPTIONS"]) -async def probe_root(_auth=Depends(require_api_key)): - """Respond to compatibility probes for the root endpoint.""" +async def probe_root(): + """Respond to unauthenticated local compatibility probes for the root endpoint.""" return _probe_response("GET, HEAD, OPTIONS") diff --git a/tests/api/test_auth.py b/tests/api/test_auth.py index 99230a32..57ba066a 100644 --- a/tests/api/test_auth.py +++ b/tests/api/test_auth.py @@ -73,3 +73,23 @@ def test_anthropic_auth_token_applies_to_models_endpoint(): assert "data" in r.json() app.dependency_overrides.clear() + + +def test_root_get_requires_auth_but_root_probes_are_public(): + client = TestClient(app) + settings = Settings() + settings.anthropic_auth_token = "root-token" + app.dependency_overrides[get_settings] = lambda: settings + + response = client.get("/") + assert response.status_code == 401 + + head = client.head("/") + assert head.status_code == 204 + assert head.headers["Allow"] == "GET, HEAD, OPTIONS" + + options = client.options("/") + assert options.status_code == 204 + assert options.headers["Allow"] == "GET, HEAD, OPTIONS" + + app.dependency_overrides.clear()