mirror of
https://github.com/fosrl/pangolin.git
synced 2026-05-27 19:22:50 +00:00
Use the create api
This commit is contained in:
@@ -44,7 +44,11 @@ const createHttpResourceSchema = z
|
|||||||
domainId: z.string(),
|
domainId: z.string(),
|
||||||
stickySession: z.boolean().optional(),
|
stickySession: z.boolean().optional(),
|
||||||
postAuthPath: z.string().nullable().optional(),
|
postAuthPath: z.string().nullable().optional(),
|
||||||
browserAccessType: z.enum(["http", "ssh", "rdp", "vnc"]).optional()
|
browserAccessType: z.enum(["http", "ssh", "rdp", "vnc"]).optional(),
|
||||||
|
// SSH Settings
|
||||||
|
pamMode: z.enum(["passthrough", "push"]).optional(),
|
||||||
|
authDaemonPort: z.int().positive().optional(),
|
||||||
|
authDaemonMode: z.enum(["site", "remote", "native"]).optional()
|
||||||
})
|
})
|
||||||
.refine(
|
.refine(
|
||||||
(data) => {
|
(data) => {
|
||||||
@@ -202,7 +206,15 @@ async function createHttpResource(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { name, domainId, postAuthPath, browserAccessType } = parsedBody.data;
|
const {
|
||||||
|
name,
|
||||||
|
domainId,
|
||||||
|
postAuthPath,
|
||||||
|
browserAccessType,
|
||||||
|
authDaemonPort,
|
||||||
|
authDaemonMode,
|
||||||
|
pamMode
|
||||||
|
} = parsedBody.data;
|
||||||
const subdomain = parsedBody.data.subdomain;
|
const subdomain = parsedBody.data.subdomain;
|
||||||
const stickySession = parsedBody.data.stickySession;
|
const stickySession = parsedBody.data.stickySession;
|
||||||
|
|
||||||
@@ -328,6 +340,9 @@ async function createHttpResource(
|
|||||||
subdomain: finalSubdomain,
|
subdomain: finalSubdomain,
|
||||||
http: true,
|
http: true,
|
||||||
browserAccessType: browserAccessType,
|
browserAccessType: browserAccessType,
|
||||||
|
pamMode: pamMode,
|
||||||
|
authDaemonMode: authDaemonMode,
|
||||||
|
authDaemonPort: authDaemonPort,
|
||||||
protocol: "tcp",
|
protocol: "tcp",
|
||||||
ssl: true,
|
ssl: true,
|
||||||
stickySession: stickySession,
|
stickySession: stickySession,
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ const createSiteResourceSchema = z
|
|||||||
disableIcmp: z.boolean().optional(),
|
disableIcmp: z.boolean().optional(),
|
||||||
authDaemonPort: z.int().positive().optional(),
|
authDaemonPort: z.int().positive().optional(),
|
||||||
authDaemonMode: z.enum(["site", "remote"]).optional(),
|
authDaemonMode: z.enum(["site", "remote"]).optional(),
|
||||||
|
pamMode: z.enum(["passthrough", "push"]).optional(),
|
||||||
domainId: z.string().optional(), // only used for http mode, we need this to verify the alias is unique within the org
|
domainId: z.string().optional(), // only used for http mode, we need this to verify the alias is unique within the org
|
||||||
subdomain: z.string().optional() // only used for http mode, we need this to verify the alias is unique within the org
|
subdomain: z.string().optional() // only used for http mode, we need this to verify the alias is unique within the org
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -393,8 +393,7 @@ export default function Page() {
|
|||||||
try {
|
try {
|
||||||
const payload: any = {
|
const payload: any = {
|
||||||
name: baseData.name,
|
name: baseData.name,
|
||||||
http: isHttpResource,
|
http: isHttpResource
|
||||||
browserAccessType: resourceType
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let sanitizedSubdomain: string | undefined;
|
let sanitizedSubdomain: string | undefined;
|
||||||
@@ -406,12 +405,28 @@ export default function Page() {
|
|||||||
? finalizeSubdomainSanitize(httpData.subdomain, true)
|
? finalizeSubdomainSanitize(httpData.subdomain, true)
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
|
const effectiveMode = isNative
|
||||||
|
? "native"
|
||||||
|
: standardDaemonLocation;
|
||||||
|
const portVal = sshDaemonPortForm.getValues().authDaemonPort;
|
||||||
|
const effectivePort =
|
||||||
|
!isNative &&
|
||||||
|
standardDaemonLocation === "remote" &&
|
||||||
|
pamMode === "push" &&
|
||||||
|
portVal
|
||||||
|
? Number(portVal)
|
||||||
|
: null;
|
||||||
|
|
||||||
Object.assign(payload, {
|
Object.assign(payload, {
|
||||||
subdomain: sanitizedSubdomain
|
subdomain: sanitizedSubdomain
|
||||||
? toASCII(sanitizedSubdomain)
|
? toASCII(sanitizedSubdomain)
|
||||||
: undefined,
|
: undefined,
|
||||||
domainId: httpData.domainId,
|
domainId: httpData.domainId,
|
||||||
protocol: "tcp"
|
protocol: "tcp",
|
||||||
|
browserAccessType: resourceType,
|
||||||
|
pamMode,
|
||||||
|
authDaemonMode: effectiveMode,
|
||||||
|
authDaemonPort: effectivePort
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const tcpUdpData = tcpUdpForm.getValues();
|
const tcpUdpData = tcpUdpForm.getValues();
|
||||||
@@ -498,25 +513,6 @@ export default function Page() {
|
|||||||
`/${orgId}/settings/resources/proxy/${newNiceId}`
|
`/${orgId}/settings/resources/proxy/${newNiceId}`
|
||||||
);
|
);
|
||||||
} else if (resourceType === "ssh") {
|
} else if (resourceType === "ssh") {
|
||||||
const effectiveMode = isNative
|
|
||||||
? "native"
|
|
||||||
: standardDaemonLocation;
|
|
||||||
const portVal =
|
|
||||||
sshDaemonPortForm.getValues().authDaemonPort;
|
|
||||||
const effectivePort =
|
|
||||||
!isNative &&
|
|
||||||
standardDaemonLocation === "remote" &&
|
|
||||||
pamMode === "push" &&
|
|
||||||
portVal
|
|
||||||
? Number(portVal)
|
|
||||||
: null;
|
|
||||||
|
|
||||||
await api.post(`/resource/${id}`, {
|
|
||||||
pamMode,
|
|
||||||
authDaemonMode: effectiveMode,
|
|
||||||
authDaemonPort: effectivePort
|
|
||||||
});
|
|
||||||
|
|
||||||
if (isNative) {
|
if (isNative) {
|
||||||
if (nativeSelectedSite) {
|
if (nativeSelectedSite) {
|
||||||
await api.put(
|
await api.put(
|
||||||
|
|||||||
Reference in New Issue
Block a user