Harden MCP broker sandbox handoff
This commit is contained in:
@@ -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)))
|
||||
|
||||
Reference in New Issue
Block a user