Skip to content

Commit f341802

Browse files
committed
remove check for "allowed" scopes
1 parent 74cc51c commit f341802

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

src/client/auth.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('OAuth Authorization', () => {
4444
}
4545
} as unknown as Response;
4646

47-
expect(extractWWWAuthenticateParams(mockResponse)).toEqual({ scope: 'read' });
47+
expect(extractWWWAuthenticateParams(mockResponse)).toEqual({ scope: scope });
4848
});
4949

5050
it('returns empty object if not bearer', async () => {
@@ -73,15 +73,16 @@ describe('OAuth Authorization', () => {
7373

7474
it('returns undefined resourceMetadataUrl on invalid url', async () => {
7575
const resourceUrl = 'invalid-url';
76+
const scope = 'read';
7677
const mockResponse = {
7778
headers: {
7879
get: jest.fn(name =>
79-
name === 'WWW-Authenticate' ? `Bearer realm="mcp", resource_metadata="${resourceUrl}", scope="read"` : null
80+
name === 'WWW-Authenticate' ? `Bearer realm="mcp", resource_metadata="${resourceUrl}", scope="${scope}"` : null
8081
)
8182
}
8283
} as unknown as Response;
8384

84-
expect(extractWWWAuthenticateParams(mockResponse)).toEqual({ scope: 'read' });
85+
expect(extractWWWAuthenticateParams(mockResponse)).toEqual({ scope: scope });
8586
});
8687
});
8788

src/client/streamableHttp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ export class StreamableHTTPClientTransport implements Transport {
158158
try {
159159
result = await auth(this._authProvider, {
160160
serverUrl: this._url,
161-
scope: this._scope,
162161
resourceMetadataUrl: this._resourceMetadataUrl,
162+
scope: this._scope,
163163
fetchFn: this._fetch
164164
});
165165
} catch (error) {

src/server/auth/handlers/authorize.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,6 @@ export function authorizationHandler({ provider, rateLimit: rateLimitConfig }: A
120120
let requestedScopes: string[] = [];
121121
if (scope !== undefined) {
122122
requestedScopes = scope.split(' ');
123-
const allowedScopes = new Set(client.scope?.split(' '));
124-
125-
// Check each requested scope against allowed scopes
126-
for (const scope of requestedScopes) {
127-
if (!allowedScopes.has(scope)) {
128-
throw new InvalidScopeError(`Client was not registered with scope ${scope}`);
129-
}
130-
}
131123
}
132124

133125
// All validation passed, proceed with authorization

0 commit comments

Comments
 (0)