fix(mcp): deduplicate scopes in insufficient_scope challenge response#2604
Conversation
The sendInsufficientScopeResponse function was aliasing operationScopes via challengeScopes := operationScopes, then appending to it. This caused operation scopes to appear twice in the WWW-Authenticate header when scopeChallengeIncludeTokenScopes was enabled. Build a fresh combined slice instead: existing token scopes first, then operation scopes (deduplicated).
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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 |
09c8b03
into
ahmet/eng-8386-implement-oauth-21-authorization-and-protected-resource
Router-nonroot image scan failed❌ Security vulnerabilities found in image: Please check the security vulnerabilities found in the PR. If you believe this is a false positive, please add the vulnerability to the |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## ahmet/eng-8386-implement-oauth-21-authorization-and-protected-resource #2604 +/- ##
===========================================================================================================
- Coverage 33.93% 23.62% -10.32%
===========================================================================================================
Files 227 225 -2
Lines 25396 25152 -244
===========================================================================================================
- Hits 8618 5941 -2677
- Misses 15706 18381 +2675
+ Partials 1072 830 -242
🚀 New features to boost your workflow:
|
Summary
sendInsufficientScopeResponseduplicated operation scopes in theWWW-Authenticateheader whenscopeChallengeIncludeTokenScopeswas enabledchallengeScopes := operationScopesaliased the slice, thenappendadded existing scopes onto it, and the subsequent loop re-added operationScopes (already present)combinedslice — existing token scopes first, then operation scopes deduplicatedTest plan
TestMCPAuthMiddleware_HTTPMiddleware/insufficient_init_scopes_-_403_with_include_token_scopes_enabled— was failing, now passesTestMCPAuthMiddleware_MethodLevelScopes/tools/list_with_insufficient_scopes_-_include_token_scopes— was failing, now passesTestMCPAuthMiddleware_MethodLevelScopes/tools/call_with_insufficient_scopes_-_include_token_scopes— was failing, now passes