mirror of
https://github.com/fosrl/pangolin.git
synced 2026-06-05 23:28:44 +00:00
Fix some ui form issues
This commit is contained in:
@@ -14,7 +14,6 @@ if (fs.existsSync(allowedDevOriginsPath)) {
|
||||
try {
|
||||
const data = fs.readFileSync(allowedDevOriginsPath, "utf-8");
|
||||
allowedDevOrigins = JSON.parse(data);
|
||||
console.log("Loaded allowed development origins:", allowedDevOrigins);
|
||||
} catch {}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ export * from "./verifyApiKeyAccess";
|
||||
export * from "./verifySiteProvisioningKeyAccess";
|
||||
export * from "./verifyDomainAccess";
|
||||
export * from "./verifyUserIsOrgOwner";
|
||||
export * from "./verifyUserFromSessionOrHeaders";
|
||||
export * from "./verifyUserFromResourceSession";
|
||||
export * from "./verifySiteResourceAccess";
|
||||
export * from "./logActionAudit";
|
||||
export * from "./verifyOlmAccess";
|
||||
|
||||
@@ -117,17 +117,28 @@ export async function listBrowserGatewayTargets(
|
||||
);
|
||||
}
|
||||
|
||||
const targets = await db
|
||||
.select()
|
||||
const rows = await db
|
||||
.select({
|
||||
browserGatewayTargetId:
|
||||
browserGatewayTarget.browserGatewayTargetId,
|
||||
resourceId: browserGatewayTarget.resourceId,
|
||||
siteId: browserGatewayTarget.siteId,
|
||||
authToken: browserGatewayTarget.authToken,
|
||||
type: browserGatewayTarget.type,
|
||||
destination: browserGatewayTarget.destination,
|
||||
destinationPort: browserGatewayTarget.destinationPort,
|
||||
siteName: sites.name
|
||||
})
|
||||
.from(browserGatewayTarget)
|
||||
.leftJoin(sites, eq(sites.siteId, browserGatewayTarget.siteId))
|
||||
.where(eq(browserGatewayTarget.resourceId, resourceId))
|
||||
.limit(limit)
|
||||
.offset(offset);
|
||||
|
||||
return response<ListBrowserGatewayTargetsResponse>(res, {
|
||||
data: {
|
||||
targets: targets,
|
||||
total: targets.length,
|
||||
targets: rows as any,
|
||||
total: rows.length,
|
||||
limit,
|
||||
offset
|
||||
},
|
||||
|
||||
@@ -26,6 +26,15 @@ const listOrgsSchema = z.object({
|
||||
.pipe(z.int().nonnegative())
|
||||
});
|
||||
|
||||
const ListOrgsResponseDataSchema = z.object({
|
||||
orgs: z.array(z.object({}).passthrough()),
|
||||
pagination: z.object({
|
||||
total: z.number(),
|
||||
limit: z.number(),
|
||||
offset: z.number()
|
||||
})
|
||||
});
|
||||
|
||||
registry.registerPath({
|
||||
method: "get",
|
||||
path: "/orgs",
|
||||
@@ -51,15 +60,6 @@ export type ListOrgsResponse = {
|
||||
pagination: { total: number; limit: number; offset: number };
|
||||
};
|
||||
|
||||
const ListOrgsResponseDataSchema = z.object({
|
||||
orgs: z.array(z.object({}).passthrough()),
|
||||
pagination: z.object({
|
||||
total: z.number(),
|
||||
limit: z.number(),
|
||||
offset: z.number()
|
||||
})
|
||||
});
|
||||
|
||||
export async function listOrgs(
|
||||
req: Request,
|
||||
res: Response,
|
||||
|
||||
@@ -524,25 +524,21 @@ export async function createSiteResource(
|
||||
});
|
||||
|
||||
if (roleIds.length > 0) {
|
||||
await trx
|
||||
.insert(roleSiteResources)
|
||||
.values(
|
||||
roleIds.map((roleId) => ({
|
||||
roleId,
|
||||
siteResourceId
|
||||
}))
|
||||
);
|
||||
await trx.insert(roleSiteResources).values(
|
||||
roleIds.map((roleId) => ({
|
||||
roleId,
|
||||
siteResourceId
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
if (userIds.length > 0) {
|
||||
await trx
|
||||
.insert(userSiteResources)
|
||||
.values(
|
||||
userIds.map((userId) => ({
|
||||
userId,
|
||||
siteResourceId
|
||||
}))
|
||||
);
|
||||
await trx.insert(userSiteResources).values(
|
||||
userIds.map((userId) => ({
|
||||
userId,
|
||||
siteResourceId
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
if (clientIds.length > 0) {
|
||||
|
||||
@@ -42,7 +42,7 @@ import {
|
||||
useState,
|
||||
useTransition
|
||||
} from "react";
|
||||
import CreatePrivateResourceDialog from "@app/components/CreateInternalResourceDialog";
|
||||
import CreatePrivateResourceDialog from "@app/components/CreatePrivateResourceDialog";
|
||||
import EditPrivateResourceDialog from "@app/components/EditPrivateResourceDialog";
|
||||
import type { PaginationState } from "@tanstack/react-table";
|
||||
import { ControlledDataTable } from "./ui/controlled-data-table";
|
||||
|
||||
@@ -62,16 +62,13 @@ export default function CreatePrivateResourceDialog({
|
||||
}
|
||||
}
|
||||
|
||||
// "ssh" mode maps to "host" in the backend with SSH settings
|
||||
const backendMode = data.mode === "ssh" ? "host" : data.mode;
|
||||
|
||||
await api.put<
|
||||
AxiosResponse<{ data: { siteResourceId: number } }>
|
||||
>(`/org/${orgId}/site-resource`, {
|
||||
name: data.name,
|
||||
siteIds: data.siteIds,
|
||||
mode: backendMode,
|
||||
destination: data.destination,
|
||||
mode: data.mode,
|
||||
destination: data.destination ?? undefined,
|
||||
enabled: true,
|
||||
...(data.mode === "http" && {
|
||||
scheme: data.scheme,
|
||||
|
||||
@@ -66,15 +66,12 @@ export default function EditPrivateResourceDialog({
|
||||
}
|
||||
}
|
||||
|
||||
// "ssh" mode maps to "host" in the backend with SSH settings
|
||||
const backendMode = data.mode === "ssh" ? "host" : data.mode;
|
||||
|
||||
await api.post(`/site-resource/${resource.id}`, {
|
||||
name: data.name,
|
||||
siteIds: data.siteIds,
|
||||
mode: backendMode,
|
||||
mode: data.mode,
|
||||
niceId: data.niceId,
|
||||
destination: data.destination,
|
||||
destination: data.destination ?? undefined,
|
||||
...(data.mode === "http" && {
|
||||
scheme: data.scheme,
|
||||
ssl: data.ssl ?? false,
|
||||
|
||||
@@ -478,14 +478,12 @@ export function PrivateResourceForm({
|
||||
|
||||
const [sshServerMode, setSshServerMode] = useState<"standard" | "native">(
|
||||
() => {
|
||||
if (
|
||||
variant === "edit" &&
|
||||
resource &&
|
||||
resource.authDaemonMode === "native"
|
||||
) {
|
||||
return "native";
|
||||
if (variant === "edit" && resource) {
|
||||
return resource.authDaemonMode === "native"
|
||||
? "native"
|
||||
: "standard";
|
||||
}
|
||||
return "standard";
|
||||
return "native";
|
||||
}
|
||||
);
|
||||
|
||||
@@ -559,7 +557,7 @@ export function PrivateResourceForm({
|
||||
tcpPortRangeString: "*",
|
||||
udpPortRangeString: "*",
|
||||
disableIcmp: false,
|
||||
authDaemonMode: "site",
|
||||
authDaemonMode: "native",
|
||||
authDaemonPort: null,
|
||||
pamMode: "passthrough",
|
||||
roles: [],
|
||||
@@ -624,7 +622,7 @@ export function PrivateResourceForm({
|
||||
tcpPortRangeString: "*",
|
||||
udpPortRangeString: "*",
|
||||
disableIcmp: false,
|
||||
authDaemonMode: "site",
|
||||
authDaemonMode: "native",
|
||||
authDaemonPort: null,
|
||||
pamMode: "passthrough",
|
||||
roles: [],
|
||||
|
||||
Reference in New Issue
Block a user