apply the containers:exec permission check to the websocket terminal path

This commit is contained in:
jarek committed 2026-08-20 08:28:26 +02:00
1 parent f50c3e52f3
commit f8bfd756ef
4 files changed
+81 -1

No files matched your search

+12
View File
@@ -619,6 +619,18 @@ function webSocketPlugin(): Plugin {
}
}
// Opening a shell requires the containers:exec permission, same as the REST exec endpoint.
const canExecFn = (globalThis as any).__canExecForUser;
if (typeof canExecFn === 'function') {
const allowed = await canExecFn(wsAuth, envId);
if (!allowed) {
console.warn(`[WS] exec denied: user=${wsAuth.username} envId=${envId}`);
ws.send(JSON.stringify({ type: 'error', message: 'Permission denied' }));
ws.close(1008, 'exec permission denied');
return;
}
}
const target = getDockerTarget(envId);
try {