Skip to content

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

address reviews

Andreybc5987f9ce4d
diff --git a/backend/src/ee/services/pam-session-recording/aws-s3/aws-s3-provider-factory.ts b/backend/src/ee/services/pam-session-recording/aws-s3/aws-s3-provider-factory.ts
index 509b17a002..3ea6ced0e0 100644
--- a/backend/src/ee/services/pam-session-recording/aws-s3/aws-s3-provider-factory.ts
+++ b/backend/src/ee/services/pam-session-recording/aws-s3/aws-s3-provider-factory.ts
@@ -1,6 +1,5 @@
import {
DeleteObjectCommand,
- DeleteObjectsCommand,
GetObjectCommand,
HeadBucketCommand,
ListObjectsV2Command,
@@ -12,6 +11,7 @@ import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
import { createS3Client } from "@app/lib/aws/s3";
import { crypto } from "@app/lib/crypto/cryptography";
import { BadRequestError } from "@app/lib/errors";
+import { chunkArray } from "@app/lib/fn";
import { logger } from "@app/lib/logger";
import { AppConnection, AWSRegion } from "@app/services/app-connection/app-connection-enums";
import { TAppConnection } from "@app/services/app-connection/app-connection-types";
@@ -163,14 +163,10 @@ export const AwsS3RecordingStorageProvider: TPamRecordingStorageProvider = () =>
})
);
const keys = (listed.Contents ?? []).map((o) => o.Key).filter((k): k is string => Boolean(k));
- if (keys.length > 0) {
+ // single-object deletes, since OCI rejects the CRC32 checksum the SDK sends with DeleteObjects
+ for (const batch of chunkArray(keys, 50)) {
// eslint-disable-next-line no-await-in-loop
- await client.send(
- new DeleteObjectsCommand({
- Bucket: config.bucket,
- Delete: { Objects: keys.map((Key) => ({ Key })), Quiet: true }
- })
- );
+ await Promise.all(batch.map((Key) => client.send(new DeleteObjectCommand({ Bucket: config.bucket, Key }))));
}
continuationToken = listed.IsTruncated ? listed.NextContinuationToken : undefined;
} while (continuationToken);
diff --git a/docs/documentation/platform/pam/sessions/external-storage.mdx b/docs/documentation/platform/pam/sessions/external-storage.mdx
index 4c6ba48945..082de66583 100644
--- a/docs/documentation/platform/pam/sessions/external-storage.mdx
+++ b/docs/documentation/platform/pam/sessions/external-storage.mdx
@@ -1,20 +1,29 @@
---
title: "External storage"
sidebarTitle: "External storage"
-description: "Store session recordings in your own S3 bucket."
+description: "Store session recordings in your own S3-compatible bucket."
---
-By default, [session recordings](/documentation/platform/pam/sessions/session-recording) are stored in Infisical's managed database. If you need control over where recordings live — for data residency, retention policies, or compliance requirements — you can store them in your own S3 bucket instead.
+By default, [session recordings](/documentation/platform/pam/sessions/session-recording) are stored in Infisical's managed database. If you need control over where recordings live — for data residency, retention policies, or compliance requirements — you can store them in your own S3-compatible bucket instead.
+
+## Supported providers
+
+| Provider | Endpoint | Access key |
+|----------|----------|------------|
+| AWS S3 | `https://s3.<region>.amazonaws.com` | An IAM user with the [required permissions](#required-permissions) |
+| Cloudflare R2 | `https://<account-id>.r2.cloudflarestorage.com` | An R2 API token with **Object Read & Write** on the bucket |
+| Google Cloud Storage | `https://storage.googleapis.com` | An HMAC key for a service account with **Storage Object User** on the bucket |
+| OCI Object Storage | `https://<namespace>.compat.objectstorage.<region>.oraclecloud.com` | A customer secret key for a user who can `inspect buckets` and `manage objects` |
## Prerequisites
-Before configuring external storage, you need an **AWS Connection** set up in your organization. This provides the credentials Infisical uses to write to your bucket.
+Before configuring external storage, you need an [AWS Connection](/integrations/app-connections/aws) or an S3-Compatible Storage connection in your organization. This provides the credentials Infisical uses to write to your bucket.
-If you don't have one, see the [AWS Connection guide](/integrations/app-connections/aws).
+To create an S3-Compatible Storage connection, go to **Integrations** > **App Connections**, select **Add Connection**, and select **S3-Compatible Storage**. Use the endpoint and access key for your provider from [Supported providers](#supported-providers).
### Required permissions
-The connection's IAM role needs these permissions on the bucket:
+For AWS S3, the connection's IAM role or user needs these permissions on the bucket:
```json
{
@@ -42,18 +51,18 @@ External storage is set at the [template](/documentation/platform/pam/templates/
<Step title="Open the template">
Go to **Account Templates** and select the template you want to configure.
</Step>
- <Step title="Find Recording Storage">
- In **System Settings**, find the **Recording Storage** section.
+ <Step title="Find Session Recording">
+ On the **General** tab, find the **Session Recording** section.
</Step>
- <Step title="Select External S3">
- Change from **Internal** to **External S3**.
+ <Step title="Select S3 Bucket">
+ Set **Storage backend** to **S3 Bucket**.
</Step>
<Step title="Configure the bucket">
| Field | Description |
|-------|-------------|
- | **AWS Connection** | Select your AWS connection |
+ | **Connection** | Select your AWS or S3-Compatible Storage connection |
| **Bucket Name** | Your S3 bucket |
- | **Region** | AWS region |
+ | **Region** | AWS region (only for an AWS connection) |
| **Key Prefix** | Optional prefix for object keys (e.g., `pam/prod/`) |
</Step>
<Step title="Save">
@@ -78,11 +87,13 @@ For session playback to work in the browser, your bucket needs a CORS policy:
Replace `https://app.infisical.com` with your Infisical URL if you have a custom domain.
-To configure:
+To configure it on AWS S3:
1. Open the bucket in AWS Console
2. Go to **Permissions → Cross-origin resource sharing (CORS)**
3. Add the configuration above
+Cloudflare R2 takes the same configuration under the bucket's **Settings** > **CORS Policy**. For Google Cloud Storage, [configure CORS](https://cloud.google.com/storage/docs/using-cors) with the same origin and the `GET` method. OCI Object Storage allows requests from any origin, so it needs no CORS configuration.
+
If CORS isn't set up correctly, session playback will fail with a network error.
## How recordings are stored
@@ -99,7 +110,7 @@ Infisical encrypts recordings before upload, so the data in your bucket is encry
## Managing retention
-Since recordings are in your bucket, you control retention. Configure S3 lifecycle rules to automatically delete or transition objects after a certain period.
+Since recordings are in your bucket, you control retention. Configure lifecycle rules on the bucket to automatically delete or transition objects after a certain period.
<Tip>
This gives you full control over how long recordings are kept — essential for compliance requirements.
diff --git a/frontend/src/helpers/appConnections.ts b/frontend/src/helpers/appConnections.ts
index 1f36bc3b27..909d0e502a 100644
--- a/frontend/src/helpers/appConnections.ts
+++ b/frontend/src/helpers/appConnections.ts
@@ -656,6 +656,43 @@ export const APP_CONNECTION_MAP: Record<
}
};
+const S3_COMPATIBLE_PROVIDERS = [
+ { name: "AWS S3", hostname: /^s3\.[a-z0-9-]+\.amazonaws\.com$/ },
+ { name: "Cloudflare R2", hostname: /^[a-f0-9]{32}(\.[a-z]+)?\.r2\.cloudflarestorage\.com$/ },
+ { name: "Google Cloud Storage", hostname: /^storage\.googleapis\.com$/ },
+ {
+ name: "OCI Object Storage",
+ hostname:
+ /^[a-z0-9-]+\.compat\.objectstorage\.[a-z0-9-]+\.(oraclecloud\.com|oci\.customer-oci\.com)$/
+ }
+];
+
+export const getS3CompatibleProviderName = (endpoint: string) => {
+ try {
+ const url = new URL(endpoint);
+ if (
+ url.protocol !== "https:" ||
+ url.port ||
+ url.username ||
+ url.pathname !== "/" ||
+ url.search ||
+ url.hash
+ ) {
+ return null;
+ }
+ return (
+ S3_COMPATIBLE_PROVIDERS.find(({ hostname }) => hostname.test(url.hostname))?.name ?? null
+ );
+ } catch {
+ return null;
+ }
+};
+
+export const getAppConnectionProviderName = (connection: TAppConnection) =>
+ (connection.app === AppConnection.S3Compatible &&
+ getS3CompatibleProviderName(connection.credentials.endpoint)) ||
+ APP_CONNECTION_MAP[connection.app].name;
+
export const POPULAR_APP_CONNECTIONS: AppConnection[] = [
AppConnection.AWS,
AppConnection.GitHub,
diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/S3CompatibleConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/S3CompatibleConnectionForm.tsx
index 928a6a69d8..956d4de331 100644
--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/S3CompatibleConnectionForm.tsx
+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/S3CompatibleConnectionForm.tsx
@@ -5,6 +5,7 @@ import { z } from "zod";
import {
Field,
+ FieldDescription,
FieldError,
FieldLabel,
Input,
@@ -18,7 +19,11 @@ import {
TooltipContent,
TooltipTrigger
} from "@app/components/v3";
-import { APP_CONNECTION_MAP, getAppConnectionMethodDetails } from "@app/helpers/appConnections";
+import {
+ APP_CONNECTION_MAP,
+ getAppConnectionMethodDetails,
+ getS3CompatibleProviderName
+} from "@app/helpers/appConnections";
import { TS3CompatibleConnection } from "@app/hooks/api/appConnections";
import { AppConnection } from "@app/hooks/api/appConnections/enums";
import { S3CompatibleConnectionMethod } from "@app/hooks/api/appConnections/types/s3-compatible-connection";
@@ -29,13 +34,6 @@ import {
GenericAppConnectionsFields
} from "./GenericAppConnectionFields";
-const S3_COMPATIBLE_ENDPOINT_EXAMPLES = [
- "https://s3.<region>.amazonaws.com",
- "https://<account-id>.r2.cloudflarestorage.com",
- "https://storage.googleapis.com",
- "https://<namespace>.compat.objectstorage.<region>.oraclecloud.com"
-];
-
type Props = {
appConnection?: TS3CompatibleConnection;
onSubmit: (formData: FormData) => Promise<void>;
@@ -53,8 +51,10 @@ const formSchema = z.discriminatedUnion("method", [
.string()
.trim()
.min(1, "Endpoint required")
- .url("Must be a valid URL")
- .startsWith("https://", "Endpoint must use HTTPS"),
+ .refine(
+ (endpoint) => Boolean(getS3CompatibleProviderName(endpoint)),
+ "Enter the S3 API endpoint of a supported provider, without the bucket name"
+ ),
accessKeyId: z.string().trim().min(1, "Access Key ID required"),
secretAccessKey: z.string().trim().min(1, "Secret Access Key required")
})
@@ -127,22 +127,7 @@ export const S3CompatibleConnectionForm = ({ appConnection, onSubmit }: Props) =
shouldUnregister
render={({ field: { value, onChange }, fieldState: { error } }) => (
<Field className="mb-4">
- <FieldLabel htmlFor="endpoint">
- Endpoint
- <Tooltip>
- <TooltipTrigger asChild>
- <Info />
- </TooltipTrigger>
- <TooltipContent className="max-w-sm">
- <p>The S3 API endpoint of your provider, without the bucket name:</p>
- <ul className="mt-1 list-disc pl-4 font-mono text-xs">
- {S3_COMPATIBLE_ENDPOINT_EXAMPLES.map((example) => (
- <li key={example}>{example}</li>
- ))}
- </ul>
- </TooltipContent>
- </Tooltip>
- </FieldLabel>
+ <FieldLabel htmlFor="endpoint">Endpoint</FieldLabel>
<Input
id="endpoint"
value={value}
@@ -150,6 +135,10 @@ export const S3CompatibleConnectionForm = ({ appConnection, onSubmit }: Props) =
placeholder="https://s3.us-east-1.amazonaws.com"
isError={Boolean(error?.message)}
/>
+ <FieldDescription>
+ The S3 API endpoint, without the bucket name. Supports AWS S3, Cloudflare R2, Google
+ Cloud Storage and OCI Object Storage.
+ </FieldDescription>
<FieldError errors={[error]} />
</Field>
)}
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/RecordingConnectionPicker.tsx b/frontend/src/pages/pam/PamAccountsPage/components/RecordingConnectionPicker.tsx
index c32c7beb51..27f8ca9d3b 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/RecordingConnectionPicker.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/RecordingConnectionPicker.tsx
@@ -1,4 +1,5 @@
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@app/components/v3";
+import { getAppConnectionProviderName } from "@app/helpers/appConnections";
import { useListAppConnections } from "@app/hooks/api/appConnections/queries";
import { PAM_RECORDING_CONNECTION_APPS } from "@app/hooks/api/pam/constants";
@@ -36,7 +37,8 @@ export const RecordingConnectionPicker = ({ value, onChange, isError, includeNon
)}
{recordingConnections.map((connection) => (
<SelectItem key={connection.id} value={connection.id}>
- {connection.name}
+ {connection.name}{" "}
+ <span className="text-muted">({getAppConnectionProviderName(connection)})</span>
</SelectItem>
))}
</SelectContent>
diff --git a/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsx b/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsx
index b70e578a13..5955e981c0 100644
--- a/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsx
+++ b/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsx
@@ -34,8 +34,10 @@ import {
} from "@app/components/v3";
import { Skeleton } from "@app/components/v3/generic/Skeleton";
import { useProject } from "@app/context";
+import { APP_CONNECTION_MAP, getAppConnectionProviderName } from "@app/helpers/appConnections";
import {
AppConnection,
+ useListAppConnections,
useListAvailableAppConnectionsForApps
} from "@app/hooks/api/appConnections";
import {
@@ -283,6 +285,7 @@ const SettingsTab = ({
PAM_RECORDING_CONNECTION_APPS,
currentProject.id
);
+ const { data: appConnections = [] } = useListAppConnections();
const { map: accountTypeMap } = usePamAccountTypeMap();
const maxPwLength = maxGeneratedPasswordLength(template?.type);
@@ -904,11 +907,23 @@ const SettingsTab = ({
<SelectValue placeholder="Select a connection" />
</SelectTrigger>
<SelectContent position="popper">
- {recordingConnections.map((conn) => (
- <SelectItem key={conn.id} value={conn.id}>
- {conn.name}
- </SelectItem>
- ))}
+ {recordingConnections.length === 0 && (
+ <div className="px-2 py-3 text-center text-xs text-muted">
+ No AWS or S3-Compatible Storage connections found. Create one from
+ the App Connections page.
+ </div>
+ )}
+ {recordingConnections.map((conn) => {
+ const connection = appConnections.find(({ id }) => id === conn.id);
+ const providerName = connection
+ ? getAppConnectionProviderName(connection)
+ : APP_CONNECTION_MAP[conn.app].name;
+ return (
+ <SelectItem key={conn.id} value={conn.id}>
+ {conn.name} <span className="text-muted">({providerName})</span>
+ </SelectItem>
+ );
+ })}
</SelectContent>
</Select>
{fieldState.error ? (