fix: converge workbench session authority
This commit is contained in:
@@ -56,22 +56,18 @@ export function isCloudApiProxyRoute(method, pathname) {
|
||||
isApiKeyWriteProxyRoute(normalizedMethod, normalizedPath) ||
|
||||
isAdminBillingWriteProxyRoute(normalizedMethod, normalizedPath) ||
|
||||
normalizedPath.startsWith("/v1/rpc/") ||
|
||||
normalizedPath.startsWith("/v1/agent/sessions/") ||
|
||||
isWorkbenchWorkspaceWriteProxyRoute(normalizedMethod, normalizedPath);
|
||||
normalizedPath.startsWith("/v1/agent/sessions/");
|
||||
}
|
||||
if (normalizedMethod === "PATCH" || normalizedMethod === "PUT") {
|
||||
return isAdminAccessWriteProxyRoute(normalizedMethod, normalizedPath) ||
|
||||
isAdminBillingWriteProxyRoute(normalizedMethod, normalizedPath) ||
|
||||
isProviderProfileManagementProxyRoute(normalizedMethod, normalizedPath) ||
|
||||
isApiKeyWriteProxyRoute(normalizedMethod, normalizedPath) ||
|
||||
isWorkbenchWorkspaceWriteProxyRoute(normalizedMethod, normalizedPath) ||
|
||||
isAgentConversationWriteProxyRoute(normalizedMethod, normalizedPath);
|
||||
isApiKeyWriteProxyRoute(normalizedMethod, normalizedPath);
|
||||
}
|
||||
if (normalizedMethod === "DELETE") {
|
||||
return isAdminAccessWriteProxyRoute(normalizedMethod, normalizedPath) ||
|
||||
isProviderProfileManagementProxyRoute(normalizedMethod, normalizedPath) ||
|
||||
isApiKeyWriteProxyRoute(normalizedMethod, normalizedPath) ||
|
||||
isAgentConversationWriteProxyRoute(normalizedMethod, normalizedPath);
|
||||
isApiKeyWriteProxyRoute(normalizedMethod, normalizedPath);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -116,20 +112,6 @@ function isAdminBillingWriteProxyRoute(method, pathname) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function isWorkbenchWorkspaceWriteProxyRoute(method, pathname) {
|
||||
const parts = pathname.split("/").filter(Boolean);
|
||||
if (parts.length < 4 || parts[0] !== "v1" || parts[1] !== "workbench" || parts[2] !== "workspace") return false;
|
||||
if ((method === "PATCH" || method === "PUT") && parts.length === 4) return true;
|
||||
if (method === "POST" && parts.length === 5) return parts[4] === "select-conversation" || parts[4] === "reset";
|
||||
return false;
|
||||
}
|
||||
|
||||
function isAgentConversationWriteProxyRoute(method, pathname) {
|
||||
const parts = pathname.split("/").filter(Boolean);
|
||||
if (parts.length !== 4 || parts[0] !== "v1" || parts[1] !== "agent" || parts[2] !== "conversations") return false;
|
||||
return ["PUT", "PATCH", "DELETE"].includes(method);
|
||||
}
|
||||
|
||||
function isPublicCodeAgentPollRoute(method, pathname) {
|
||||
return method === "GET" && (
|
||||
pathname.startsWith("/v1/agent/turns/") ||
|
||||
|
||||
@@ -192,39 +192,6 @@ test("cloud web proxies authenticated hwpod node-ops route", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("cloud web proxies authenticated account workbench write routes", () => {
|
||||
assert.deepEqual(cloudWebProxyRoutePolicy("PATCH", "/v1/workbench/workspace/ws_default"), {
|
||||
proxy: true,
|
||||
authRequired: true,
|
||||
publicRoute: false,
|
||||
routeKey: "PATCH /v1/workbench/workspace/ws_default"
|
||||
});
|
||||
assert.deepEqual(cloudWebProxyRoutePolicy("PUT", "/v1/workbench/workspace/ws_default"), {
|
||||
proxy: true,
|
||||
authRequired: true,
|
||||
publicRoute: false,
|
||||
routeKey: "PUT /v1/workbench/workspace/ws_default"
|
||||
});
|
||||
assert.deepEqual(cloudWebProxyRoutePolicy("POST", "/v1/workbench/workspace/ws_default/select-conversation"), {
|
||||
proxy: true,
|
||||
authRequired: true,
|
||||
publicRoute: false,
|
||||
routeKey: "POST /v1/workbench/workspace/ws_default/select-conversation"
|
||||
});
|
||||
assert.deepEqual(cloudWebProxyRoutePolicy("POST", "/v1/workbench/workspace/ws_default/reset"), {
|
||||
proxy: true,
|
||||
authRequired: true,
|
||||
publicRoute: false,
|
||||
routeKey: "POST /v1/workbench/workspace/ws_default/reset"
|
||||
});
|
||||
assert.deepEqual(cloudWebProxyRoutePolicy("POST", "/v1/workbench/workspace/ws_default/events"), {
|
||||
proxy: false,
|
||||
authRequired: false,
|
||||
publicRoute: false,
|
||||
routeKey: "POST /v1/workbench/workspace/ws_default/events"
|
||||
});
|
||||
});
|
||||
|
||||
test("cloud web proxies Code Agent steer through the Web-equivalent public API path", () => {
|
||||
assert.deepEqual(cloudWebProxyRoutePolicy("POST", "/v1/agent/chat/steer"), {
|
||||
proxy: true,
|
||||
@@ -234,11 +201,3 @@ test("cloud web proxies Code Agent steer through the Web-equivalent public API p
|
||||
});
|
||||
});
|
||||
|
||||
test("cloud web proxies authenticated session deletion through account conversation API", () => {
|
||||
assert.deepEqual(cloudWebProxyRoutePolicy("DELETE", "/v1/agent/conversations/cnv_test"), {
|
||||
proxy: true,
|
||||
authRequired: true,
|
||||
publicRoute: false,
|
||||
routeKey: "DELETE /v1/agent/conversations/cnv_test"
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user