Skip to content

feat(upstreams): an OAuth app's client secret, for GitHub (ADR-0069 addendum) - #381

Merged
7schmiede merged 1 commit into
mainfrom
feat/upstream-client-secret
Oct 30, 2026
Merged

7schmiede merged 1 commit into
mainfrom
feat/upstream-client-secret

Conversation

@7schmiede

Copy link
Copy Markdown
Member

GitHub's MCP server (api.githubcopilot.com/mcp) names its authorization server (github.com/login/oauth, PKCE S256), but GitHub registers no clients itself (no registration_endpoint) and wants a client secret at its token endpoint even with PKCE. The hub sent none, so a pool's github upstream could only log in with a token. This lets an OAuth upstream carry a client secret.

Review card

Approved by the owner in the conversation on 2026-10-30: all four points.

# Category Point What it beats What reversing it costs
1 trust An OAuth upstream may carry a client secret, for authorization servers that demand one even with PKCE (GitHub); it is the secret of an app registered for desktop clients, not confidential by nature (RFC 8252 §8.5, as with the gh CLI), and the hub sends it only to the token endpoint the upstream's metadata names (code exchange and refresh). Device flow (a second login path plus UI); a PAT per member (manual, no expiry). Drop the field; logins through such an app fail again, other upstreams are untouched.
2 trust On a user's own upstream the secret goes into the keychain, never into upstreams.toml; the API takes it and only ever answers whether one is set. Keeping it in the config file next to the client id. Small: one keychain entry per upstream to migrate or drop.
3 trust A pool may name one with its client id: the coordinator gives it to approved members with the list (GET /v1/upstreams), their hubs keep it with the pool's list, and the dashboard, the CLI and the audit log show only that one is set. This is the one exception to "a pool's list holds no secret". Each member registering their own GitHub app. Members must type the secret themselves; the field goes from the list again.
4 contract API and CLI: auth: {kind: "oauth", client_id?, client_secret?, scopes?} on write; reads answer client_secret: true instead of the value; an edit without a secret keeps the one set; devstack pool upstreams add --client-secret … --scope …. A separate secrets endpoint. Additive fields; older hubs ignore them.

Decided on my own: the stored login keeps the secret for its refresh; --scope in the CLI (a GitHub OAuth app without scopes gets public read access only); members' hubs keep a pool's secret in pool-upstreams.json beside the list (point 1: not confidential); logging out keeps the client secret, removing the upstream or leaving OAuth drops it (keychain entry <name>#client); a secret is up to 1024 characters without spaces; an empty string (or false) takes it away. Found while building: GitHub refuses at its token endpoint with 200 and an error, so any answer with an error is now a refusal with that reason. The dashboard forms gained the scopes too: until now an edit there dropped them.

What changed

  • devstack-node/src/upstreams.rs: PoolAuth::Oauth.client_secret; put keeps it across a change without one; PoolUpstream::redacted() for anything that shows the list.
  • devstack-hub/src/upstreams.rs: ClientSecret (serialises as true, Debug redacted); the user's own secret in the keychain; sent with the code exchange and the refresh; token answers with error refused.
  • devstack-hub/src/pool.rs: /hub/pool/upstreams answers redacted.
  • CLI: devstack pool upstreams add --client-secret … --scope …; the list says "a client secret" and the scopes.
  • UI: client secret (password field, "set; empty keeps it", remove checkbox) and scopes in both forms.
  • Docs: dashboard-api.md, pool.md (the GitHub recipe), ADR-0069 addendum 2026-10-30.

Compatibility

  • An older coordinator drops the field on a change.
  • An older member's hub ignores the field, and its login fails as before.
  • int-baumeister needs this release before the pool's github entry can carry a secret.

Tests

  • cargo clippy --workspace --all-targets -D warnings and cargo fmt --check clean.
  • cargo test -p devstack-hub -p devstack-node -p devstack green. New tests:
    • the secret reaches only the token endpoint (exchange and refresh) and never upstreams.toml, the views or Debug;
    • an edit keeps it, logout keeps it, an empty one drops it;
    • a pool's secret is used and shown as set;
    • a 200 with an error is a refusal;
    • the coordinator keeps the secret, redacts it, and refuses one without a client id;
    • CLI parsing.
  • UI: vue-tsc and vitest green (new oauthAuth.test.ts).
  • Not tested against GitHub itself yet. That comes once int-baumeister has the release and the pool has an OAuth app.

🤖 Generated with Claude Code

…ddendum)

GitHub's MCP server names its authorization server, but GitHub registers
no clients itself and wants a client secret at its token endpoint even
with PKCE. An OAuth upstream may now carry one with its client id:

- the hub sends it only to the token endpoint (code exchange, refresh);
- the user's own goes into the keychain (`<name>#client`), never into
  upstreams.toml; reads answer `client_secret: true`;
- a pool may name one: members' hubs get it with the list, the dashboard,
  the CLI and the audit log only say that one is set;
- an edit without one keeps it, an empty one takes it away;
- `devstack pool upstreams add --client-secret … --scope …`, and the
  dashboard's forms gained the client secret and the scopes.

A token endpoint answering `200` with an `error` (GitHub) is a refusal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@7schmiede
7schmiede merged commit fdf5361 into main Oct 30, 2026
13 checks passed
@7schmiede
7schmiede deleted the feat/upstream-client-secret branch October 30, 2026 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant