Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

cli fix

x032205d17d39eeba94
diff --git a/backend/src/ee/routes/v1/pam-routers/pam-account-router.ts b/backend/src/ee/routes/v1/pam-routers/pam-account-router.ts
index da8f694d91..c05e857ece 100644
--- a/backend/src/ee/routes/v1/pam-routers/pam-account-router.ts
+++ b/backend/src/ee/routes/v1/pam-routers/pam-account-router.ts
@@ -13,6 +13,7 @@ import {
PamTemplateAccessPolicySchema,
PamTemplateSettingsSchema
} from "@app/ee/services/pam-account-template/pam-account-template-schemas";
+import { SESSION_HANDLERS } from "@app/ee/services/pam-web-access/pam-session-handlers";
import { ApiDocsTags } from "@app/lib/api-docs/constants";
import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { slugSchema } from "@app/server/lib/schemas";
@@ -292,7 +293,9 @@ export const registerPamAccountRouter = async (server: FastifyZodProvider) => {
config: { rateLimit: readLimit },
onRequest: verifyAuth([AuthMode.JWT]),
handler: async () => {
- return { accountTypes: buildPamAccountTypeMetadata() };
+ return {
+ accountTypes: buildPamAccountTypeMetadata(new Set(Object.keys(SESSION_HANDLERS) as PamAccountType[]))
+ };
}
});
diff --git a/backend/src/ee/services/pam-account/pam-account-schemas.test.ts b/backend/src/ee/services/pam-account/pam-account-schemas.test.ts
index 0a0390521e..118c3c8cbb 100644
--- a/backend/src/ee/services/pam-account/pam-account-schemas.test.ts
+++ b/backend/src/ee/services/pam-account/pam-account-schemas.test.ts
@@ -13,9 +13,15 @@ import {
// These assertions exercise the Zod-introspection path (buildPamAccountTypeMetadata reads schema internals to derive field descriptors)
describe("buildPamAccountTypeMetadata", () => {
- const metadata = buildPamAccountTypeMetadata();
+ const metadata = buildPamAccountTypeMetadata(new Set([PamAccountType.Postgres, PamAccountType.SSH]));
const byType = new Map(metadata.map((m) => [m.type, m]));
+ test("flags web-access support from the provided supported-types set", () => {
+ expect(byType.get(PamAccountType.Postgres)?.supportsWebAccess).toBe(true);
+ expect(byType.get(PamAccountType.SSH)?.supportsWebAccess).toBe(true);
+ expect(byType.get(PamAccountType.MySQL)?.supportsWebAccess).toBe(false);
+ });
+
const fieldByKey = <T extends { key: string }>(fields: T[], key: string) => fields.find((f) => f.key === key);
test("emits valid, non-empty field descriptors for every configured account type", () => {
diff --git a/backend/src/ee/services/pam-account/pam-account-schemas.ts b/backend/src/ee/services/pam-account/pam-account-schemas.ts
index edd1986512..410702086b 100644
--- a/backend/src/ee/services/pam-account/pam-account-schemas.ts
+++ b/backend/src/ee/services/pam-account/pam-account-schemas.ts
@@ -279,6 +279,7 @@ export const PamAccountTypeMetadataSchema = z.object({
type: z.nativeEnum(PamAccountType),
name: z.string(),
icon: z.string(),
+ supportsWebAccess: z.boolean(),
connectionFields: z.array(PamFieldDescriptorSchema),
credentialFields: z.array(PamFieldDescriptorSchema)
});
@@ -410,7 +411,7 @@ const fieldsFromSchema = (schema: z.ZodTypeAny, ui: Record<string, TFieldUiHint>
return [];
};
-export const buildPamAccountTypeMetadata = (): PamAccountTypeMetadata[] =>
+export const buildPamAccountTypeMetadata = (webAccessSupportedTypes: Set<PamAccountType>): PamAccountTypeMetadata[] =>
(
Object.entries(ACCOUNT_TYPE_CONFIGS) as [
TSupportedAccountType,
@@ -420,6 +421,7 @@ export const buildPamAccountTypeMetadata = (): PamAccountTypeMetadata[] =>
type,
name: config.name,
icon: config.icon,
+ supportsWebAccess: webAccessSupportedTypes.has(type),
connectionFields: fieldsFromSchema(config.connectionDetails, config.ui),
credentialFields: fieldsFromSchema(config.credentials, config.ui)
}));
diff --git a/backend/src/ee/services/pam/CLAUDE.md b/backend/src/ee/services/pam/CLAUDE.md
index 6a12760637..2548709553 100644
--- a/backend/src/ee/services/pam/CLAUDE.md
+++ b/backend/src/ee/services/pam/CLAUDE.md
@@ -94,7 +94,7 @@ Defined in `pam/pam-enums.ts` as `PamAccountType`. Each type's full config lives
### Schema-Driven Forms
-The frontend renders the create/edit account forms entirely from backend metadata -- there are **no per-type frontend components**. `buildPamAccountTypeMetadata()` walks each config's Zod schemas and emits `PamFieldDescriptor`s (`{ key, label, widget, required, secret, options?, showWhen? }`). The `GET /pam/accounts/types` endpoint serves these as `PamAccountTypeMetadata` (`{ type, name, icon, connectionFields, credentialFields }`).
+The frontend renders the create/edit account forms entirely from backend metadata -- there are **no per-type frontend components**. `buildPamAccountTypeMetadata(webAccessSupportedTypes)` walks each config's Zod schemas and emits `PamFieldDescriptor`s (`{ key, label, widget, required, secret, options?, defaultValue?, showWhen? }`). The `GET /pam/accounts/types` endpoint serves these as `PamAccountTypeMetadata` (`{ type, name, icon, supportsWebAccess, connectionFields, credentialFields }`). `supportsWebAccess` is derived from the `SESSION_HANDLERS` keys (passed in by the route) -- the single source of truth for browser-session support -- so the frontend gates Browser vs CLI launch without a separate list to maintain.
How descriptors are derived:
- **Label** -- `ui[key].label`, else humanized from the field key.
diff --git a/frontend/src/hooks/api/pam/types/index.ts b/frontend/src/hooks/api/pam/types/index.ts
index fd6f1f229d..44d2c1ae4c 100644
--- a/frontend/src/hooks/api/pam/types/index.ts
+++ b/frontend/src/hooks/api/pam/types/index.ts
@@ -38,6 +38,7 @@ export type TPamAccountTypeMetadata = {
type: PamAccountType;
name: string;
icon: string;
+ supportsWebAccess: boolean;
connectionFields: TPamFieldDescriptor[];
credentialFields: TPamFieldDescriptor[];
};
diff --git a/frontend/src/pages/pam/PamAccessPage/components/LaunchSessionSheet.tsx b/frontend/src/pages/pam/PamAccessPage/components/LaunchSessionSheet.tsx
index ed917ec9b1..8fa08a722c 100644
--- a/frontend/src/pages/pam/PamAccessPage/components/LaunchSessionSheet.tsx
+++ b/frontend/src/pages/pam/PamAccessPage/components/LaunchSessionSheet.tsx
@@ -1,9 +1,9 @@
import { ReactNode, useState } from "react";
import { Link } from "@tanstack/react-router";
-import { FolderOpen, Globe, Rocket, Terminal } from "lucide-react";
+import { Copy, FolderOpen, Globe, Rocket, Terminal } from "lucide-react";
+import { createNotification } from "@app/components/notifications";
import {
- Badge,
Button,
Card,
CardContent,
@@ -12,6 +12,7 @@ import {
CardTitle,
Field,
FieldLabel,
+ IconButton,
RadioGroup,
RadioGroupItem
} from "@app/components/v3";
@@ -32,6 +33,8 @@ type Props = {
onOpenChange: (open: boolean) => void;
};
+type LaunchMethod = "browser" | "cli";
+
const formatFieldValue = (value: unknown): ReactNode => {
if (typeof value === "boolean") return value ? "Enabled" : "Disabled";
const str = String(value);
@@ -39,9 +42,21 @@ const formatFieldValue = (value: unknown): ReactNode => {
return <span className="font-mono">{str}</span>;
};
-const LaunchTab = ({ account }: { account: TAccessiblePamAccount }) => {
+const LaunchTab = ({
+ account,
+ supportsWebAccess
+}: {
+ account: TAccessiblePamAccount;
+ supportsWebAccess: boolean;
+}) => {
const { currentOrg } = useOrganization();
- const [method, setMethod] = useState("browser");
+ const [method, setMethod] = useState<LaunchMethod>(supportsWebAccess ? "browser" : "cli");
+
+ const cliCommand = `infisical pam access ${account.folderName}/${account.name}`;
+ const handleCopyCommand = async () => {
+ await navigator.clipboard.writeText(cliCommand);
+ createNotification({ text: "Command copied to clipboard", type: "success" });
+ };
return (
<div className="flex flex-1 flex-col gap-4 p-4">
@@ -51,54 +66,78 @@ const LaunchTab = ({ account }: { account: TAccessiblePamAccount }) => {
<CardDescription>Choose how to connect to this account.</CardDescription>
</CardHeader>
<CardContent className="flex flex-col gap-5">
- <div>
- <p className="mb-3 text-sm font-medium text-foreground">Launch method</p>
- <RadioGroup value={method} onValueChange={setMethod} className="grid-cols-2 gap-3">
- <FieldLabel htmlFor="launch-browser" variant="pam">
- <Field orientation="horizontal" className="items-center gap-3">
- <Globe className="size-5 shrink-0 text-foreground" />
- <div className="flex-1 text-left">
- <p className="text-sm font-medium text-foreground">Browser</p>
- <p className="text-xs text-muted">Connect directly from your browser.</p>
- </div>
- <RadioGroupItem id="launch-browser" value="browser" className="sr-only" />
- </Field>
- </FieldLabel>
- <FieldLabel htmlFor="launch-cli" variant="pam">
- <Field orientation="horizontal" className="relative items-center gap-3">
- <Terminal className="size-5 shrink-0 text-foreground" />
- <div className="flex-1 text-left">
- <p className="text-sm font-medium text-foreground">CLI</p>
- <p className="text-xs text-muted">
- Use a custom client with the Infisical CLI.
- </p>
- </div>
- <Badge variant="warning" className="absolute top-2 right-2">
- Coming soon
- </Badge>
- <RadioGroupItem id="launch-cli" value="cli" disabled className="sr-only" />
- </Field>
- </FieldLabel>
- </RadioGroup>
- </div>
-
- <div>
- <p className="mb-2.5 text-sm text-foreground">Launch browser client</p>
- <Button variant="pam" className="w-full" asChild>
- <Link
- to="/organizations/$orgId/pam/accounts/$accountType/$accountId/access"
- params={{
- orgId: currentOrg.id,
- accountType: account.accountType,
- accountId: account.id
- }}
- target="_blank"
+ {supportsWebAccess && (
+ <div>
+ <p className="mb-3 text-sm font-medium text-foreground">Launch method</p>
+ <RadioGroup
+ value={method}
+ onValueChange={(value) => setMethod(value as LaunchMethod)}
+ className="grid-cols-2 gap-3"
>
- <Rocket className="size-4" />
- Connect in Browser
- </Link>
- </Button>
- </div>
+ <FieldLabel htmlFor="launch-browser" variant="pam">
+ <Field orientation="horizontal" className="items-center gap-3">
+ <Globe className="size-5 shrink-0 text-foreground" />
+ <div className="flex-1 text-left">
+ <p className="text-sm font-medium text-foreground">Browser</p>
+ <p className="text-xs text-muted">Connect directly from your browser.</p>
+ </div>
+ <RadioGroupItem id="launch-browser" value="browser" className="sr-only" />
+ </Field>
+ </FieldLabel>
+ <FieldLabel htmlFor="launch-cli" variant="pam">
+ <Field orientation="horizontal" className="items-center gap-3">
+ <Terminal className="size-5 shrink-0 text-foreground" />
+ <div className="flex-1 text-left">
+ <p className="text-sm font-medium text-foreground">CLI</p>
+ <p className="text-xs text-muted">
+ Use a custom client with the Infisical CLI.
+ </p>
+ </div>
+ <RadioGroupItem id="launch-cli" value="cli" className="sr-only" />
+ </Field>
+ </FieldLabel>
+ </RadioGroup>
+ </div>
+ )}
+
+ {method === "browser" && (
+ <div>
+ <p className="mb-2.5 text-sm text-foreground">Launch browser client</p>
+ <Button variant="pam" className="w-full" asChild>
+ <Link
+ to="/organizations/$orgId/pam/accounts/$accountType/$accountId/access"
+ params={{
+ orgId: currentOrg.id,
+ accountType: account.accountType,
+ accountId: account.id
+ }}
+ target="_blank"
+ >
+ <Rocket className="size-4" />
+ Connect in Browser
+ </Link>
+ </Button>
+ </div>
+ )}
+
+ {method === "cli" && (
+ <div>
+ <p className="mb-2.5 text-sm text-foreground">Run this command</p>
+ <div className="flex items-center justify-between gap-3 rounded-md border border-border bg-container px-4 py-3">
+ <code className="font-mono text-sm break-all text-foreground">
+ <span className="text-product-pam">$</span> {cliCommand}
+ </code>
+ <IconButton
+ variant="ghost"
+ aria-label="Copy command"
+ onClick={handleCopyCommand}
+ className="shrink-0 text-muted hover:text-foreground"
+ >
+ <Copy className="size-4" />
+ </IconButton>
+ </div>
+ </div>
+ )}
</CardContent>
</Card>
</div>
@@ -111,7 +150,9 @@ export const LaunchSessionSheet = ({ account, isOpen, onOpenChange }: Props) =>
if (!account) return null;
- const typeName = map[account.accountType]?.name ?? account.accountType;
+ const typeMeta = map[account.accountType];
+ const typeName = typeMeta?.name ?? account.accountType;
+ const supportsWebAccess = Boolean(typeMeta?.supportsWebAccess);
const subtitle = account.folderName ? (
<span className="flex items-center gap-1.5">
@@ -120,7 +161,6 @@ export const LaunchSessionSheet = ({ account, isOpen, onOpenChange }: Props) =>
</span>
) : undefined;
- const typeMeta = map[account.accountType];
const conn = (fullAccount?.connectionDetails ?? {}) as Record<string, unknown>;
const credentials = (fullAccount?.credentials ?? {}) as Record<string, unknown>;
@@ -150,7 +190,7 @@ export const LaunchSessionSheet = ({ account, isOpen, onOpenChange }: Props) =>
value: PamSheetTab.Launch,
label: "Launch",
icon: <Rocket className="mr-1.5 size-4" />,
- content: <LaunchTab account={account} />
+ content: <LaunchTab account={account} supportsWebAccess={supportsWebAccess} />
}
]}
/>