Skip to content

✨ feat(proxy): inject GitHub authorization at the MITM proxy on v5 (#1861) - #5876

Merged
clubanderson merged 2 commits into
v5from
feat/1861-proxy-gh-auth-injection-v5
Sep 3, 2026
Merged

✨ feat(proxy): inject GitHub authorization at the MITM proxy on v5 (#1861)#5876
clubanderson merged 2 commits into
v5from
feat/1861-proxy-gh-auth-injection-v5

Conversation

@clubanderson

Copy link
Copy Markdown
Member

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 via HIVE_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

  • Interception dispatch: v4's IsGitHubHost/NeedsMITM seams became NeedsInspection on 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.
  • WriteAgentToken divert rebased onto v5's best-effort-close write path.
  • proxyHTTP gained an agent.AgentCapabilities parameter on v5 — test harness updated.
  • tunnelHalfCloseDrain is an atomic.Int64 on v5 — test override updated.
  • Module path 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

…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>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Sep 3, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign hanthor for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Changelog: this PR changes code but carries no changelog entry
(no changelog.d/ fragment and no CHANGELOG.md edit).

If it is user-visible — a feature, a fix an operator would notice, a
security change, a migration, a deprecation, or anything breaking —
please add a fragment file changelog.d/<category>-<pr-or-slug>.md
containing exactly your entry (see changelog.d/README.md; the
category is one of added/changed/deprecated/fixed/security). Please
do not append to CHANGELOG.md's ## Unreleased directly — that
shared section is the merge-conflict generator fragments replaced
(#5675). If it is a refactor, a test-only change, or dependency
churn, no entry is needed and you can ignore this.

This is a reminder, not a gate; it never blocks a merge.

@kubestellar-prow kubestellar-prow Bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Sep 3, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Andy Anderson <andy@clubanderson.com>
@clubanderson
clubanderson merged commit e3ffc64 into v5 Sep 3, 2026
53 of 54 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the feat/1861-proxy-gh-auth-injection-v5 branch September 3, 2026 16:11
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

Check out what's new:

Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant