feat: exempt /api/instance-info from auth

This commit is contained in:
Brian Krabach
2026-03-30 20:54:21 -07:00
parent 395278818f
commit e61efd141c
2 changed files with 14 additions and 1 deletions
+1 -1
View File
@@ -134,7 +134,7 @@ def authenticate_pam(username: str, password: str) -> bool:
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Paths that bypass auth (login page itself, static assets it needs) # Paths that bypass auth (login page itself, static assets it needs)
_AUTH_EXEMPT_PATHS = {"/login", "/auth/mode", "/auth/logout"} _AUTH_EXEMPT_PATHS = {"/login", "/auth/mode", "/auth/logout", "/api/instance-info"}
# Socket-level localhost addresses — cannot be forged via HTTP headers # Socket-level localhost addresses — cannot be forged via HTTP headers
_LOCALHOST_ADDRS = {"127.0.0.1", "::1"} _LOCALHOST_ADDRS = {"127.0.0.1", "::1"}
+13
View File
@@ -447,3 +447,16 @@ def test_resolve_auth_generates_password_as_last_resort(monkeypatch, capsys, tmp
assert len(pw) > 10 assert len(pw) > 10
assert "generated" in captured.err assert "generated" in captured.err
assert pw in captured.err assert pw in captured.err
def test_middleware_instance_info_path_excluded():
"""/api/instance-info is excluded from auth (public metadata endpoint)."""
app = _make_test_app()
@app.get("/api/instance-info")
async def instance_info():
return PlainTextResponse("info")
client = TestClient(app, base_url="http://192.168.1.1")
response = client.get("/api/instance-info")
assert response.status_code == 200