feat(http): add opt-in static authentication - #3175
Conversation
…auth # Conflicts: # pkg/http/handler_test.go
Staff AppSec (HTTP static-auth)Verdict: Approve with comments (conversation comment — formal review UI often disabled here.) Opt-in Residual (acknowledge on merge): this authenticates callers to the MCP server with nothing — any non-browser client that can reach the socket and omits Non-blocking asks: (1) loud startup warning when static auth is on and listen host is not loopback; (2) startup warning when static auth is on without Refs #2946. |
Summary
Add explicit opt-in static authentication for single-tenant HTTP deployments.
When enabled, requests without an
Authorizationheader use the processGITHUB_PERSONAL_ACCESS_TOKEN; per-request credentials remain authoritative.Why
HTTP mode currently requires every caller to supply an
Authorizationheader,even when a single-tenant deployment already has a service credential in the
process environment. Gateways and tunnels that cannot inject custom headers
therefore receive a 401 for every request.
Fixes #2946
What changed
--static-authflag andGITHUB_STATIC_AUTHenvironmentequivalent, with startup validation for the configured token.
Authorizationheader is absent; explicit empty,malformed, or unsupported headers remain errors.
shared-credential security boundary.
credential, while preserving explicit bearer-token CORS and OAuth metadata.
MCP impact
HTTP transport authentication behavior changes only when static auth is
explicitly enabled. MCP tool definitions and schemas are unchanged.
Prompts tested (tool changes only)
Security / limits
Static authentication is disabled by default. When enabled, every caller that
omits the header receives the shared credential's permissions, so the docs
require an authenticating trusted gateway or access boundary and recommend
least privilege and
--read-only; loopback alone is not presented asauthentication. Browser-origin requests cannot consume the fallback token.
Explicit request credentials always take precedence, and configuration errors
never include the token value.
Tool renaming
deprecated_tool_aliases.goNo tools are renamed.
Lint & tests
./script/lint./script/test./script/lintreports zero issues../script/testand an uncached focusedgo test -race -count=1 ./pkg/utils ./pkg/http/... ./cmd/github-mcp-serverboth pass.
Docs
Updated
docs/streamable-http.mdwith configuration, precedence, startupvalidation, browser-origin behavior, and shared-credential safety guidance.