Skip to content

fix(core): redeem browser login code with PKCE - #6

Merged
steebchen merged 1 commit into
mainfrom
cli-code-exchange
Oct 27, 2026
Merged

steebchen merged 1 commit into
mainfrom
cli-code-exchange

Conversation

@steebchen

Copy link
Copy Markdown
Member

Summary

The browser login received the minted API key in the loopback callback URL (?key=…), so the key could land in browser history. It also stored the key as never expiring, although dashboard CLI keys expire after 90 days.

The login now uses the one-time code exchange from theopenco/llmgateway#4846 (same change as the upstream OpenCode PR anomalyco/opencode#59241):

  • The /connect/cli URL carries an S256 code_challenge; the dashboard redirects back with ?code= only.
  • The plugin redeems the code at https://internal.llmgateway.io/public/cli-auth/token with its verifier and stores the key with its real expiry. An expired key asks the user to log in again.
  • DEVPASS_INTERNAL_API_URL / LLMGATEWAY_INTERNAL_API_URL override the redeem endpoint, mirroring DEVPASS_APP_URL (README updated).

Merge after theopenco/llmgateway#4846 is deployed — until then the dashboard ignores the challenge and sends ?key=, which this version rejects.

Verification

  • packages/core/test/plugin/provider-llmgateway.test.ts (14 pass): the URL carries org, source and an S256 challenge; a forged state and a rejected code both fail the attempt; a valid callback redeems the code with a verifier matching the challenge and stores the key with its expiry.
  • bun run check (pre-push) and packages/core typecheck pass.

@github-actions

Copy link
Copy Markdown

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 72 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@steebchen
steebchen merged commit 5b968bd into main Oct 27, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant