mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 09:00:21 +00:00
fix(sandbox): use one-time noVNC observer tokens
This commit is contained in:
@@ -30,6 +30,7 @@ export async function startBrowserBridgeServer(params: {
|
||||
authToken?: string;
|
||||
authPassword?: string;
|
||||
onEnsureAttachTarget?: (profile: ProfileContext["profile"]) => Promise<void>;
|
||||
resolveSandboxNoVncToken?: (token: string) => string | null;
|
||||
}): Promise<BrowserBridge> {
|
||||
const host = params.host ?? "127.0.0.1";
|
||||
if (!isLoopbackHost(host)) {
|
||||
@@ -40,6 +41,23 @@ export async function startBrowserBridgeServer(params: {
|
||||
const app = express();
|
||||
installBrowserCommonMiddleware(app);
|
||||
|
||||
if (params.resolveSandboxNoVncToken) {
|
||||
app.get("/sandbox/novnc", (req, res) => {
|
||||
const rawToken = typeof req.query?.token === "string" ? req.query.token.trim() : "";
|
||||
if (!rawToken) {
|
||||
res.status(400).send("Missing token");
|
||||
return;
|
||||
}
|
||||
const redirectUrl = params.resolveSandboxNoVncToken?.(rawToken);
|
||||
if (!redirectUrl) {
|
||||
res.status(404).send("Invalid or expired token");
|
||||
return;
|
||||
}
|
||||
res.setHeader("Cache-Control", "no-store");
|
||||
res.redirect(302, redirectUrl);
|
||||
});
|
||||
}
|
||||
|
||||
const authToken = params.authToken?.trim() || undefined;
|
||||
const authPassword = params.authPassword?.trim() || undefined;
|
||||
if (!authToken && !authPassword) {
|
||||
|
||||
Reference in New Issue
Block a user