Files
magpie/docs
yetone f64c7e54f1 provider: a Remote magpie's cards, limits and router go with its client certificate (#6413)
hhdaxia on X (0.1.4258), and Linsenx in #6413 with a patch: a Remote
magpie behind mTLS, with Client certificate and Server CA set on the
provider, answered model calls, but Usage → Overview's read of its
cards went without the certificate. The remote's TLS refused it, and
the 403 was then shown as "remote magpie isn't shared".

Two causes, both fixed for the class:

- magpie's own requests to a Remote magpie built their context without
  p.Via, so they missed the provider's proxy, client certificate,
  Server CA, unchecked TLS and pin. Via now goes in at the three choke
  points every such request goes through:
  - remoteBodyAs: cards, refresh, quota history, Codex reset, Library,
    version/update, the root /v1 that finds the MCP router;
  - askRemoteKeyLimit: a key's limit;
  - waitRemoteList: the model list's wait.
  The Library server for a Remote magpie's MCP router (/mcp/magpie/hub)
  is checked and called through checkTransport. That transport now goes
  through ViaRemoteMagpieAt, which applies the Remote magpie provider
  whose address matches.
- Every 403 without a key code was read as "isn't shared". remoteRefused
  now gives that only when the remote says "shared on the local
  network", which every not-shared 403 the gateway writes says. Any
  other refusal (magpie's own client-certificate 403, a proxy's page,
  an empty body) is shown with its status and the remote's own words,
  or names a client certificate check or a proxy in front.

Model calls, the connection test, sign-in and the cert peek already
carried Via; a grep of every NewRequest to a remote address found no
other route.

Tests:
- TestRemoteMagpieOwnRequestsShowClientCert: a real httptest TLS server
  with RequireAndVerifyClientCert and a cert from mtls.Store. It checks
  cards, quota history, key limit, root and list wait.
- TestRemoteForbiddenSaysWhatRefused: 403 bodies for not shared (JSON
  and lanGuard text), magpie's client-cert text, an nginx page and an
  empty body, through both remoteBody and askRemoteKeyLimit.
- TestRemoteMagpieRouterShowsClientCert (library): CheckServer on the
  router behind mTLS is refused with the CA alone and ok with the
  provider's certificate.
- fakePeer's 403 now writes the gateway's real not-shared message.

Run:
- At origin/main 3b643f397 with only the new tests (mote): all three
  are red.
  - Every provider path fails with "x509: certificate signed by unknown
    authority".
  - Every refusal reads "isn't shared".
  - The router check is "unreachable".
- At this head (mica):
  - gofmt -l is clean;
  - go vet for darwin, GOOS=linux -tags nogui and GOOS=windows
    (provider, library) passes;
  - go test -count=1 -timeout 45m ./internal/provider ./internal/library
    ./internal/gui: ok, ok, ok (135s, 124s, 142s)

Not tried:
- the reporter's real remote, or a real nginx doing mTLS;
- a full ./... suite;
- GUI tests (no GUI file changed: an error other than "isn't shared"
  was always shown as it came).
- gui/remote.go's remote-window probe and remote_moved's proves() are
  not provider requests and are unchanged.
2026-11-16 10:42:40 +08:00
..