Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

901 B
Raw Blame
import { NextRequest } from "next/server";
import { constantTimeEq } from "@/lib/auth/session";
import { readRequestJson } from "@/lib/security/request-body";
import { socketPolicy } from "@/lib/managed-apps/socket-policy";

export async function handlePostSocketPolicy(req: Request): Promise<Response> {
  const secret = process.env.MSO_SOCKET_POLICY_SECRET ?? "";
  if (secret.length < 32 || !constantTimeEq(req.headers.get("authorization") ?? "", `Bearer ${secret}`)) return new Response(null, { status: 404 });
  try {
    const input = await readRequestJson(req, 32 * 1024) as { url: string; headers: Record<string, string> };
    const decision = await socketPolicy(new NextRequest(input.url, { headers: input.headers }));
    return Response.json(decision, { status: decision ? 200 : 403, headers: { "Cache-Control": "no-store" } });
  } catch { return new Response(null, { status: 403 }); }
}