From 76d0b5753a841291c78b416007d1fbe3dae9892d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 16 Jun 2026 23:53:23 +0000 Subject: [PATCH] Restrict public browser gateway defaults to newt targets --- .../resources/public/[niceId]/rdp/page.tsx | 6 ++++-- .../resources/public/[niceId]/ssh/page.tsx | 19 +++++++++++-------- .../resources/public/[niceId]/vnc/page.tsx | 6 ++++-- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/app/[orgId]/settings/resources/public/[niceId]/rdp/page.tsx b/src/app/[orgId]/settings/resources/public/[niceId]/rdp/page.tsx index 59e73dea1..26a2abecb 100644 --- a/src/app/[orgId]/settings/resources/public/[niceId]/rdp/page.tsx +++ b/src/app/[orgId]/settings/resources/public/[niceId]/rdp/page.tsx @@ -40,6 +40,7 @@ type TargetRow = { targetId: number; resourceId: number; siteId: number; + siteType: string | null; siteName?: string; mode: string | null; ip: string; @@ -105,7 +106,8 @@ function RdpServerForm({ const api = createApiClient(useEnvContext()); const router = useRouter(); const targets = targetsResponse.targets.filter((t) => t.mode === "rdp"); - const firstTarget = targets[0]; + const browserGatewayTargets = targets.filter((t) => t.siteType === "newt"); + const firstTarget = browserGatewayTargets[0]; const formSchema = useMemo( () => createBrowserGatewayTargetFormSchema(t), @@ -115,7 +117,7 @@ function RdpServerForm({ const form = useForm({ resolver: zodResolver(formSchema), defaultValues: { - selectedSites: targets.map((target) => ({ + selectedSites: browserGatewayTargets.map((target) => ({ siteId: target.siteId, name: target.siteName ?? String(target.siteId), type: "newt" as const diff --git a/src/app/[orgId]/settings/resources/public/[niceId]/ssh/page.tsx b/src/app/[orgId]/settings/resources/public/[niceId]/ssh/page.tsx index 8696e1967..6ef4f2af2 100644 --- a/src/app/[orgId]/settings/resources/public/[niceId]/ssh/page.tsx +++ b/src/app/[orgId]/settings/resources/public/[niceId]/ssh/page.tsx @@ -62,6 +62,7 @@ type TargetRow = { targetId: number; resourceId: number; siteId: number; + siteType: string | null; siteName?: string; mode: string | null; ip: string; @@ -130,7 +131,9 @@ function SshServerForm({ const isNativeInitially = resource.authDaemonMode === "native"; const targets = targetsResponse.targets.filter((t) => t.mode === "ssh"); + const browserGatewayTargets = targets.filter((t) => t.siteType === "newt"); const firstTarget = targets[0]; + const firstBrowserGatewayTarget = browserGatewayTargets[0]; const initialPamMode = (resource.pamMode as "passthrough" | "push") || "passthrough"; const initialStandardDaemonLocation = isNativeInitially @@ -163,18 +166,18 @@ function SshServerForm({ selectedSites: isNativeInitially || useSingleSiteOnLoad ? [] - : targets.map((target) => ({ + : browserGatewayTargets.map((target) => ({ siteId: target.siteId, name: target.siteName ?? String(target.siteId), type: "newt" as const })), selectedSite: - useSingleSiteOnLoad && firstTarget + useSingleSiteOnLoad && firstBrowserGatewayTarget ? { - siteId: firstTarget.siteId, + siteId: firstBrowserGatewayTarget.siteId, name: - firstTarget.siteName ?? - String(firstTarget.siteId), + firstBrowserGatewayTarget.siteName ?? + String(firstBrowserGatewayTarget.siteId), type: "newt" as const } : null, @@ -190,11 +193,11 @@ function SshServerForm({ : null, destination: isNativeInitially ? "" - : (firstTarget?.ip ?? ""), + : (firstBrowserGatewayTarget?.ip ?? ""), destinationPort: isNativeInitially ? "22" - : firstTarget - ? String(firstTarget.port) + : firstBrowserGatewayTarget + ? String(firstBrowserGatewayTarget.port) : "22" } }); diff --git a/src/app/[orgId]/settings/resources/public/[niceId]/vnc/page.tsx b/src/app/[orgId]/settings/resources/public/[niceId]/vnc/page.tsx index 3efe29ee4..fac7b1de2 100644 --- a/src/app/[orgId]/settings/resources/public/[niceId]/vnc/page.tsx +++ b/src/app/[orgId]/settings/resources/public/[niceId]/vnc/page.tsx @@ -40,6 +40,7 @@ type TargetRow = { targetId: number; resourceId: number; siteId: number; + siteType: string | null; siteName?: string; mode: string | null; ip: string; @@ -105,7 +106,8 @@ function VncServerForm({ const api = createApiClient(useEnvContext()); const router = useRouter(); const targets = targetsResponse.targets.filter((t) => t.mode === "vnc"); - const firstTarget = targets[0]; + const browserGatewayTargets = targets.filter((t) => t.siteType === "newt"); + const firstTarget = browserGatewayTargets[0]; const formSchema = useMemo( () => createBrowserGatewayTargetFormSchema(t), @@ -115,7 +117,7 @@ function VncServerForm({ const form = useForm({ resolver: zodResolver(formSchema), defaultValues: { - selectedSites: targets.map((target) => ({ + selectedSites: browserGatewayTargets.map((target) => ({ siteId: target.siteId, name: target.siteName ?? String(target.siteId), type: "newt" as const