Return 404 JSON for oauth-protected-resource discovery probes.
Stop 302ing Claude well-known checks to /login without advertising OAuth. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -16,7 +16,9 @@ export default defineEventHandler((event) => {
|
|||||||
path === '/login' ||
|
path === '/login' ||
|
||||||
// Claude MCP discovery — never 302 to /login (JSON 404 handlers serve these).
|
// Claude MCP discovery — never 302 to /login (JSON 404 handlers serve these).
|
||||||
path === '/.well-known/oauth-authorization-server' ||
|
path === '/.well-known/oauth-authorization-server' ||
|
||||||
path === '/.well-known/openid-configuration'
|
path === '/.well-known/openid-configuration' ||
|
||||||
|
path === '/.well-known/oauth-protected-resource' ||
|
||||||
|
path.startsWith('/.well-known/oauth-protected-resource/')
|
||||||
) {
|
) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
/** Claude discovery probe — no OAuth; never redirect to /login. */
|
||||||
|
export default defineEventHandler((event) => {
|
||||||
|
setResponseStatus(event, 404)
|
||||||
|
setResponseHeader(event, 'Content-Type', 'application/json')
|
||||||
|
setResponseHeader(event, 'Cache-Control', 'no-store')
|
||||||
|
return { error: 'not found' }
|
||||||
|
})
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
/** Claude discovery probe — no OAuth; never redirect to /login. */
|
||||||
|
export default defineEventHandler((event) => {
|
||||||
|
setResponseStatus(event, 404)
|
||||||
|
setResponseHeader(event, 'Content-Type', 'application/json')
|
||||||
|
setResponseHeader(event, 'Cache-Control', 'no-store')
|
||||||
|
return { error: 'not found' }
|
||||||
|
})
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import test from 'node:test'
|
import test from 'node:test'
|
||||||
import assert from 'node:assert/strict'
|
import assert from 'node:assert/strict'
|
||||||
import { existsSync, readFileSync } from 'node:fs'
|
import { readFileSync } from 'node:fs'
|
||||||
import { fileURLToPath } from 'node:url'
|
import { fileURLToPath } from 'node:url'
|
||||||
import { dirname, join } from 'node:path'
|
import { dirname, join } from 'node:path'
|
||||||
import {
|
import {
|
||||||
@@ -77,7 +77,7 @@ test('aigen routes exist, stay on the studio-2 enqueue path, and 404 on xAIGen',
|
|||||||
assert.match(middleware, /aigenApiPathAllowed/)
|
assert.match(middleware, /aigenApiPathAllowed/)
|
||||||
assert.match(middleware, /\/\.well-known\/oauth-authorization-server/)
|
assert.match(middleware, /\/\.well-known\/oauth-authorization-server/)
|
||||||
assert.match(middleware, /\/\.well-known\/openid-configuration/)
|
assert.match(middleware, /\/\.well-known\/openid-configuration/)
|
||||||
assert.doesNotMatch(middleware, /oauth-protected-resource/)
|
assert.match(middleware, /\/\.well-known\/oauth-protected-resource/)
|
||||||
assert.match(authPaths, /path === '\/mcp'/)
|
assert.match(authPaths, /path === '\/mcp'/)
|
||||||
assert.match(mcp, /mcpBearerOk/)
|
assert.match(mcp, /mcpBearerOk/)
|
||||||
assert.match(mcp, /text\/event-stream/)
|
assert.match(mcp, /text\/event-stream/)
|
||||||
@@ -98,10 +98,14 @@ test('aigen routes exist, stay on the studio-2 enqueue path, and 404 on xAIGen',
|
|||||||
|
|
||||||
const as = readFileSync(join(root, 'server/routes/.well-known/oauth-authorization-server.get.ts'), 'utf8')
|
const as = readFileSync(join(root, 'server/routes/.well-known/oauth-authorization-server.get.ts'), 'utf8')
|
||||||
const oidc = readFileSync(join(root, 'server/routes/.well-known/openid-configuration.get.ts'), 'utf8')
|
const oidc = readFileSync(join(root, 'server/routes/.well-known/openid-configuration.get.ts'), 'utf8')
|
||||||
|
const opr = readFileSync(join(root, 'server/routes/.well-known/oauth-protected-resource.get.ts'), 'utf8')
|
||||||
|
const oprMcp = readFileSync(join(root, 'server/routes/.well-known/oauth-protected-resource/mcp.get.ts'), 'utf8')
|
||||||
assert.match(as, /not found/)
|
assert.match(as, /not found/)
|
||||||
assert.match(oidc, /not found/)
|
assert.match(oidc, /not found/)
|
||||||
assert.equal(existsSync(join(root, 'server/routes/.well-known/oauth-protected-resource.get.ts')), false)
|
assert.match(opr, /not found/)
|
||||||
assert.equal(existsSync(join(root, 'server/routes/.well-known/oauth-protected-resource/mcp.get.ts')), false)
|
assert.match(oprMcp, /not found/)
|
||||||
|
assert.doesNotMatch(opr, /authorization_servers/)
|
||||||
|
assert.doesNotMatch(oprMcp, /authorization_servers/)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('defaultLibraryFolderId prefers Inbox then the first folder', () => {
|
test('defaultLibraryFolderId prefers Inbox then the first folder', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user