coreapi: use auth-go crossjuris for the cross-jurisdiction transport - #2235
Conversation
Replace the private 421-follow + RFC 8693 exchange round tripper with github.com/entireio/auth-go/crossjuris (COR-1441). The CLI keeps only its own pieces: the ENTIRE_DEBUG-gated trace printer wired to Config.Logf, and the mirror-requests Location canonicalizer as an outer RoundTripper reading the replayed request. http:// loopback targets are permitted only when the core the client is built against is itself http loopback. Pins auth-go to v0.5.3-0.20260902062113-ea855c0e45f1; bump to a tag once entireio/auth-go#24 merges. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Verification (worktree, go1.26.6 darwin/arm64): |
There was a problem hiding this comment.
馃數 Needs a closer look
It changes the core authentication transport used by all control-plane API calls and relies on behavior now residing in an external pre-release dependency, so it merits final human review despite the wiring/tests looking consistent.
Pull request overview
This PR migrates the CLI鈥檚 control-plane (coreapi) cross-jurisdiction HTTP transport (421 follow + RFC 8693 token exchange) from an in-repo implementation to the shared github.com/entireio/auth-go/crossjuris package, keeping CLI-specific behavior (mirror-request Location canonicalization and ENTIRE_DEBUG logging) in internal/coreapi.
Changes:
- Replace the deleted in-repo cross-juris transport with
crossjuris.New(...), wiring it under the existing User-Agent/base transport and gating insecure HTTP only for http-loopback cores. - Preserve CLI-only
Locationrewriting forPOST /api/v1/mirror-requestsby wrapping the shared transport with an outer round tripper that can inspectresp.Request. - Update tests to focus on coreapi wiring/chain-shape and policy (dropping cache/TTL internals now owned by auth-go), and bump
auth-goto a pinned pre-release pseudo-version.
File summaries
| File | Description |
|---|---|
| internal/coreapi/cross_juris_transport.go | Deletes the previous in-repo cross-jurisdiction transport implementation. |
| internal/coreapi/cross_juris_client.go | Adds new transport wiring around auth-go/crossjuris plus CLI-specific Location canonicalization and debug logging. |
| internal/coreapi/client.go | Updates coreapi client construction to use the new newCrossJurisHTTPClient(coreURL) API and propagate setup errors. |
| internal/coreapi/cross_juris_client_test.go | Updates/adjusts tests to validate wiring behavior and adds a policy test ensuring https cores won鈥檛 follow plaintext 421 targets. |
| internal/coreapi/cross_juris_useragent_test.go | Updates constants and validates User-Agent stamping across all hops including crossjuris-synthesized requests. |
| go.mod | Bumps github.com/entireio/auth-go to the pinned pseudo-version containing crossjuris. |
| go.sum | Updates sums for the bumped auth-go version. |
Review details
- Files reviewed: 6/7 changed files
- Comments generated: 0
- Review effort level: Lite
馃挕 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Match the sibling NewClient wrap so a transport construction failure names where it happened. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
https://entire.io/gh/entireio/cli/trails/1217
Why
The 421-follow + RFC 8693 exchange transport now lives in
github.com/entireio/auth-go/crossjuris(entireio/auth-go#24), shared with entiredb and entire-ci. This deletes the CLI's copy. Linear: https://linear.app/entirehq/issue/COR-1441What
internal/coreapi/cross_juris_transport.godeleted (644 lines).newCrossJurisHTTPClient(coreURL)wirescrossjuris.Newwith the existing User-Agent base chain,ClientID: entire-cli, and the ENTIRE_DEBUG-gateddebugfasLogf.AllowInsecureHTTPis true only when the core URL is http loopback, so local dev keeps working and prod stays https-only.Locationcanonicalization stays CLI-side as an outer round tripper reading the replayed request fromresp.Request.Pinned to auth-go main after entireio/auth-go#24 merged (
v0.5.3-0.20260902072340-78f4dc59700e, no tag planned).Verification
go build ./...,go test -race ./internal/coreapi/...,golangci-lint run --new-from-rev=origin/main: clean. Output in the comment below.馃 Generated with Claude Code
Note
Medium Risk
Touches authentication transport for all control-plane API calls (421 redirects and token exchange), though behavior is intended to be equivalent after moving to the shared library; mis-wiring or AllowInsecureHTTP policy could affect JWT handling across regions.
Overview
Replaces the CLI鈥檚 ~644-line in-repo cross-jurisdiction transport with
github.com/entireio/auth-go/crossjuris, bumpingauth-goto a pinned pre-release commit until the shared library PR lands.newCrossJurisHTTPClient(coreURL)now builds the control-plane HTTP client by stackingcrossjuris.New(421 follow, RFC 8693 exchange, federation checks) on the existing User-Agent/base transport, withAllowInsecureHTTPonly when the configured core is http loopback (local dev/tests).clientForTargetandNewWithBearerpass the core origin and propagate setup errors.CLI-only behavior stays in a thin outer round tripper:
mirrorLocationCanonicalizerrewritesLocationon 202 fromPOST /api/v1/mirror-requestsusing the host that actually answered after a 421 follow.Tests focus on wiring (redirect/exchange chains, off-origin rejection, User-Agent on every hop); cache/TTL unit tests were dropped in favor of auth-go, plus a new case that an https core refuses following a 421 to a plaintext loopback home.
Reviewed by Cursor Bugbot for commit 02abf21. Configure here.