Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions tools/server/server-http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,20 @@ bool server_http_context::init(const common_params & params) {
"/v1/health",
"/models",
"/v1/models",
"/api/tags"
"/api/tags",
"/",
"/index.html",
"/bundle.js",
"/bundle.css",
};

// If API key is not set, skip validation
if (api_keys.empty()) {
return true;
}

// If path is public or is static file, skip validation
if (public_endpoints.find(req.path) != public_endpoints.end() || req.path == "/") {
// If path is public or static file, skip validation
if (public_endpoints.find(req.path) != public_endpoints.end()) {
return true;
}

Expand Down
9 changes: 9 additions & 0 deletions tools/server/tests/unit/test_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ def test_access_public_endpoint(endpoint: str):
assert "error" not in res.body


def test_access_static_assets_without_api_key():
"""Static web UI assets should not require API key authentication (issue #21229)"""
global server
server.start()
for path in ["/", "/bundle.js", "/bundle.css"]:
res = server.make_request("GET", path)
assert res.status_code == 200, f"Expected 200 for {path}, got {res.status_code}"


@pytest.mark.parametrize("api_key", [None, "invalid-key"])
def test_incorrect_api_key(api_key: str):
global server
Expand Down
Loading