fix(web): always request offline_access for MCP refresh_token grant#1292
Conversation
…ot-dev#1292] Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughPre-selects the ChangesMCP OAuth Offline Access Scope Pre-Selection
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Atlassian (and other providers) only honour the `refresh_token` grant when `offline_access` is included in the authorization scope. The client was already declaring `refresh_token` in `clientMetadata.grant_types` but never injecting `offline_access` into `requestedOAuthScopes`, so the /authorize request was incomplete and Atlassian rejected it. - `PrismaOAuthClientProvider` now appends `OFFLINE_ACCESS_SCOPE` before normalization so it appears in both `clientMetadata.scope` and the /authorize request. Injection is unconditional (matching the existing behaviour of always declaring `refresh_token`); a comment explains the tradeoff vs checking `oauthScopesSupported`. - `buildMcpOAuthScopeEntries` defaults `offline_access` to enabled when present in available scopes so the admin UI reflects what will be sent. - New `oauthScopeUtils.test.ts` covers the default-enabled behaviour and general normalization/filtering helpers. - Updated `prismaOAuthClientProvider.test.ts` to assert `offline_access` is always present and that it is not duplicated when already supplied. - Added a note to the connectors doc explaining why `offline_access` is pre-ticked in the OAuth scopes UI. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ot-dev#1292] Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ccess` injection Both mocks asserted `clientMetadata.scope === 'repo'`; the scope is now `'offline_access repo'` after the fix in the previous commit. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ing discovery. Still allow an admin to remove the scope if they want.
…for refresh tokens.
26714e0 to
42123cc
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@packages/web/src/app/`(app)/settings/workspaceAskAgent/workspaceAskAgentPage.tsx:
- Around line 161-172: The Tooltip trigger's click handler uses
event.preventDefault() which doesn't stop the click from bubbling to the parent
label and toggling the checkbox; update the onClick handler on the
TooltipTrigger/span (the element inside TooltipTrigger near
OFFLINE_ACCESS_SCOPE) to call event.stopPropagation() (optionally keep
event.preventDefault() as well) so the tooltip info icon click does not toggle
the associated checkbox.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7344ab9a-2b03-4b62-9e46-061f5476426f
📒 Files selected for processing (5)
CHANGELOG.mddocs/docs/features/ask/connectors.mdxpackages/web/src/app/(app)/settings/workspaceAskAgent/workspaceAskAgentPage.tsxpackages/web/src/ee/features/chat/mcp/oauthScopeUtils.test.tspackages/web/src/ee/features/chat/mcp/oauthScopeUtils.ts
✅ Files skipped from review due to trivial changes (2)
- CHANGELOG.md
- docs/docs/features/ask/connectors.mdx

Atlassian (and other providers) only honour the
refresh_tokengrant whenoffline_accessis included in the authorization scope. The client wasalready declaring
refresh_tokeninclientMetadata.grant_typesbut neverinjecting
offline_accessintorequestedOAuthScopes, so the /authorizerequest was incomplete and Atlassian rejected it.
PrismaOAuthClientProvidernow appendsOFFLINE_ACCESS_SCOPEbeforenormalization so it appears in both
clientMetadata.scopeand the/authorize request. Injection is unconditional (matching the existing
behaviour of always declaring
refresh_token); a comment explains thetradeoff vs checking
oauthScopesSupported.buildMcpOAuthScopeEntriesdefaultsoffline_accessto enabled whenpresent in available scopes so the admin UI reflects what will be sent.
oauthScopeUtils.test.tscovers the default-enabled behaviour andgeneral normalization/filtering helpers.
prismaOAuthClientProvider.test.tsto assertoffline_accessisalways present and that it is not duplicated when already supplied.
offline_accessispre-ticked in the OAuth scopes UI.
Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com
Summary by CodeRabbit
Bug Fixes
New Features
Documentation
Tests