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
feat(pam): redis account type (#7447)
Andre6aff166fe262
diff --git a/backend/src/ee/services/pam-account/pam-account-connection-test.ts b/backend/src/ee/services/pam-account/pam-account-connection-test.tsindex 1f2f41c408..18e70fdfa4 100644--- a/backend/src/ee/services/pam-account/pam-account-connection-test.ts+++ b/backend/src/ee/services/pam-account/pam-account-connection-test.ts@@ -12,6 +12,7 @@ import { extractGatewayTarget, isCredentialConfigured, qualifyUsernameWithDomainexport enum TestConnectionMode {SQL = "sql",MongoDB = "mongodb",+ Redis = "redis",LDAP = "ldap",Kubernetes = "kubernetes",SSH = "ssh",@@ -39,6 +40,14 @@ export type TestConnectionRequest =sslRejectUnauthorized?: boolean;sslCertificate?: string;}+ | {+ mode: TestConnectionMode.Redis;+ username?: string;+ password?: string;+ sslEnabled?: boolean;+ sslRejectUnauthorized?: boolean;+ sslCertificate?: string;+ }| {mode: TestConnectionMode.LDAP;username: string;@@ -138,6 +147,27 @@ export const buildGatewayConnectionTest = async (}};}+ case PamAccountType.Redis: {+ const cd = connectionDetails as {+ sslEnabled?: boolean;+ sslRejectUnauthorized?: boolean;+ sslCertificate?: string;+ };+ const c = creds as { username?: string; password?: string } | null;+ if (!c) return tcp(host, port);+ return {+ host,+ port,+ request: {+ mode: TestConnectionMode.Redis,+ username: c.username,+ password: c.password,+ sslEnabled: cd.sslEnabled,+ sslRejectUnauthorized: cd.sslRejectUnauthorized,+ sslCertificate: cd.sslCertificate+ }+ };+ }case PamAccountType.Kubernetes: {const cd = connectionDetails as { sslRejectUnauthorized?: boolean; sslCertificate?: string };const c = creds as {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.tsindex e79d517bb1..4e4a5432b7 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@@ -115,6 +115,38 @@ describe("buildPamAccountTypeMetadata", () => {});});+ test("derives Redis connection and credential fields from the schema", () => {+ const redis = byType.get(PamAccountType.Redis);+ expect(redis).toBeDefined();+ expect(redis?.name).toBe("Redis");+ expect(redis?.supportsWebAccess).toBe(false);++ expect(redis?.connectionFields.map((f) => f.key)).toEqual([+ "host",+ "port",+ "sslEnabled",+ "sslRejectUnauthorized",+ "sslCertificate"+ ]);+ expect(fieldByKey(redis!.connectionFields, "port")).toMatchObject({+ widget: "number",+ required: true,+ defaultValue: 6379+ });++ expect(fieldByKey(redis!.credentialFields, "username")).toMatchObject({+ widget: "text",+ required: true,+ secret: false,+ defaultValue: "default"+ });+ expect(fieldByKey(redis!.credentialFields, "password")).toMatchObject({+ widget: "password",+ secret: true,+ required: false+ });+ });+test("derives Kubernetes connection and credential fields from the schema", () => {const k8s = byType.get(PamAccountType.Kubernetes);expect(k8s).toBeDefined();diff --git a/backend/src/ee/services/pam-account/pam-account-schemas.ts b/backend/src/ee/services/pam-account/pam-account-schemas.tsindex 382bed375a..6376140e1b 100644--- a/backend/src/ee/services/pam-account/pam-account-schemas.ts+++ b/backend/src/ee/services/pam-account/pam-account-schemas.ts@@ -311,6 +311,46 @@ export const ACCOUNT_TYPE_CONFIGS = {}},+ [PamAccountType.Redis]: {+ name: "Redis",+ icon: "Redis.png",+ connectionDetails: z.object({+ host: z.string().trim().min(1).max(255),+ port: z.coerce.number().int().min(1).max(65535),+ sslEnabled: z.boolean(),+ sslRejectUnauthorized: z.boolean(),+ sslCertificate: optionalTrimmedString+ }),+ credentials: z.object({+ username: z.string().trim().min(1).max(256),+ password: z+ .string()+ .trim()+ .max(256)+ .transform((v) => v || undefined)+ .optional()+ }),+ sanitizedCredentials: z.object({ username: z.string() }),+ ui: {+ port: { defaultValue: 6379 },+ username: {+ defaultValue: "default",+ tooltip: "The Redis ACL username. Use 'default' for the default user."+ },+ password: { widget: PamFieldWidget.Password, secret: true, optional: true },+ sslEnabled: { label: "SSL Enabled" },+ sslRejectUnauthorized: {+ label: "Reject Unauthorized",+ showWhen: { field: "sslEnabled", equals: true }+ },+ sslCertificate: {+ label: "SSL Certificate",+ widget: PamFieldWidget.Textarea,+ showWhen: { field: "sslEnabled", equals: true }+ }+ }+ },+[PamAccountType.SSH]: {name: "SSH",icon: "SSH.png",@@ -637,6 +677,7 @@ export const ACCOUNT_TYPE_CONFIGS = {label?: string;widget?: PamFieldWidget;secret?: boolean;+ optional?: boolean;defaultValue?: string | number | boolean;showWhen?: { field: string; equals: string | boolean };tooltip?: string;@@ -721,6 +762,7 @@ export const extractGatewayTarget = async (case PamAccountType.Postgres:case PamAccountType.MySQL:case PamAccountType.MsSQL:+ case PamAccountType.Redis:case PamAccountType.Windows:return {host: (validated as { host: string; port: number }).host,@@ -861,6 +903,10 @@ const accountTypeConnectionStringSchemes = (accountType: PamAccountType): stringreturn config?.connectionStringSchemes ? [...config.connectionStringSchemes] : undefined;};+// redis can be reached without credentials+export const accountTypeRequiresCredential = (accountType: PamAccountType): boolean =>+ accountType !== PamAccountType.Redis;+export const getAccountAccessibilityIssues = (account: {accountType: PamAccountType | string;gatewayId?: string | null;@@ -899,7 +945,9 @@ export const getAccountAccessibilityIssues = (account: {if (!hasRecordingConfig) issues.push(PamAccountAccessibilityIssue.NoRecordingConfig);}- if (!account.credentialConfigured) issues.push(PamAccountAccessibilityIssue.NoCredential);+ if (accountTypeRequiresCredential(account.accountType as PamAccountType) && !account.credentialConfigured) {+ issues.push(PamAccountAccessibilityIssue.NoCredential);+ }return issues;};@@ -921,6 +969,7 @@ export const PamFieldDescriptorSchema = z.object({widget: z.nativeEnum(PamFieldWidget),required: z.boolean(),secret: z.boolean(),+ optional: z.boolean().optional(),options: z.array(z.object({ label: z.string(), value: z.string() })).optional(),// Value the form prefills the field with on create@@ -955,6 +1004,7 @@ type TFieldUiHint = {label?: string;widget?: PamFieldWidget;secret?: boolean;+ optional?: boolean;defaultValue?: string | number | boolean;showWhen?: PamFieldDescriptor["showWhen"];tooltip?: string;@@ -1017,6 +1067,7 @@ const describeField = (widget,required,secret: hint.secret ?? widget === PamFieldWidget.Password,+ ...(hint.optional ? { optional: true } : {}),...(widget === PamFieldWidget.Select? { options: hint.options ?? (enumValues ? enumValues.map((v) => ({ label: humanizeKey(v), value: v })) : []) }: {}),diff --git a/docs/cli/commands/pam.mdx b/docs/cli/commands/pam.mdxindex 1b4861a5f6..60b9f33463 100644--- a/docs/cli/commands/pam.mdx+++ b/docs/cli/commands/pam.mdx@@ -108,6 +108,23 @@ Based on the account's template, the CLI starts the appropriate local proxy or c| MongoDB | `mongodb://127.0.0.1:<port>/<database>` |</Accordion>+ <Accordion title="Redis">+ Starts a local Redis proxy on `127.0.0.1`. Connect using any Redis client with no password, as authentication is handled by the proxy.++ ```bash+ # Example+ infisical pam access production/cache-primary --duration 2h+ ```++ Then connect with `redis-cli` or any Redis client:++ ```bash+ redis-cli -h 127.0.0.1 -p <port>+ ```++ Connection string format: `redis://127.0.0.1:<port>`+ </Accordion>+<Accordion title="SSH">Starts a local SSH proxy. Use standard SSH/SCP/SFTP/rsync commands to connect.diff --git a/docs/docs.json b/docs/docs.jsonindex 06e8f3892d..7d1096eb3b 100644--- a/docs/docs.json+++ b/docs/docs.json@@ -1123,6 +1123,7 @@"documentation/platform/pam/accounts/mysql","documentation/platform/pam/accounts/mssql","documentation/platform/pam/accounts/mongodb",+ "documentation/platform/pam/accounts/redis","documentation/platform/pam/accounts/ssh","documentation/platform/pam/accounts/kubernetes","documentation/platform/pam/accounts/aws-iam",diff --git a/docs/documentation/platform/pam/accounts/overview.mdx b/docs/documentation/platform/pam/accounts/overview.mdxindex 126c954b5a..47526d93d3 100644--- a/docs/documentation/platform/pam/accounts/overview.mdx+++ b/docs/documentation/platform/pam/accounts/overview.mdx@@ -18,6 +18,7 @@ PAM supports the following account types:| [**MySQL**](/documentation/platform/pam/accounts/mysql) | MySQL databases | ✓ || [**MS SQL**](/documentation/platform/pam/accounts/mssql) | Microsoft SQL Server | || [**MongoDB**](/documentation/platform/pam/accounts/mongodb) | MongoDB databases | |+| [**Redis**](/documentation/platform/pam/accounts/redis) | Redis databases | || [**SSH**](/documentation/platform/pam/accounts/ssh) | Linux/Unix servers | ✓ || [**Kubernetes**](/documentation/platform/pam/accounts/kubernetes) | Kubernetes clusters | || [**AWS IAM**](/documentation/platform/pam/accounts/aws-iam) | AWS IAM roles | ✓ |diff --git a/docs/documentation/platform/pam/accounts/redis.mdx b/docs/documentation/platform/pam/accounts/redis.mdxnew file mode 100644index 0000000000..15eb55b220--- /dev/null+++ b/docs/documentation/platform/pam/accounts/redis.mdx@@ -0,0 +1,67 @@+---+title: "Redis Accounts"+sidebarTitle: "Redis"+description: "Add and connect to Redis databases."+---++Redis accounts let you manage access to your Redis databases. Users connect through the CLI (a local proxy), and every [session](/documentation/platform/pam/sessions/overview) is recorded.++## Creating an Account++<Steps>+ <Step title="Start adding an account">+ Go to **Privileged Access Management → Accounts** and click **Add Account**.+ </Step>+ <Step title="Select a folder and template">+ Choose which [folder](/documentation/platform/pam/folders/overview) to add the account to, then select a Redis [template](/documentation/platform/pam/templates/overview).+ </Step>+ <Step title="Enter connection details">+ | Field | Description |+ |-------|-------------|+ | **Name** | A descriptive name (e.g., `cache-primary`) |+ | **Host** | Redis host |+ | **Port** | Redis port (default: 6379) |+ | **SSL Enabled** | Enable SSL/TLS for the connection |+ | **Reject Unauthorized** | Reject connections with invalid certificates (only if SSL enabled) |+ | **SSL Certificate** | Custom CA certificate (only if SSL enabled) |+ </Step>+ <Step title="Enter credentials">+ | Field | Description |+ |-------|-------------|+ | **Username** | Redis ACL username. Use `default` for the default user (also works with a legacy `requirepass` password on Redis 6+) |+ | **Password** | Redis password. Optional, leave blank for an unauthenticated Redis server |+ </Step>+ <Step title="Save">+ Click **Create**.+ </Step>+</Steps>++## Connecting++The CLI starts a local proxy that you connect to with your preferred Redis client.++```bash+infisical pam access my-folder/cache-primary+```++The command outputs the local port to connect to. Then use `redis-cli` or any Redis client:+```bash+redis-cli -h 127.0.0.1 -p <port>+```++No password needed since the proxy handles authentication.++**Flags:**+- `--port <port>` — use a specific local port (otherwise one is assigned automatically)+- `--reason <reason>` — provide an access reason (if required by template)++## Next Steps++<CardGroup cols={2}>+ <Card title="MongoDB Accounts" icon="database" href="/documentation/platform/pam/accounts/mongodb">+ Add MongoDB database accounts.+ </Card>+ <Card title="Sessions" icon="display" href="/documentation/platform/pam/sessions/overview">+ View and manage sessions.+ </Card>+</CardGroup>diff --git a/frontend/src/hooks/api/pam/types/index.ts b/frontend/src/hooks/api/pam/types/index.tsindex a7989942f6..6ca2dec2b4 100644--- a/frontend/src/hooks/api/pam/types/index.ts+++ b/frontend/src/hooks/api/pam/types/index.ts@@ -149,6 +149,7 @@ export type TPamFieldDescriptor = {widget: PamFieldWidget;required: boolean;secret: boolean;+ optional?: boolean;options?: { label: string; value: string }[];defaultValue?: string | number | boolean;showWhen?: { field: string; equals: string | boolean };diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamSchemaFields.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamSchemaFields.tsxindex d407235a98..8a14e3e592 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/PamSchemaFields.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamSchemaFields.tsx@@ -157,7 +157,9 @@ export const PamSchemaFields = ({ control, namePrefix, fields, smartPaste }: Pro<Field orientation="horizontal"><FieldLabel>{descriptor.label}- {(descriptor.required || descriptor.secret) && <RequiredMark />}+ {(descriptor.required || (descriptor.secret && !descriptor.optional)) && (+ <RequiredMark />+ )}<FieldTooltip text={descriptor.tooltip} /></FieldLabel><Switch@@ -170,7 +172,9 @@ export const PamSchemaFields = ({ control, namePrefix, fields, smartPaste }: Pro<Field><FieldLabel>{descriptor.label}- {(descriptor.required || descriptor.secret) && <RequiredMark />}+ {(descriptor.required || (descriptor.secret && !descriptor.optional)) && (+ <RequiredMark />+ )}<FieldTooltip text={descriptor.tooltip} /></FieldLabel><FieldContent>diff --git a/frontend/src/pages/pam/PamAccountsPage/components/accountFormSchema.ts b/frontend/src/pages/pam/PamAccountsPage/components/accountFormSchema.tsindex d93cd697c8..836879b5b5 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/accountFormSchema.ts+++ b/frontend/src/pages/pam/PamAccountsPage/components/accountFormSchema.ts@@ -50,7 +50,7 @@ export const getMissingRequiredFields = (fields.filter((field) => {if (field.widget === PamFieldWidget.Boolean || !isFieldVisible(field, values)) return false;- if (!field.required && !field.secret) return false;+ if (!field.required && !(field.secret && !field.optional)) return false;const value = values[field.key];return value === undefined || value === null || String(value).trim() === "";})