Skip to content

fix(auth): cherry-pick upstream OpenCode password and pairing-code fixes - #342

Merged
shuv1337 merged 2 commits into
mainfrom
sync/auth-25230-25222
Oct 30, 2026
Merged

shuv1337 merged 2 commits into
mainfrom
sync/auth-25230-25222

Conversation

@shuv1337

Copy link
Copy Markdown
Owner

Problem

Two upstream auth fixes are missing on fork main (165d40279). OpenCode sessions ignore the resolved server password, so a configured password never reaches the SDK client. MCP approval also spends a pairing code before the scope check, so a scope rejection burns a code that should still be usable at a lower access level.

Change

Cherry-picks onto fork main, in order, with -x:

  1. pingdotgg/t3code#25230 d796063f78a96c8816196fac3fa5660bebdd99a9 — OpenCode authenticates with the resolved server password. Passes settings.serverPassword into server connect and uses connection.serverPassword on the SDK client.
  2. pingdotgg/t3code#25222 7860ee983d81d287eaf15664ffd92dc6964d92cc — keep pairing codes after a scope rejection. requiredScopes is checked inside the consume UPDATE (and the in-memory grant path), so a rejected code stays unspent.

EnvironmentAuth.ts conflicted and was hand-resolved. Fork behavior stays: purpose: "watch" on bootstrap consume, and BootstrapCredentialScopeNotGrantedError still maps to ServerAuthScopeNotGrantedError. Upstream's change is added on top: requiredScopes on resolveBootstrapGrant, the reusable-dev-token scope filter, consumeMcpApprovalCode passing requiredScopes: mcpClientScopes(access) before the grant is spent, and the updated insufficient-scope message. The post-consume scope check that burned the code is removed.

No workflow, release, or desktop update-channel files.

Scope and approval

Phase A only. Lauren approved opening this PR. Do not merge. A full upstream sync is out of scope.

Verification

  • vp run --filter t3 --filter @t3tools/provider-opencode typecheck — both packages succeeded.
  • vp test run packages/provider-opencode/src/server/adapter.test.ts — 1 file, 35 tests passed, including opens an authenticated OpenCode session for external and managed servers.
  • vp test run apps/server/src/auth — 14 files, 96 tests passed, including preserves a rejected MCP pairing code for exactly one concurrent lower-access retry and the MCP OAuth case that reuses a read-only code after a full-access rejection.

Manual checks not run in this environment:

  • Pairing: issue a code with only orchestration:read. Approve an MCP client at full access. It should fail with insufficient scope and say the code has not been used. Approve the same code as read-only. That should succeed once; a second use should fail as unknown or already used.
  • OpenCode: set a server password in OpenCode provider settings (or OPENCODE_SERVER_PASSWORD for a managed server). Opening a session should send Authorization: Basic for user opencode and that password, including when the server URL is external.

Grok 4.7, Cursor cloud agent.

Open in Web Open in Cursor 

maria-rcks and others added 2 commits October 30, 2026 19:47
…tgg#25230)

Co-authored-by: Alex Southwell <4596216+saphid@users.noreply.github.com>
Co-authored-by: maria-rcks <254055478+maria-rcks@users.noreply.github.com>
(cherry picked from commit d796063)
)

Co-authored-by: Alex Southwell <4596216+saphid@users.noreply.github.com>
(cherry picked from commit 7860ee9)
Co-authored-by: shuv <shuv1337@users.noreply.github.com>
@shuv1337
shuv1337 merged commit 8a03372 into main Oct 30, 2026
4 checks passed
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.

2 participants