fix: Use configured OAuth server rate limits (#40542)

Co-authored-by: n8n-cat-bot[bot] <n8n-cat-bot[bot]@users.noreply.github.com>
This commit is contained in:
n8n-cat-bot[bot] 2026-10-07 13:24:56 +00:00 committed by GitHub
parent 00849c4dea
commit 4c8b76b6f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 36 additions and 3 deletions

View File

@ -938,6 +938,32 @@ describe('IP rate limit configuration', () => {
}
});
test.each([
['GET', '/mcp-oauth/authorize'],
['POST', '/mcp-oauth/token'],
['POST', '/mcp-oauth/revoke'],
['POST', '/mcp-oauth/register'],
['GET', '/oauth/authorize'],
['POST', '/oauth/token'],
['POST', '/oauth/revoke'],
['POST', '/oauth/register'],
])('does not apply an SDK rate limit to %s %s', async (method, path) => {
const response =
method === 'GET'
? await testServer.restlessAgent.get(path)
: await testServer.restlessAgent.post(path).send({});
expect(response.statusCode).not.toBe(404);
expect(response.headers).not.toHaveProperty('ratelimit-policy');
});
test('does not cap authorization requests at the SDK default of 100', async () => {
for (let attempt = 0; attempt <= 100; attempt++) {
const response = await testServer.restlessAgent.get('/mcp-oauth/authorize');
expect(response.statusCode).toBe(400);
}
});
test.each([
'metadata',
'metadataOptions',

View File

@ -81,10 +81,17 @@ const rfc9207IssuerParam: RequestHandler = (_req, res, next) => {
// `/oauth/*` paths that future, non-MCP protected resources will advertise.
const registerRouter = clientRegistrationHandler({
clientsStore: oauthServerService.clientsStore,
rateLimit: false,
}) as Router;
const authorizeRouter = authorizationHandler({
provider: oauthServerService,
rateLimit: false,
}) as Router;
const tokenRouter = tokenHandler({ provider: oauthServerService, rateLimit: false }) as Router;
const revokeRouter = revocationHandler({
provider: oauthServerService,
rateLimit: false,
}) as Router;
const authorizeRouter = authorizationHandler({ provider: oauthServerService }) as Router;
const tokenRouter = tokenHandler({ provider: oauthServerService }) as Router;
const revokeRouter = revocationHandler({ provider: oauthServerService }) as Router;
const sharedEndpointRouters = (basePath: '/mcp-oauth' | '/oauth'): StaticRouterMetadata[] => [
{