Harden MCP broker sandbox handoff

This commit is contained in:
Codex
2026-04-27 21:33:05 +00:00
parent fdb18300eb
commit fd0959d994
18 changed files with 634 additions and 101 deletions
+11
View File
@@ -13,11 +13,18 @@ const PUBLIC_PATHS = [
"/favicon.svg",
"/favicon-32.png",
]
const BROKER_PATHS = [
"/api/mcp/broker",
]
function isPublicPath(pathname: string) {
return PUBLIC_PATHS.some((path) => pathname === path || pathname.startsWith(`${path}/`))
}
function isBrokerPath(pathname: string) {
return BROKER_PATHS.some((path) => pathname === path || pathname.startsWith(`${path}/`))
}
function isAssetPath(pathname: string) {
return pathname.startsWith("/_next/") || pathname.startsWith("/public/")
}
@@ -97,6 +104,10 @@ export async function middleware(request: NextRequest) {
return withSecurityHeaders(NextResponse.next())
}
if (isBrokerPath(pathname)) {
return withSecurityHeaders(NextResponse.next())
}
if (isPublicPath(pathname)) {
if (pathname === "/login" && await verifySessionCookieValue(request.cookies.get(settings.cookieName)?.value)) {
return withSecurityHeaders(NextResponse.redirect(new URL("/", request.url)))