Files
magpie/docs
RainierandClaude Opus 5.5 db4da33bc6 gateway: a LazyCat box's X-HC-* headers go on only to a provider whose PassHeaders names them (#5987)
On a LazyCat box (懒猫微服) every app sits behind the box's ingress,
lzc-ingress, which puts on each request it passes the app who sent it:
the box account (X-HC-User-ID), its role (X-HC-User-Role), what sent it
(X-HC-Source), the device (X-HC-Device-ID, -PeerID and -Version) and
when it signed in (X-HC-Login-Time); the box's docs name
X-HC-User-Groups and X-HC-User-Ticket too. A request signed in to the
box gets them on the app's public paths as well, where a package serves
the gateway's client routes. The native route, the Codex passthrough and
relay to the ChatGPT backend (copyHeaders) and /mcp/<server> passed them
all on, so a vendor, the ChatGPT backend or a remote MCP server was told
the box account's name and role and the device's ids.

proxyIdentity takes any X-Hc-* as what a proxy says of the caller, as
it takes Tailscale-*, so nativeHeaderDropped, copyHeaders and the MCP
proxy's header loop skip them. lzc-ingress's X-Forwarded-By was dropped
already (X-Forwarded-*). What 7d196b679 checked and left stays as it
is: a provider's PassHeaders passes on the names it lists, these too, as
the user chose them (gateway-routing.md now says so); Codex's
allow-listed codexHeader, the Codex websocket's headers (taken from a
request magpie built) and passOnCaller are as they were.

What the ingress puts there was read off a probe app on a box (lzcos
1.6.2+fix.4) that echoes its request headers: a browser signed in to
the box got X-HC-User-ID, X-HC-User-Role ADMIN, X-HC-Source client,
X-HC-Device-ID, -PeerID, -Version and X-HC-Login-Time, on a public path
the same as on /.

Tests: TestNativeAnyDropsProxyIdentity and
TestPassthroughDropsProxyIdentity send ten X-HC-* headers and
X-Forwarded-By beside the twelve they sent, and check that none arrive
and X-Custom still does.

Run (macOS 27.2, go1.26.8 darwin/arm64), at this tree, on 6c3f113ce:
gofmt clean; go vet, GOOS=linux -tags nogui go vet and GOOS=windows go
vet of internal/gateway clean; go build -tags nogui ok; both tests ok.
The next commit adds a test to internal/gateway and changes nothing else
of it; the whole package ran there: ok.

Broken by hand: with the X-Hc- prefix out of proxyIdentity, both are
red: the native vendor, the ChatGPT backend and the MCP server were each
told all ten X-HC-* headers.

Not tried: a real vendor call through a box; a provider whose
PassHeaders names an X-HC-* header.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 10:15:40 +08:00
..