Repository navigation
✨ hub: remaining ownership proof methods with per-request scopes - #19241
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
There was a problem hiding this comment.
Decision needed: @clubanderson should the hub accept a caller-supplied GitHub token (X-Hive-Proof-Token) as ownership proof behind HIVE_HUB_PROOF_GITHUB_USER_TOKEN?
Read selfservice_v1_proof.go in full. I found no defect; this goes to a person because it makes the hub handle a user's GitHub token on a new path.
Verified in the code: the token is read only from a header, length and charset checked (hubV1PlausibleToken), never echoed or logged (the log lines at hubV1ProveWithUserToken carry user, hive, repo, status only), and tokenUser requires the token's GET /user login to equal the signed-in login (strings.EqualFold), so another person's token cannot prove ownership. The method is off by default and a disabled request is a 400, not a silent fallback to the stored token.
Open question for the maintainer: whether request headers are ever dumped by the hub's access logging or the reverse proxy in front of it; I could not verify that from this diff, and X-Hive-Proof-Token would then land in logs.
-- hive: agent=reviewer-2 backend=claude model=claude-sonnet-5-5 claude=2.1.328
|
Needs a decision, not a merge:
Head: verdict requires_human @ddf2b4d, 72/73 checks green, 1 pending, DCO yes, soak 0s of 10m0s. What to do: approve this head ( How to release it:
Clear the cause and the hive re-evaluates on its next pass; the stage moves to Updated 2026-11-19 09:31 UTC. |
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Decision needed: @clubanderson should decide whether the hub may accept a user-minted GitHub token in the X-Hive-Proof-Token request header (even flag-gated, off by default) for registration ownership proof.
Read selfservice_v1_proof.go and the changed repoAdminDetail/tokenUser paths. I found no defect in the code I read, and the invariants it states hold: the token is length and charset checked (hubV1PlausibleToken), bound to the signed-in login through GET /user (strings.EqualFold(who.login, githubLogin)), only used for read-only GETs, and absent from refusal bodies. The flag defaults to off and a disabled request is a 400, not a fallback.
This PR introduces a new path where the hub receives a user's GitHub credential on each request. That is a credential-handling policy choice, so I am routing it rather than approving.
Open questions I could not verify from the diff alone (not claimed as defects):
- Whether any reverse proxy, ingress or access-log middleware in front of the hub records request headers; if one does,
X-Hive-Proof-Tokenwould be persisted despite the in-handler no-log guarantee. - The
conflicts-with-open-prlabel is set; the overlapping PR was not checked here.
-- hive: agent=reviewer backend=claude model=claude-sonnet-5-5 claude=2.1.328
|
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor. Review findings from The code reads correctly to me; the open point is a policy call, not a defect. Read Open question for a human: this adds a credential-bearing request header to the registration API. Is that acceptable for the hub, and should the rollout wait for |
|
Maintainer-side review of the decision question (accept a caller-supplied GitHub token in X-Hive-Proof-Token as ownership proof, behind HIVE_HUB_PROOF_GITHUB_USER_TOKEN). Verdict: acceptable as is. The method is off by default and only read when the flag is on. Checked against the code:
Optional follow-up, not blocking: in hub-deployment.md, recommend a fine-grained token with only Metadata read on the listed repos and a short expiry, ahead of the classic repo scope (which is full read and write). Note: the overlap check reports a conflict with #19240 (key rotation); whichever merges second needs a rebase. |
|
[APPROVALNOTIFIER] This PR is APPROVED Approval requirements bypassed by manually added approval. This pull-request has been approved by: The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
clubanderson
left a comment
There was a problem hiding this comment.
Approved at head ddf2b4d. Off by default behind HIVE_HUB_PROOF_GITHUB_USER_TOKEN; the token is bound to the signed-in user, used only for read-only GitHub calls, and never returned or logged; no hub code or nginx log format records the header.
Summary
The hub signs users in with no GitHub scope, so in an org that restricts OAuth apps GitHub hides the admin role from the stored token, and registration says "not an admin" for repos the user does administer. There is nothing the user or the org can grant to fix it. This adds the RFC's per-request token proof so those users can register, without making the stored sign-in token any broader.
github-user-token,github-app-installationandrepo-file. Onlyhub-session-token(the stored-tokenpermissions.admincheck) existed.github-user-token, the simplest read-only one.repo-filestays out per the owner decision on 📝 RFC: v7 - Hub registration protocol for self-hosted hives #18642 (deferred).github-app-installationneeds an App installation lookup and is left as a follow-up rather than folded into this PR.HIVE_HUB_PROOF_GITHUB_USER_TOKEN(off by default, on top ofHIVE_HUB_SELFSERVICE_REGISTRATION). While off, asking for the method is a 400 listing what the hub offers, never a silent fallback.X-Hive-Proof-Methodand sends the token inX-Hive-Proof-Token. Discovery lists the scopes the token needs (none for public repos,repofor private, read access for fine-grained tokens), and a refusal reportsrequired_scopesand thegranted_scopesGitHub reported.reason(token_rejected,token_user_mismatch,sso_not_authorized,missing_scope,repo_not_visible,admin_role_not_visible,not_admin), so "the token cannot see your role" is no longer reported as "you are not an admin".GET /userandGET /repos/{o}/{r}, and is never stored, logged or echoed. Nothing writes to GitHub. The v6/api/hub/selfservice/*routes ignore the headers, and their pinned bodies are unchanged. RFC note: the hub does not ask forread:org, since the only call it makes on a repo isGET /repos/{o}/{r}.Related issues
Closes #19238 (part of #19056, RFC #18642)
Testing
gofmt -lwas run on the changed files.src/pkg/hub/selfservice_v1_proof_test.gocovers discovery with the flag on and off, a token proving what the stored token cannot (create and PATCH), every request refusal and every proof refusal reason, 502 on a GitHub error, the v6 route ignoring the headers, and that the token never shows up in responses, logs or the store.Contributor checklist
changelog.d/added-19238-hub-github-user-token-proof.mdv5.hub-deployment.md,env-vars.md,api-reference/hub-server.md,audit-log.md).🤖 Generated with Claude Code
-- hive: agent=scanner backend=claude model=claude-sonnet-5-5 claude=2.1.328 requested_by=@clubanderson