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.

fix(integrations): make shell embed frameable

Rahmanb6494edac133
diff --git a/app/api/integrations/setup/route.ts b/app/api/integrations/setup/route.ts
index 46a09eda..032e4458 100644
--- a/app/api/integrations/setup/route.ts
+++ b/app/api/integrations/setup/route.ts
@@ -15,7 +15,7 @@ function cors(req: NextRequest): Record<string, string> | null {
if (!origin || (![MSO_ORIGIN, MCP_UI_DOMAIN].includes(origin) && !local)) return null;
return { ...BASE_HEADERS, "Access-Control-Allow-Origin": origin, "Access-Control-Allow-Methods": "POST, OPTIONS", "Access-Control-Allow-Headers": "Authorization, Content-Type" };
}
-export const GET = integrationPageResponse;
+export function GET() { return integrationPageResponse(false); }
export function OPTIONS(req: NextRequest) {
const headers = cors(req);
return new NextResponse(null, { status: headers ? 204 : 403, headers: headers ?? BASE_HEADERS });
diff --git a/app/integrations/embed/route.ts b/app/integrations/embed/route.ts
new file mode 100644
index 00000000..368b3e35
--- /dev/null
+++ b/app/integrations/embed/route.ts
@@ -0,0 +1,4 @@
+import { integrationPageResponse } from "@/lib/infra/setup-page";
+export const runtime = "nodejs";
+export const dynamic = "force-dynamic";
+export function GET() { return integrationPageResponse(true); }
diff --git a/app/integrations/route.test.ts b/app/integrations/route.test.ts
index 33b7618a..804d0904 100644
--- a/app/integrations/route.test.ts
+++ b/app/integrations/route.test.ts
@@ -2,6 +2,7 @@ import { describe, expect, it, vi } from "vitest";
import { NextRequest } from "next/server";
vi.mock("server-only", () => ({}));
import { GET } from "./route";
+import { GET as GET_EMBED } from "./embed/route";
import { proxy } from "@/proxy";
describe("friendly native Integrations page", () => {
it("renders an uncached full catalog with public instructions but no credential grant", async () => {
@@ -13,8 +14,8 @@ describe("friendly native Integrations page", () => {
expect(html).toContain("How to get this credential / authorization"); expect(html).not.toContain("si-coder");
expect(() => new Function(html.match(/<script nonce="[^"]+">([\s\S]*)<\/script>/)![1])).not.toThrow();
});
- it("allows only same-origin framing for the explicit shell embed mode", async () => {
- const response = GET(new NextRequest("https://mso.example.com/integrations?embed=shell"));
+ it("allows only same-origin framing on the dedicated shell embed route", async () => {
+ const response = GET_EMBED();
expect(response.headers.get("x-frame-options")).toBe("SAMEORIGIN");
expect(response.headers.get("content-security-policy")).toContain("frame-ancestors 'self'");
expect(response.headers.get("content-security-policy")).not.toContain("frame-ancestors 'none'");
diff --git a/app/integrations/route.ts b/app/integrations/route.ts
index 4c3218f0..bf42bf24 100644
--- a/app/integrations/route.ts
+++ b/app/integrations/route.ts
@@ -1,4 +1,4 @@
import { integrationPageResponse } from "@/lib/infra/setup-page";
export const runtime = "nodejs";
export const dynamic = "force-dynamic";
-export const GET = integrationPageResponse;
+export function GET() { return integrationPageResponse(false); }
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 62d80de5..40c974f4 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -8,6 +8,7 @@ this is the *what*, and it is what Settings → About shows as “What's new”.
**Fixed**
+- `integrations` make shell embed frameable
- `integrations` add shell app and detect SC worktrees
- `mcp` fall back when project MCP discover returns -32601
diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md
index 374f7d85..4a4865a8 100644
--- a/docs/PROGRESS.md
+++ b/docs/PROGRESS.md
@@ -4,9 +4,10 @@ The native Integrations workbench existed as a browser/Page/CLI surface but was
OS-shell app manifest, so it could not behave like the other dock/launcher features. Integrations
now has its own feature-slice `AppDescriptor`, is pinned by the MSO consumer manifest, and reuses
the canonical `/integrations` manager instead of duplicating credential state or actions. The
-ordinary browser route remains anti-frame (`DENY` / `frame-ancestors 'none'`). Only the explicit
-`?embed=shell` mode permits same-origin framing (`SAMEORIGIN` / `frame-ancestors 'self'`), so the
-new window does not widen cross-origin framing policy.
+ordinary browser route remains anti-frame (`DENY` / `frame-ancestors 'none'`). Only the dedicated
+`/integrations/embed` shell route permits same-origin framing (`SAMEORIGIN` / `frame-ancestors 'self'`);
+the global header policy explicitly overrides `DENY` only for that route, so the new window does not widen
+cross-origin framing policy.
Local SI-Coder migration discovery previously required the version-reported source path to contain
`si-coder-agent`. The installed SC 0.9.8 currently resolves to a legitimate worktree named
diff --git a/frontend/slices/integrations/app.tsx b/frontend/slices/integrations/app.tsx
index 8337ef9d..2920b8c5 100644
--- a/frontend/slices/integrations/app.tsx
+++ b/frontend/slices/integrations/app.tsx
@@ -4,14 +4,14 @@ import { AppFrame } from "@/features/appshell";
/**
* Shell window for the canonical owner Integrations workbench.
- * The iframe reuses /integrations so browser, MCP Page, CLI and the desktop app
- * continue to share one credential-management implementation and policy surface.
+ * The iframe reuses the dedicated same-origin embed route so browser, MCP Page,
+ * CLI and the desktop app still share one credential-management implementation.
*/
export default function IntegrationsApp() {
return (
<AppFrame safeArea={false} bodyClassName="overflow-hidden bg-background">
<iframe
- src="/integrations?embed=shell"
+ src="/integrations/embed"
title="MSO Integrations"
className="h-full w-full border-0 bg-background"
referrerPolicy="same-origin"
diff --git a/lib/infra/setup-page.ts b/lib/infra/setup-page.ts
index 5ad3ad06..edd95ed6 100644
--- a/lib/infra/setup-page.ts
+++ b/lib/infra/setup-page.ts
@@ -13,8 +13,7 @@ export function integrationSetupPage(embedded=false) {
const html = `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="referrer" content="no-referrer"><title>Integrations · MSO</title><style nonce="${nonce}">${MSO_WIDGET_TOKENS}${INTEGRATION_FORM_STYLE}${CONNECTION_MANAGER_STYLE}${PORTABILITY_STYLE}*{box-sizing:border-box}body{margin:0;background:var(--surface);padding:${bodyPadding};font-family:var(--font-body);color:var(--text)}.site-bar{max-width:1180px;margin:0 auto 26px;font-size:var(--type-small);display:flex;justify-content:space-between;gap:var(--space-3)}.site-bar strong{display:flex;align-items:center;gap:var(--space-3);font-weight:750}.site-bar svg{width:30px;height:30px}.site-bar span{color:var(--text-dim)}button{border:var(--stroke) solid var(--sep-strong);border-radius:var(--radius-control);background:var(--field);color:var(--text);padding:var(--space-2) var(--space-3);cursor:pointer}a{color:var(--os-accent)}</style></head><body><header class="site-bar"><strong>${MSO_LOGO_SVG} MSO</strong><span>Your service connections</span></header><main id="setup" class="integration"><h1>Integrations</h1><p>Preparing the native provider catalog…</p><noscript>Enable JavaScript to open the secure credential form. Credentials can also be entered through the MSO terminal.</noscript></main><script nonce="${nonce}">const INTEGRATIONS_CATALOG=${catalog};${INTEGRATION_FORM_SCRIPT}${CONNECTION_MANAGER_SCRIPT}${PORTABILITY_SCRIPT}${INTEGRATION_BROWSER_SCRIPT}</script></body></html>`;
return { html, csp: `default-src 'none'; script-src 'nonce-${nonce}'; style-src 'nonce-${nonce}'; connect-src 'self'; form-action 'none'; base-uri 'none'; frame-ancestors ${embedded?"'self'":"'none'"}` };
}
-export function integrationPageResponse(request?:Request) {
- const embedded=request?new URL(request.url).searchParams.get("embed")==="shell":false;
+export function integrationPageResponse(embedded=false) {
const page = integrationSetupPage(embedded);
return new Response(page.html,{headers:{"Content-Type":"text/html; charset=utf-8","Content-Security-Policy":page.csp,"Cache-Control":"no-store, private","Referrer-Policy":"no-referrer","X-Content-Type-Options":"nosniff","X-Frame-Options":embedded?"SAMEORIGIN":"DENY"}});
}
diff --git a/next.config.mjs b/next.config.mjs
index 59567cde..dc451ccd 100644
--- a/next.config.mjs
+++ b/next.config.mjs
@@ -131,6 +131,10 @@ const nextConfig = {
// carry host bytes (fs/read), auth state, and per-session data.
{ source: "/api/:path*", headers: [{ key: "Cache-Control", value: "no-store" }] },
{ source: "/integrations", headers: [{ key: "Cache-Control", value: "no-store" }, { key: "Referrer-Policy", value: "no-referrer" }] },
+ // Dedicated shell-only embed path. The global DENY remains authoritative for
+ // every ordinary page; this one path is still same-origin only and also has
+ // a route-level CSP `frame-ancestors 'self'`.
+ { source: "/integrations/embed", headers: [{ key: "X-Frame-Options", value: "SAMEORIGIN" }, { key: "Cache-Control", value: "no-store" }, { key: "Referrer-Policy", value: "no-referrer" }] },
{ source: "/api/integrations/:path*", headers: [{ key: "Referrer-Policy", value: "no-referrer" }] },
// Named brand/wallpaper assets are effectively immutable but, unlike
// /_next chunks, are NOT content-hashed — rename or add ?v= if ever redrawn.