-
Notifications
You must be signed in to change notification settings - Fork 298
fix(web): always request offline_access for MCP refresh_token grant
#1292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jsourcebot
merged 11 commits into
sourcebot-dev:main
from
fatmcgav:fix-atlassian-mcp-scopes
Jun 11, 2026
+134
−5
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
bf33868
fix(web): always request `offline_access` for MCP `refresh_token` grant
fatmcgav c42d19f
chore: add `CHANGELOG.md` entry for `offline_access` MCP fix [#1292]
fatmcgav 6d5dd9f
test(web): update `connect` and `callback` route tests for `offline_a…
fatmcgav b294cf0
clean up comments to be more concise
jsourcebot 13e8df6
clean up tests to keep only the higher value ones
jsourcebot 9c50a7c
Change the approach to enable the scope by default if it is found dur…
jsourcebot 60fd09c
Add support for a tooltip warning admins that this scope is required …
jsourcebot f4bd20f
Update scopes page to warn admin when offline scope is the only selec…
jsourcebot 42123cc
Update changelog and docs
jsourcebot 7ae1c35
include links to openid documentation for offline access scope
jsourcebot f5a574a
Also show warning when scopes are discovered but none are selected
jsourcebot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
81 changes: 81 additions & 0 deletions
81
packages/web/src/ee/features/chat/mcp/oauthScopeUtils.test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| import { describe, expect, test } from 'vitest'; | ||
| import { | ||
| buildMcpOAuthScopeEntries, | ||
| normalizeMcpRequestedOAuthScopes, | ||
| getEnabledMcpOAuthScopeNames, | ||
| } from './oauthScopeUtils'; | ||
|
|
||
| describe('normalizeMcpRequestedOAuthScopes', () => { | ||
| test('deduplicates, trims, and sorts scopes', () => { | ||
| expect(normalizeMcpRequestedOAuthScopes([' repo ', 'read:user', 'repo'])).toEqual([ | ||
| 'read:user', | ||
| 'repo', | ||
| ]); | ||
| }); | ||
|
|
||
| test('filters blank strings', () => { | ||
| expect(normalizeMcpRequestedOAuthScopes(['', ' ', 'read'])).toEqual(['read']); | ||
| }); | ||
| }); | ||
|
|
||
| describe('buildMcpOAuthScopeEntries', () => { | ||
| test('enables scopes that are in requestedOAuthScopes', () => { | ||
| const entries = buildMcpOAuthScopeEntries({ | ||
| availableOAuthScopes: ['read', 'write'], | ||
| requestedOAuthScopes: ['read'], | ||
| }); | ||
|
|
||
| expect(entries).toEqual([ | ||
| { scope: 'read', enabled: true }, | ||
| { scope: 'write', enabled: false }, | ||
| ]); | ||
| }); | ||
|
|
||
| test('does not special-case offline_access; it is enabled only when requested', () => { | ||
| const entries = buildMcpOAuthScopeEntries({ | ||
| availableOAuthScopes: ['offline_access', 'read'], | ||
| requestedOAuthScopes: [], | ||
| }); | ||
|
|
||
| expect(entries).toEqual([ | ||
| { scope: 'offline_access', enabled: false }, | ||
| { scope: 'read', enabled: false }, | ||
| ]); | ||
| }); | ||
|
|
||
| test('merges requested scopes not in available scopes into the output', () => { | ||
| const entries = buildMcpOAuthScopeEntries({ | ||
| availableOAuthScopes: ['read'], | ||
| requestedOAuthScopes: ['write'], | ||
| }); | ||
|
|
||
| expect(entries).toEqual([ | ||
| { scope: 'read', enabled: false }, | ||
| { scope: 'write', enabled: true }, | ||
| ]); | ||
| }); | ||
|
|
||
| test('returns sorted, deduplicated entries', () => { | ||
| const entries = buildMcpOAuthScopeEntries({ | ||
| availableOAuthScopes: ['write', 'read', 'write'], | ||
| requestedOAuthScopes: ['write', 'write'], | ||
| }); | ||
|
|
||
| expect(entries).toEqual([ | ||
| { scope: 'read', enabled: false }, | ||
| { scope: 'write', enabled: true }, | ||
| ]); | ||
| }); | ||
| }); | ||
|
|
||
| describe('getEnabledMcpOAuthScopeNames', () => { | ||
| test('returns only enabled scopes, sorted and deduplicated', () => { | ||
| const scopes = getEnabledMcpOAuthScopeNames([ | ||
| { scope: 'write', enabled: false }, | ||
| { scope: 'read', enabled: true }, | ||
| { scope: 'offline_access', enabled: true }, | ||
| ]); | ||
|
|
||
| expect(scopes).toEqual(['offline_access', 'read']); | ||
| }); | ||
| }); |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.