✨ feat(proxy): inject GitHub authorization at the MITM proxy on v5 (#1861) - #5876
Conversation
…never hold usable tokens (#1861) Opt-in via HIVE_PROXY_INJECT_GH_AUTH (default OFF, byte-identical behavior when unset). When enabled: - WriteAgentToken diverts the real tier-scoped token to an in-memory registry the proxy injects from, and writes the visibly-fake placeholder hive-proxy-injected-<agent> to the agent-readable cache (the single choke point gh-wrapper.sh, git-credential-hive.sh, and the manager's GITHUB_TOKEN env push all read). - The MITM proxy strips any agent-supplied Authorization header and injects the UID-identified agent's hub-held scoped token: token scheme for REST/GraphQL, Basic x-access-token for git smart HTTP (with Connection: close so keep-alive reuse cannot bypass the rewrite via the raw git relay). - MITM widens to every GitHub-family host (github.com, registered GHE) under the flag, because an opaque tunnel would carry the placeholder to GitHub un-replaced. - Unknown agent = no injection, no fallback: the request proceeds unauthenticated and fails loud at GitHub. The hive's own control-plane calls (internalCallerName, UID-attributed) pass through untouched. - OAuth device-flow endpoints get strip-only treatment. - Logs carry agent name + injected yes/no, never token bytes. Part of #1861 Signed-off-by: Andy Anderson <andy@clubanderson.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Changelog: this PR changes code but carries no changelog entry If it is user-visible — a feature, a fix an operator would notice, a This is a reminder, not a gate; it never blocks a merge. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Andy Anderson <andy@clubanderson.com>
|
Thank you for your contribution! Your PR has been merged. Check out what's new:
Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey |
Port of #4032 to
v5. Ships the core of #1861 (item 1 as re-scoped by triage): GitHub authorization is injected at the MITM proxy, per UID-identified agent, so with the flag on nothing an agent holds authenticates anywhere. Opt-in viaHIVE_PROXY_INJECT_GH_AUTH=true, default OFF — flag unset, token delivery and proxy behavior are byte-identical to today.See #4032 for the full design write-up (mechanism, survey findings, soak watch-items, and the mutation-checked test evidence table).
v5 adaptations
IsGitHubHost/NeedsMITMseams becameNeedsInspectionon v5 (api.linear.app is now under mode enforcement, RFC: converse capability + Linear agents as first-class workspace members #4492 F). Both CONNECT-path gates are now!NeedsInspection(host) && !p.hostNeedsMITM(host), so injection widening composes with Linear inspection instead of replacing it.WriteAgentTokendivert rebased onto v5's best-effort-close write path.proxyHTTPgained anagent.AgentCapabilitiesparameter on v5 — test harness updated.tunnelHalfCloseDrainis anatomic.Int64on v5 — test override updated.github.com/hivecommons/hive(post org-transfer).Validation
go build ./...,go vet ./...✅go test -race ./pkg/proxy/— ok (full package, 46s)go test ./pkg/github/ ./pkg/config/— ok (full packages)Part of #1861