Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
fix endpoint and improve frontend performance
x032205bf1bdf93ec99
diff --git a/frontend/src/hooks/api/pam/queries.tsx b/frontend/src/hooks/api/pam/queries.tsxindex 60ead74ecf..22810c4e3f 100644--- a/frontend/src/hooks/api/pam/queries.tsx+++ b/frontend/src/hooks/api/pam/queries.tsx@@ -4,6 +4,7 @@ import { apiRequest } from "@app/config/request";import { TPamResourceOption } from "./types/resource-options";import { TPamAccount, TPamFolder, TPamResource, TPamSession } from "./types";+import { PamResourceType } from "./enums";export const pamKeys = {all: ["pam"] as const,@@ -70,22 +71,23 @@ export const useListPamResources = (};export const useGetPamResourceById = (+ resourceType?: PamResourceType,resourceId?: string,options?: Omit<UseQueryOptions<TPamResource, unknown, TPamResource, ReturnType<typeof pamKeys.getResource>>,- "queryKey" | "queryFn" | "enabled"+ "queryKey" | "queryFn">) => {return useQuery({queryKey: pamKeys.getResource(resourceId || ""),queryFn: async () => {const { data } = await apiRequest.get<{ resource: TPamResource }>(- `/api/v1/pam/resources/${resourceId}`+ `/api/v1/pam/resources/${resourceType}/${resourceId}`);return data.resource;},- enabled: !!resourceId,+ enabled: !!resourceId && !!resourceType && (options?.enabled ?? true),...options});};diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PamAccountForm.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PamAccountForm.tsxindex eee101a541..8b553e656a 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PamAccountForm.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PamAccountForm.tsx@@ -65,7 +65,13 @@ const CreateForm = ({switch (resourceType) {case PamResourceType.Postgres:- return <PostgresAccountForm onSubmit={onSubmit} resourceId={resourceId} />;+ return (+ <PostgresAccountForm+ onSubmit={onSubmit}+ resourceId={resourceId}+ resourceType={resourceType}+ />+ );default:throw new Error(`Unhandled resource: ${resourceType}`);}diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PostgresAccountForm.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PostgresAccountForm.tsxindex 5a2104275a..c353a278b4 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PostgresAccountForm.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PostgresAccountForm.tsx@@ -4,7 +4,7 @@ import { zodResolver } from "@hookform/resolvers/zod";import { z } from "zod";import { Button, ModalClose } from "@app/components/v2";-import { TPostgresAccount, useGetPamResourceById } from "@app/hooks/api/pam";+import { PamResourceType, TPostgresAccount, useGetPamResourceById } from "@app/hooks/api/pam";import { BaseSqlAccountSchema } from "./shared/sql-account-schemas";import { SqlAccountFields } from "./shared/SqlAccountFields";@@ -14,6 +14,7 @@ import { RotateAccountFields, rotateAccountFieldsSchema } from "./RotateAccountFtype Props = {account?: TPostgresAccount;resourceId?: string;+ resourceType?: PamResourceType;onSubmit: (formData: FormData) => Promise<void>;};@@ -23,7 +24,7 @@ const formSchema = genericAccountFieldsSchema.extend(rotateAccountFieldsSchema.stype FormData = z.infer<typeof formSchema>;-export const PostgresAccountForm = ({ account, resourceId, onSubmit }: Props) => {+export const PostgresAccountForm = ({ account, resourceId, resourceType, onSubmit }: Props) => {const isUpdate = Boolean(account);const form = useForm<FormData>({@@ -46,7 +47,9 @@ export const PostgresAccountForm = ({ account, resourceId, onSubmit }: Props) =>const [rotationCredentialsConfigured, setRotationCredentialsConfigured] = useState(false);- const { data: resource } = useGetPamResourceById(resourceId);+ const { data: resource } = useGetPamResourceById(resourceType, resourceId, {+ enabled: !account && !!resourceId && !!resourceType+ });useEffect(() => {if (account) {