diff --git a/src/backend/ssh/docker-console.ts b/src/backend/ssh/docker-console.ts index 6c93afaf9..2532c69aa 100644 --- a/src/backend/ssh/docker-console.ts +++ b/src/backend/ssh/docker-console.ts @@ -257,6 +257,12 @@ wss.on("connection", async (ws: WebSocket, req) => { } } + if (!token) { + const urlObj = new URL(req.url || "", "http://localhost"); + const qp = urlObj.searchParams.get("token"); + if (qp) token = qp; + } + if (!token) { ws.close(1008, "Authentication required"); return; diff --git a/src/backend/ssh/terminal.ts b/src/backend/ssh/terminal.ts index 105826038..050b1ef5b 100644 --- a/src/backend/ssh/terminal.ts +++ b/src/backend/ssh/terminal.ts @@ -505,6 +505,12 @@ wss.on("connection", async (ws: WebSocket, req) => { } } + if (!token) { + const urlObj = new URL(req.url || "", "http://localhost"); + const qp = urlObj.searchParams.get("token"); + if (qp) token = qp; + } + if (!token) { ws.close(1008, "Authentication required"); return; diff --git a/src/ui/features/terminal/Terminal.tsx b/src/ui/features/terminal/Terminal.tsx index 04e3eb065..9768721c9 100644 --- a/src/ui/features/terminal/Terminal.tsx +++ b/src/ui/features/terminal/Terminal.tsx @@ -884,6 +884,10 @@ const TerminalInner = forwardRef( .replace(/^https?:\/\//, "") .replace(/\/$/, ""); baseWsUrl = `${wsProtocol}${wsHost}/ssh/websocket/`; + const storedJwt = localStorage.getItem("jwt"); + if (storedJwt) { + baseWsUrl += `?token=${encodeURIComponent(storedJwt)}`; + } } } else { baseWsUrl = `${getBasePath()}/ssh/websocket/`;