Repository navigation
fix(oauth): log rejected authorization and token steps - #1242
Draft
sweetmantech wants to merge 1 commit into
Draft
sweetmantech wants to merge 1 commit into
sweetmantech wants to merge 1 commit into
Conversation
…error codes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before: when an MCP client such as Claude finishes the Recoup sign-in but its token exchange or authorization is rejected, the server logs nothing. A failed bearer check caused by a storage error on
/mcpis also swallowed silently. So when the Claude connector reports "sign in failed", the logs can't show which step failed.After: each rejected authorization or token request logs
OAuth request rejectedwith{ event: "oauth_request_rejected", step: "authorization" | "grant", error: <standard OAuth error code or "other"> }. A storage failure while checking an OAuth bearer on/mcplogsoauth_bearer_verification_unavailable. No codes, tokens, client IDs or account IDs are logged.How:
createRecoupOAuthProviderlistens to oidc-provider'sauthorization.errorandgrant.errorevents and reduces each error to an allow-listed code with the newgetOAuthErrorCode. Registration denials stay unlogged, as the existing diagnostics test expects.verifyBearerTokenlogs a fixed event in its existing catch. A new test inproviderDiagnostics.test.tschecks that a rejected token exchange logs only the step and code.Context: locally, Claude's real client metadata document (CIMD) and a Claude-style DCR registration both complete authorize, consent, callback, token, bearer check and refresh against this code, including the full OAuth suite on the real SQL migrations (320 tests). So the Claude connector failure only shows up in production, and this logging is meant to name the failing step after one reconnect.
Tests:
pnpm test:mcp-oauthpasses, as dovitest run app/mcp lib/mcp/oauthandtsc -p tsconfig.build.json.Generated by Claude Code
Summary by cubic
Adds diagnostics logging so OAuth authorization and token rejections, plus bearer-check storage failures, no longer fail silently during MCP sign-in.
A rejected authorization or token request now logs
OAuth request rejectedwith the failing step (authorizationorgrant) and a standard, nonsecret OAuth error code. A storage failure while verifying an OAuth bearer on/mcplogsoauth_bearer_verification_unavailable. No codes, tokens, client IDs, or account IDs are logged. Registration denials remain unlogged.Written for commit 5cd96d7. Summary will update on new commits.