mirror of
https://github.com/fosrl/pangolin.git
synced 2026-07-06 04:10:13 +00:00
Restrict public browser gateway defaults to newt targets
This commit is contained in:
committed by
GitHub
parent
f9cc52ece9
commit
76d0b5753a
@@ -40,6 +40,7 @@ type TargetRow = {
|
|||||||
targetId: number;
|
targetId: number;
|
||||||
resourceId: number;
|
resourceId: number;
|
||||||
siteId: number;
|
siteId: number;
|
||||||
|
siteType: string | null;
|
||||||
siteName?: string;
|
siteName?: string;
|
||||||
mode: string | null;
|
mode: string | null;
|
||||||
ip: string;
|
ip: string;
|
||||||
@@ -105,7 +106,8 @@ function RdpServerForm({
|
|||||||
const api = createApiClient(useEnvContext());
|
const api = createApiClient(useEnvContext());
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const targets = targetsResponse.targets.filter((t) => t.mode === "rdp");
|
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(
|
const formSchema = useMemo(
|
||||||
() => createBrowserGatewayTargetFormSchema(t),
|
() => createBrowserGatewayTargetFormSchema(t),
|
||||||
@@ -115,7 +117,7 @@ function RdpServerForm({
|
|||||||
const form = useForm<BrowserGatewayTargetFormValues>({
|
const form = useForm<BrowserGatewayTargetFormValues>({
|
||||||
resolver: zodResolver(formSchema),
|
resolver: zodResolver(formSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
selectedSites: targets.map((target) => ({
|
selectedSites: browserGatewayTargets.map((target) => ({
|
||||||
siteId: target.siteId,
|
siteId: target.siteId,
|
||||||
name: target.siteName ?? String(target.siteId),
|
name: target.siteName ?? String(target.siteId),
|
||||||
type: "newt" as const
|
type: "newt" as const
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ type TargetRow = {
|
|||||||
targetId: number;
|
targetId: number;
|
||||||
resourceId: number;
|
resourceId: number;
|
||||||
siteId: number;
|
siteId: number;
|
||||||
|
siteType: string | null;
|
||||||
siteName?: string;
|
siteName?: string;
|
||||||
mode: string | null;
|
mode: string | null;
|
||||||
ip: string;
|
ip: string;
|
||||||
@@ -130,7 +131,9 @@ function SshServerForm({
|
|||||||
|
|
||||||
const isNativeInitially = resource.authDaemonMode === "native";
|
const isNativeInitially = resource.authDaemonMode === "native";
|
||||||
const targets = targetsResponse.targets.filter((t) => t.mode === "ssh");
|
const targets = targetsResponse.targets.filter((t) => t.mode === "ssh");
|
||||||
|
const browserGatewayTargets = targets.filter((t) => t.siteType === "newt");
|
||||||
const firstTarget = targets[0];
|
const firstTarget = targets[0];
|
||||||
|
const firstBrowserGatewayTarget = browserGatewayTargets[0];
|
||||||
const initialPamMode =
|
const initialPamMode =
|
||||||
(resource.pamMode as "passthrough" | "push") || "passthrough";
|
(resource.pamMode as "passthrough" | "push") || "passthrough";
|
||||||
const initialStandardDaemonLocation = isNativeInitially
|
const initialStandardDaemonLocation = isNativeInitially
|
||||||
@@ -163,18 +166,18 @@ function SshServerForm({
|
|||||||
selectedSites:
|
selectedSites:
|
||||||
isNativeInitially || useSingleSiteOnLoad
|
isNativeInitially || useSingleSiteOnLoad
|
||||||
? []
|
? []
|
||||||
: targets.map((target) => ({
|
: browserGatewayTargets.map((target) => ({
|
||||||
siteId: target.siteId,
|
siteId: target.siteId,
|
||||||
name: target.siteName ?? String(target.siteId),
|
name: target.siteName ?? String(target.siteId),
|
||||||
type: "newt" as const
|
type: "newt" as const
|
||||||
})),
|
})),
|
||||||
selectedSite:
|
selectedSite:
|
||||||
useSingleSiteOnLoad && firstTarget
|
useSingleSiteOnLoad && firstBrowserGatewayTarget
|
||||||
? {
|
? {
|
||||||
siteId: firstTarget.siteId,
|
siteId: firstBrowserGatewayTarget.siteId,
|
||||||
name:
|
name:
|
||||||
firstTarget.siteName ??
|
firstBrowserGatewayTarget.siteName ??
|
||||||
String(firstTarget.siteId),
|
String(firstBrowserGatewayTarget.siteId),
|
||||||
type: "newt" as const
|
type: "newt" as const
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
@@ -190,11 +193,11 @@ function SshServerForm({
|
|||||||
: null,
|
: null,
|
||||||
destination: isNativeInitially
|
destination: isNativeInitially
|
||||||
? ""
|
? ""
|
||||||
: (firstTarget?.ip ?? ""),
|
: (firstBrowserGatewayTarget?.ip ?? ""),
|
||||||
destinationPort: isNativeInitially
|
destinationPort: isNativeInitially
|
||||||
? "22"
|
? "22"
|
||||||
: firstTarget
|
: firstBrowserGatewayTarget
|
||||||
? String(firstTarget.port)
|
? String(firstBrowserGatewayTarget.port)
|
||||||
: "22"
|
: "22"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ type TargetRow = {
|
|||||||
targetId: number;
|
targetId: number;
|
||||||
resourceId: number;
|
resourceId: number;
|
||||||
siteId: number;
|
siteId: number;
|
||||||
|
siteType: string | null;
|
||||||
siteName?: string;
|
siteName?: string;
|
||||||
mode: string | null;
|
mode: string | null;
|
||||||
ip: string;
|
ip: string;
|
||||||
@@ -105,7 +106,8 @@ function VncServerForm({
|
|||||||
const api = createApiClient(useEnvContext());
|
const api = createApiClient(useEnvContext());
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const targets = targetsResponse.targets.filter((t) => t.mode === "vnc");
|
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(
|
const formSchema = useMemo(
|
||||||
() => createBrowserGatewayTargetFormSchema(t),
|
() => createBrowserGatewayTargetFormSchema(t),
|
||||||
@@ -115,7 +117,7 @@ function VncServerForm({
|
|||||||
const form = useForm<BrowserGatewayTargetFormValues>({
|
const form = useForm<BrowserGatewayTargetFormValues>({
|
||||||
resolver: zodResolver(formSchema),
|
resolver: zodResolver(formSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
selectedSites: targets.map((target) => ({
|
selectedSites: browserGatewayTargets.map((target) => ({
|
||||||
siteId: target.siteId,
|
siteId: target.siteId,
|
||||||
name: target.siteName ?? String(target.siteId),
|
name: target.siteName ?? String(target.siteId),
|
||||||
type: "newt" as const
|
type: "newt" as const
|
||||||
|
|||||||
Reference in New Issue
Block a user