Skip to content

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

remove api token from r2 keys

adilson110aa89a072f
diff --git a/backend/src/ee/routes/v2/secret-rotation-v2-routers/cloudflare-r2-access-key-rotation-router.ts b/backend/src/ee/routes/v2/secret-rotation-v2-routers/cloudflare-r2-access-key-rotation-router.ts
index ef8208f93c..ab2a8d804e 100644
--- a/backend/src/ee/routes/v2/secret-rotation-v2-routers/cloudflare-r2-access-key-rotation-router.ts
+++ b/backend/src/ee/routes/v2/secret-rotation-v2-routers/cloudflare-r2-access-key-rotation-router.ts
@@ -1,5 +1,5 @@
import {
- CloudflareR2AccessKeyRotationGeneratedCredentialsSchema,
+ CloudflareR2AccessKeyRotationGeneratedCredentialsResponseSchema,
CloudflareR2AccessKeyRotationSchema,
CreateCloudflareR2AccessKeyRotationSchema,
UpdateCloudflareR2AccessKeyRotationSchema
@@ -15,5 +15,5 @@ export const registerCloudflareR2AccessKeyRotationRouter = async (server: Fastif
responseSchema: CloudflareR2AccessKeyRotationSchema,
createSchema: CreateCloudflareR2AccessKeyRotationSchema,
updateSchema: UpdateCloudflareR2AccessKeyRotationSchema,
- generatedCredentialsSchema: CloudflareR2AccessKeyRotationGeneratedCredentialsSchema
+ generatedCredentialsSchema: CloudflareR2AccessKeyRotationGeneratedCredentialsResponseSchema
});
diff --git a/backend/src/ee/services/secret-rotation-v2/cloudflare-r2-access-key/cloudflare-r2-access-key-rotation-constants.ts b/backend/src/ee/services/secret-rotation-v2/cloudflare-r2-access-key/cloudflare-r2-access-key-rotation-constants.ts
index 97cde7f8b9..70e9d87d17 100644
--- a/backend/src/ee/services/secret-rotation-v2/cloudflare-r2-access-key/cloudflare-r2-access-key-rotation-constants.ts
+++ b/backend/src/ee/services/secret-rotation-v2/cloudflare-r2-access-key/cloudflare-r2-access-key-rotation-constants.ts
@@ -13,7 +13,6 @@ export const CLOUDFLARE_R2_ACCESS_KEY_ROTATION_LIST_OPTION: TSecretRotationV2Lis
accessLevel: CloudflareR2AccessLevel.ObjectRead
},
secretsMapping: {
- apiToken: "CLOUDFLARE_R2_API_TOKEN",
accessKeyId: "CLOUDFLARE_R2_ACCESS_KEY_ID",
secretAccessKey: "CLOUDFLARE_R2_SECRET_ACCESS_KEY"
}
diff --git a/backend/src/ee/services/secret-rotation-v2/cloudflare-r2-access-key/cloudflare-r2-access-key-rotation-fns.ts b/backend/src/ee/services/secret-rotation-v2/cloudflare-r2-access-key/cloudflare-r2-access-key-rotation-fns.ts
index 7dbcdecae8..03472cb927 100644
--- a/backend/src/ee/services/secret-rotation-v2/cloudflare-r2-access-key/cloudflare-r2-access-key-rotation-fns.ts
+++ b/backend/src/ee/services/secret-rotation-v2/cloudflare-r2-access-key/cloudflare-r2-access-key-rotation-fns.ts
@@ -172,7 +172,6 @@ export const cloudflareR2AccessKeyRotationFactory: TRotationFactory<
const getSecretsPayload: TRotationFactoryGetSecretsPayload<TCloudflareR2AccessKeyRotationGeneratedCredentials> = (
generatedCredentials
) => [
- { key: secretsMapping.apiToken, value: generatedCredentials.apiToken },
{ key: secretsMapping.accessKeyId, value: generatedCredentials.accessKeyId },
{ key: secretsMapping.secretAccessKey, value: generatedCredentials.secretAccessKey }
];
diff --git a/backend/src/ee/services/secret-rotation-v2/cloudflare-r2-access-key/cloudflare-r2-access-key-rotation-schemas.ts b/backend/src/ee/services/secret-rotation-v2/cloudflare-r2-access-key/cloudflare-r2-access-key-rotation-schemas.ts
index 197ef09092..e28050fd5c 100644
--- a/backend/src/ee/services/secret-rotation-v2/cloudflare-r2-access-key/cloudflare-r2-access-key-rotation-schemas.ts
+++ b/backend/src/ee/services/secret-rotation-v2/cloudflare-r2-access-key/cloudflare-r2-access-key-rotation-schemas.ts
@@ -40,19 +40,27 @@ export const CloudflareR2BucketSchema = z.object({
jurisdiction: z.nativeEnum(CloudflareR2Jurisdiction).default(CloudflareR2Jurisdiction.Default)
});
-export const CloudflareR2AccessKeyRotationGeneratedCredentialsSchema = z
- .object({
- // the underlying Cloudflare API token value, and the input to the secret access key hash
- apiToken: z.string(),
- // the API token's id — what R2's S3 API expects as the access key id, and what we delete on revoke
- accessKeyId: z.string(),
- // sha256 hex of `apiToken`
- secretAccessKey: z.string()
- })
- .array()
+const CloudflareR2AccessKeyCredentialsSchema = z.object({
+ /**
+ * The underlying Cloudflare API token value. Retained only so the credential check can introspect
+ * the token and to derive the secret access key — it is never mapped to a secret or returned to
+ * callers, since R2's S3 API only needs the access key pair.
+ */
+ apiToken: z.string(),
+ // the API token's id — what R2's S3 API expects as the access key id, and what we delete on revoke
+ accessKeyId: z.string(),
+ // sha256 hex of `apiToken`
+ secretAccessKey: z.string()
+});
+
+export const CloudflareR2AccessKeyRotationGeneratedCredentialsSchema = CloudflareR2AccessKeyCredentialsSchema.array()
.min(1)
.max(2);
+/** Keeps `apiToken` inside the encryption boundary — zod strips it when serializing the response. */
+export const CloudflareR2AccessKeyRotationGeneratedCredentialsResponseSchema =
+ CloudflareR2AccessKeyCredentialsSchema.omit({ apiToken: true }).array().min(1).max(2);
+
const CloudflareR2AccessKeyRotationParametersSchema = z.object({
name: CloudflareTokenNameSchema.describe(SecretRotations.PARAMETERS.CLOUDFLARE_R2_ACCESS_KEY.name),
buckets: CloudflareR2BucketSchema.array()
@@ -75,7 +83,6 @@ const CloudflareR2AccessKeyRotationParametersSchema = z.object({
});
const CloudflareR2AccessKeyRotationSecretsMappingSchema = z.object({
- apiToken: SecretNameSchema.describe(SecretRotations.SECRETS_MAPPING.CLOUDFLARE_R2_ACCESS_KEY.apiToken),
accessKeyId: SecretNameSchema.describe(SecretRotations.SECRETS_MAPPING.CLOUDFLARE_R2_ACCESS_KEY.accessKeyId),
secretAccessKey: SecretNameSchema.describe(SecretRotations.SECRETS_MAPPING.CLOUDFLARE_R2_ACCESS_KEY.secretAccessKey)
});
@@ -86,7 +93,6 @@ export const CloudflareR2AccessKeyRotationTemplateSchema = z.object({
accessLevel: z.nativeEnum(CloudflareR2AccessLevel)
}),
secretsMapping: z.object({
- apiToken: z.string(),
accessKeyId: z.string(),
secretAccessKey: z.string()
})
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.ts
index 576aff6275..20c9d2845c 100644
--- a/backend/src/lib/api-docs/constants.ts
+++ b/backend/src/lib/api-docs/constants.ts
@@ -3687,7 +3687,6 @@ export const SecretRotations = {
apiToken: "The name of the secret that the rotated Cloudflare API token value will be mapped to."
},
CLOUDFLARE_R2_ACCESS_KEY: {
- apiToken: "The name of the secret that the rotated Cloudflare API token value will be mapped to.",
accessKeyId: "The name of the secret that the rotated R2 access key ID will be mapped to.",
secretAccessKey: "The name of the secret that the rotated R2 secret access key will be mapped to."
},
diff --git a/docs/api-reference/endpoints/secret-rotations/cloudflare-r2-access-key/create.mdx b/docs/api-reference/endpoints/secret-rotations/cloudflare-r2-access-key/create.mdx
index 7a8c563e4d..44058420de 100644
--- a/docs/api-reference/endpoints/secret-rotations/cloudflare-r2-access-key/create.mdx
+++ b/docs/api-reference/endpoints/secret-rotations/cloudflare-r2-access-key/create.mdx
@@ -30,7 +30,6 @@ Creates a Cloudflare R2 Access Key secret rotation. Infisical will create and ro
| `parameters.disallowedIps` | string[] | No | The IP addresses or CIDR blocks the generated access key is denied from. |
| `secretsMapping.accessKeyId` | string | Yes | Secret key name to store the generated access key ID (e.g. `CLOUDFLARE_R2_ACCESS_KEY_ID`). |
| `secretsMapping.secretAccessKey` | string | Yes | Secret key name to store the generated secret access key (e.g. `CLOUDFLARE_R2_SECRET_ACCESS_KEY`). |
-| `secretsMapping.apiToken` | string | Yes | Secret key name to store the underlying Cloudflare API token value (e.g. `CLOUDFLARE_R2_API_TOKEN`). |
| `description` | string | No | Optional description. |
## Sample request
@@ -61,8 +60,7 @@ curl --request POST \
},
"secretsMapping": {
"accessKeyId": "CLOUDFLARE_R2_ACCESS_KEY_ID",
- "secretAccessKey": "CLOUDFLARE_R2_SECRET_ACCESS_KEY",
- "apiToken": "CLOUDFLARE_R2_API_TOKEN"
+ "secretAccessKey": "CLOUDFLARE_R2_SECRET_ACCESS_KEY"
}
}'
```
@@ -77,8 +75,7 @@ curl --request POST \
"description": "Cloudflare R2 access key rotation",
"secretsMapping": {
"accessKeyId": "CLOUDFLARE_R2_ACCESS_KEY_ID",
- "secretAccessKey": "CLOUDFLARE_R2_SECRET_ACCESS_KEY",
- "apiToken": "CLOUDFLARE_R2_API_TOKEN"
+ "secretAccessKey": "CLOUDFLARE_R2_SECRET_ACCESS_KEY"
},
"isAutoRotationEnabled": true,
"activeIndex": 0,
diff --git a/docs/documentation/platform/secret-rotation/cloudflare-r2-access-key.mdx b/docs/documentation/platform/secret-rotation/cloudflare-r2-access-key.mdx
index 5470896d45..cae4f00149 100644
--- a/docs/documentation/platform/secret-rotation/cloudflare-r2-access-key.mdx
+++ b/docs/documentation/platform/secret-rotation/cloudflare-r2-access-key.mdx
@@ -9,7 +9,7 @@ description: "Learn how to automatically rotate Cloudflare R2 access keys."
This rotation maintains two active credential sets with overlapping validity, ensuring zero-downtime during rotation cycles.
</Note>
-An R2 access key is a Cloudflare API token viewed through R2's S3-compatible API: the **Access Key ID** is the token's ID, and the **Secret Access Key** is the SHA-256 hash of the token's value. This rotation creates that token scoped to the buckets you select, then hands you all three values as secrets.
+An R2 access key is a Cloudflare API token viewed through R2's S3-compatible API: the **Access Key ID** is the token's ID, and the **Secret Access Key** is the SHA-256 hash of the token's value. This rotation creates that token scoped to the buckets you select, then hands you both values as secrets.
## Prerequisites
@@ -60,7 +60,6 @@ An R2 access key is a Cloudflare API token viewed through R2's S3-compatible API
- **Access Key ID** - The name of the secret in Infisical where the generated access key ID will be stored.
- **Secret Access Key** - The name of the secret in Infisical where the generated secret access key will be stored.
- - **API Token** - The name of the secret in Infisical where the underlying Cloudflare API token value will be stored. Use this one when calling the Cloudflare REST API rather than R2's S3 API.
![Rotation Secrets Mapping](/images/secret-rotations-v2/cloudflare-r2-access-key/secrets-mapping.png)
@@ -115,8 +114,7 @@ An R2 access key is a Cloudflare API token viewed through R2's S3-compatible API
},
"secretsMapping": {
"accessKeyId": "CLOUDFLARE_R2_ACCESS_KEY_ID",
- "secretAccessKey": "CLOUDFLARE_R2_SECRET_ACCESS_KEY",
- "apiToken": "CLOUDFLARE_R2_API_TOKEN"
+ "secretAccessKey": "CLOUDFLARE_R2_SECRET_ACCESS_KEY"
}
}'
```
@@ -131,8 +129,7 @@ An R2 access key is a Cloudflare API token viewed through R2's S3-compatible API
"description": "Cloudflare R2 access key rotation",
"secretsMapping": {
"accessKeyId": "CLOUDFLARE_R2_ACCESS_KEY_ID",
- "secretAccessKey": "CLOUDFLARE_R2_SECRET_ACCESS_KEY",
- "apiToken": "CLOUDFLARE_R2_API_TOKEN"
+ "secretAccessKey": "CLOUDFLARE_R2_SECRET_ACCESS_KEY"
},
"isAutoRotationEnabled": true,
"activeIndex": 0,
diff --git a/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewCloudflareR2AccessKeyRotationGeneratedCredentials.tsx b/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewCloudflareR2AccessKeyRotationGeneratedCredentials.tsx
index e30dbb3124..cd5c811782 100644
--- a/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewCloudflareR2AccessKeyRotationGeneratedCredentials.tsx
+++ b/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewCloudflareR2AccessKeyRotationGeneratedCredentials.tsx
@@ -25,9 +25,6 @@ export const ViewCloudflareR2AccessKeyRotationGeneratedCredentials = ({
<CredentialDisplay isSensitive label="Secret Access Key">
{activeCredentials?.secretAccessKey}
</CredentialDisplay>
- <CredentialDisplay isSensitive label="API Token">
- {activeCredentials?.apiToken}
- </CredentialDisplay>
</>
}
inactiveCredentials={
@@ -38,9 +35,6 @@ export const ViewCloudflareR2AccessKeyRotationGeneratedCredentials = ({
<CredentialDisplay isSensitive label="Secret Access Key">
{inactiveCredentials?.secretAccessKey}
</CredentialDisplay>
- <CredentialDisplay isSensitive label="API Token">
- {inactiveCredentials?.apiToken}
- </CredentialDisplay>
</>
}
/>
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/CloudflareR2AccessKeyRotationReviewFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/CloudflareR2AccessKeyRotationReviewFields.tsx
index f86c6fe6dd..0f2e677ab5 100644
--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/CloudflareR2AccessKeyRotationReviewFields.tsx
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/CloudflareR2AccessKeyRotationReviewFields.tsx
@@ -19,7 +19,7 @@ export const CloudflareR2AccessKeyRotationReviewFields = () => {
}
>();
- const [parameters, { apiToken, accessKeyId, secretAccessKey }] = watch([
+ const [parameters, { accessKeyId, secretAccessKey }] = watch([
"parameters",
"secretsMapping"
]);
@@ -54,7 +54,6 @@ export const CloudflareR2AccessKeyRotationReviewFields = () => {
<SecretRotationReviewSection label="Secrets Mapping">
<GenericFieldLabel label="Access Key ID">{accessKeyId}</GenericFieldLabel>
<GenericFieldLabel label="Secret Access Key">{secretAccessKey}</GenericFieldLabel>
- <GenericFieldLabel label="API Token">{apiToken}</GenericFieldLabel>
</SecretRotationReviewSection>
</>
);
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/CloudflareR2AccessKeyRotationSecretsMappingFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/CloudflareR2AccessKeyRotationSecretsMappingFields.tsx
index ee6f363e5a..0481c33f07 100644
--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/CloudflareR2AccessKeyRotationSecretsMappingFields.tsx
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/CloudflareR2AccessKeyRotationSecretsMappingFields.tsx
@@ -51,24 +51,6 @@ export const CloudflareR2AccessKeyRotationSecretsMappingFields = () => {
name="secretsMapping.secretAccessKey"
/>
)
- },
- {
- name: "API Token",
- input: (
- <Controller
- render={({ field: { value, onChange }, fieldState: { error } }) => (
- <FormControl isError={Boolean(error)} errorText={error?.message}>
- <Input
- value={value}
- onChange={onChange}
- placeholder={rotationOption?.template.secretsMapping.apiToken}
- />
- </FormControl>
- )}
- control={control}
- name="secretsMapping.apiToken"
- />
- )
}
];
diff --git a/frontend/src/components/secret-rotations-v2/forms/schemas/cloudflare-r2-access-key-rotation-schema.ts b/frontend/src/components/secret-rotations-v2/forms/schemas/cloudflare-r2-access-key-rotation-schema.ts
index b6656a6a59..4867e63067 100644
--- a/frontend/src/components/secret-rotations-v2/forms/schemas/cloudflare-r2-access-key-rotation-schema.ts
+++ b/frontend/src/components/secret-rotations-v2/forms/schemas/cloudflare-r2-access-key-rotation-schema.ts
@@ -59,7 +59,6 @@ export const CloudflareR2AccessKeyRotationSchema = z
disallowedIps: CloudflareTokenIpRestrictionsSchema
}),
secretsMapping: z.object({
- apiToken: z.string().trim().min(1, "API Token secret name required"),
accessKeyId: z.string().trim().min(1, "Access Key ID secret name required"),
secretAccessKey: z.string().trim().min(1, "Secret Access Key secret name required")
})
diff --git a/frontend/src/hooks/api/secretRotationsV2/types/cloudflare-r2-access-key-rotation.ts b/frontend/src/hooks/api/secretRotationsV2/types/cloudflare-r2-access-key-rotation.ts
index 5980739a9a..68d5e7b2cf 100644
--- a/frontend/src/hooks/api/secretRotationsV2/types/cloudflare-r2-access-key-rotation.ts
+++ b/frontend/src/hooks/api/secretRotationsV2/types/cloudflare-r2-access-key-rotation.ts
@@ -19,14 +19,12 @@ export type TCloudflareR2AccessKeyRotation = TSecretRotationV2Base & {
disallowedIps?: string[];
};
secretsMapping: {
- apiToken: string;
accessKeyId: string;
secretAccessKey: string;
};
};
export type TCloudflareR2AccessKeyRotationGeneratedCredentials = {
- apiToken: string;
accessKeyId: string;
secretAccessKey: string;
};