Skip to content

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

UI: add rotation for cloudflare on the UI

adilson81e89edd90ce
diff --git a/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewCloudflareApiTokenRotationGeneratedCredentials.tsx b/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewCloudflareApiTokenRotationGeneratedCredentials.tsx
new file mode 100644
index 0000000000..38ba218ee6
--- /dev/null
+++ b/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewCloudflareApiTokenRotationGeneratedCredentials.tsx
@@ -0,0 +1,38 @@
+import { CredentialDisplay } from "@app/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/shared/CredentialDisplay";
+import { TCloudflareApiTokenRotationGeneratedCredentialsResponse } from "@app/hooks/api/secretRotationsV2/types/cloudflare-api-token-rotation";
+
+import { ViewRotationGeneratedCredentialsDisplay } from "./shared";
+
+type Props = {
+ generatedCredentialsResponse: TCloudflareApiTokenRotationGeneratedCredentialsResponse;
+};
+
+export const ViewCloudflareApiTokenRotationGeneratedCredentials = ({
+ generatedCredentialsResponse: { generatedCredentials, activeIndex }
+}: Props) => {
+ const inactiveIndex = activeIndex === 0 ? 1 : 0;
+
+ const activeCredentials = generatedCredentials[activeIndex];
+ const inactiveCredentials = generatedCredentials[inactiveIndex];
+
+ return (
+ <ViewRotationGeneratedCredentialsDisplay
+ activeCredentials={
+ <>
+ <CredentialDisplay label="Token ID">{activeCredentials?.tokenId}</CredentialDisplay>
+ <CredentialDisplay isSensitive label="API Token">
+ {activeCredentials?.apiToken}
+ </CredentialDisplay>
+ </>
+ }
+ inactiveCredentials={
+ <>
+ <CredentialDisplay label="Token ID">{inactiveCredentials?.tokenId}</CredentialDisplay>
+ <CredentialDisplay isSensitive label="API Token">
+ {inactiveCredentials?.apiToken}
+ </CredentialDisplay>
+ </>
+ }
+ />
+ );
+};
diff --git a/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewSecretRotationV2GeneratedCredentials.tsx b/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewSecretRotationV2GeneratedCredentials.tsx
index 4d57fc1167..642cf657bb 100644
--- a/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewSecretRotationV2GeneratedCredentials.tsx
+++ b/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewSecretRotationV2GeneratedCredentials.tsx
@@ -24,6 +24,7 @@ import {
import { ViewSqlCredentialsRotationGeneratedCredentials } from "./shared";
import { ViewAwsIamUserSecretRotationGeneratedCredentials } from "./ViewAwsIamUserSecretRotationGeneratedCredentials";
+import { ViewCloudflareApiTokenRotationGeneratedCredentials } from "./ViewCloudflareApiTokenRotationGeneratedCredentials";
import { ViewDatadogApiKeyRotationGeneratedCredentials } from "./ViewDatadogApiKeyRotationGeneratedCredentials";
import { ViewDatadogApplicationKeySecretRotationGeneratedCredentials } from "./ViewDatadogApplicationKeySecretRotationGeneratedCredentials";
import { ViewDbtServiceTokenRotationGeneratedCredentials } from "./ViewDbtSeviceTokenRotationGeneratedCredentials";
@@ -236,6 +237,13 @@ const Content = ({ secretRotation }: ContentProps) => {
/>
);
break;
+ case SecretRotation.CloudflareApiToken:
+ Component = (
+ <ViewCloudflareApiTokenRotationGeneratedCredentials
+ generatedCredentialsResponse={generatedCredentialsResponse}
+ />
+ );
+ break;
default:
throw new Error("Unhandled View Generated Credential Rotation Type");
}
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/CloudflareApiTokenRotationParametersFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/CloudflareApiTokenRotationParametersFields.tsx
new file mode 100644
index 0000000000..b07de99e40
--- /dev/null
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/CloudflareApiTokenRotationParametersFields.tsx
@@ -0,0 +1,388 @@
+import { useEffect, useMemo, useState } from "react";
+import { Control, Controller, useFieldArray, useFormContext } from "react-hook-form";
+import { MultiValue, SingleValue } from "react-select";
+import { faPlus, faTrash } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { twMerge } from "tailwind-merge";
+import { z } from "zod";
+
+import {
+ Button,
+ FilterableSelect,
+ FormControl,
+ FormLabel,
+ IconButton,
+ Input,
+ Select,
+ SelectItem,
+ Tab,
+ TabList,
+ TabPanel,
+ Tabs,
+ TextArea
+} from "@app/components/v2";
+import {
+ TCloudflarePermissionGroup,
+ TCloudflareZone,
+ useCloudflareConnectionListPermissionGroups,
+ useCloudflareConnectionListZones
+} from "@app/hooks/api/appConnections/cloudflare";
+
+import {
+ CLOUDFLARE_API_TOKEN_NAME_MAX_LENGTH,
+ CLOUDFLARE_POLICY_EFFECT_MAP,
+ CLOUDFLARE_POLICY_SCOPE_MAP,
+ CLOUDFLARE_POLICY_SCOPE_RESOURCE_MAP,
+ CloudflareApiTokenPolicyEffect,
+ CloudflareApiTokenPolicyScope,
+ CloudflareApiTokenRotationSchema,
+ explodePolicies,
+ isStoredPolicy
+} from "../schemas/cloudflare-api-token-rotation-schema";
+
+// The schema merges policy rows into the stored shape on submit, so `TSecretRotationV2Form` (the
+// schema's *output* type) describes merged policies. The fields here edit rows, which is the input side.
+type TCloudflareApiTokenForm = z.input<typeof CloudflareApiTokenRotationSchema>;
+
+const DEFAULT_POLICY = {
+ effect: CloudflareApiTokenPolicyEffect.Allow,
+ scope: CloudflareApiTokenPolicyScope.Account,
+ zoneIds: [],
+ permissionGroupId: ""
+};
+
+enum ParameterTab {
+ General = "general",
+ Restrictions = "restrictions"
+}
+
+/**
+ * Textarea-backed editor for a list of IPs/CIDRs. The raw text lives in local state so partially
+ * typed entries and blank lines survive re-renders, while the form only ever holds the parsed list.
+ */
+const IpListInput = ({
+ value,
+ onChange
+}: {
+ value?: string[];
+ onChange: (value: string[]) => void;
+}) => {
+ const [rawValue, setRawValue] = useState((value ?? []).join("\n"));
+
+ return (
+ <TextArea
+ reSize="none"
+ rows={4}
+ value={rawValue}
+ onChange={(e) => {
+ setRawValue(e.target.value);
+ onChange(
+ e.target.value
+ .split(/[\n,]/)
+ .map((entry) => entry.trim())
+ .filter(Boolean)
+ );
+ }}
+ placeholder={"199.27.128.0/21\n2400:cb00::/32"}
+ className="border-mineshaft-600 bg-mineshaft-900 font-mono text-sm"
+ />
+ );
+};
+
+const IpListField = ({
+ control,
+ name,
+ label,
+ tooltipText
+}: {
+ control: Control<TCloudflareApiTokenForm>;
+ name: "parameters.allowedIps" | "parameters.disallowedIps";
+ label: string;
+ tooltipText: string;
+}) => (
+ <Controller
+ control={control}
+ name={name}
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl
+ isOptional
+ isError={Boolean(error)}
+ errorText={error?.message}
+ label={label}
+ tooltipText={tooltipText}
+ >
+ <IpListInput value={value} onChange={onChange} />
+ </FormControl>
+ )}
+ />
+);
+
+export const CloudflareApiTokenRotationParametersFields = () => {
+ const { control, watch, setValue, getValues } = useFormContext<TCloudflareApiTokenForm>();
+
+ const connectionId = watch("connection.id");
+ const policies = watch("parameters.policies");
+
+ // account-scoped: a zone outside the connection's account can't appear in an account token's policy
+ const { data: zones, isPending: isZonesPending } = useCloudflareConnectionListZones(
+ connectionId,
+ { enabled: Boolean(connectionId) },
+ true
+ );
+
+ const { data: permissionGroups, isPending: isPermissionGroupsPending } =
+ useCloudflareConnectionListPermissionGroups(connectionId, {
+ enabled: Boolean(connectionId)
+ });
+
+ const policyFields = useFieldArray({
+ control,
+ name: "parameters.policies"
+ });
+
+ // Seed a first row on create, and on edit expand the stored merged policies into one row per
+ // permission group so the field array has something row-shaped to render.
+ useEffect(() => {
+ const currentPolicies = getValues("parameters.policies");
+
+ if (!currentPolicies?.length) {
+ setValue("parameters.policies", [DEFAULT_POLICY]);
+ return;
+ }
+
+ // the form type says rows, but `defaultValues` really does hand us the stored shape on edit
+ const storedPolicies = (currentPolicies as unknown[]).filter(isStoredPolicy);
+
+ if (storedPolicies.length) {
+ setValue("parameters.policies", explodePolicies(storedPolicies));
+ }
+ }, []);
+
+ // A permission group can only be attached to the resource types listed in its `scopes`. Groups that
+ // report no scopes are kept in every list so an upstream response change can't empty the dropdown.
+ const permissionGroupsByScope = useMemo(() => {
+ const filterByScope = (scope: CloudflareApiTokenPolicyScope) =>
+ (permissionGroups ?? []).filter(
+ (group) =>
+ !group.scopes.length || group.scopes.includes(CLOUDFLARE_POLICY_SCOPE_RESOURCE_MAP[scope])
+ );
+
+ return {
+ [CloudflareApiTokenPolicyScope.Account]: filterByScope(CloudflareApiTokenPolicyScope.Account),
+ [CloudflareApiTokenPolicyScope.AllZones]: filterByScope(
+ CloudflareApiTokenPolicyScope.AllZones
+ ),
+ [CloudflareApiTokenPolicyScope.Zones]: filterByScope(CloudflareApiTokenPolicyScope.Zones)
+ };
+ }, [permissionGroups]);
+
+ return (
+ <Tabs defaultValue={ParameterTab.General}>
+ <TabList>
+ <Tab value={ParameterTab.General}>General</Tab>
+ <Tab value={ParameterTab.Restrictions}>Restrictions</Tab>
+ </TabList>
+ <TabPanel value={ParameterTab.General}>
+ <Controller
+ control={control}
+ name="parameters.name"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ label="Token Name"
+ tooltipText="The name for the generated Cloudflare API token. A timestamp is appended so each rotated token is distinct."
+ >
+ <Input
+ {...field}
+ placeholder="infisical-rotated-token"
+ maxLength={CLOUDFLARE_API_TOKEN_NAME_MAX_LENGTH}
+ />
+ </FormControl>
+ )}
+ />
+ <FormLabel
+ label="Access Policies"
+ tooltipText="Each row grants one permission group over the entire account, all zones in the account, or a specific set of zones. Rows targeting the same resources are combined into a single Cloudflare policy."
+ />
+ <div
+ className={twMerge(
+ "mb-3 flex w-full flex-col space-y-2",
+ policyFields.fields.length >= 3 ? "max-h-96 overflow-y-auto" : ""
+ )}
+ >
+ {policyFields.fields.map(({ id: policyFieldId }, i) => {
+ const policyScope = policies?.[i]?.scope ?? CloudflareApiTokenPolicyScope.Account;
+ const permissionGroupOptions = permissionGroupsByScope[policyScope];
+ const showZones = policyScope === CloudflareApiTokenPolicyScope.Zones;
+
+ return (
+ // A card per policy rather than one flat row: four selects side by side don't fit the
+ // modal width, and cramming them wraps the placeholders and misaligns the labels.
+ <div
+ key={policyFieldId}
+ className="rounded-md border border-mineshaft-600 bg-mineshaft-800 p-3"
+ >
+ <div className="mb-1 flex items-center justify-between">
+ <span className="text-xs text-mineshaft-400">Policy {i + 1}</span>
+ <IconButton
+ ariaLabel="delete policy"
+ variant="plain"
+ colorSchema="danger"
+ onClick={() => {
+ const currentPolicies = getValues("parameters.policies");
+ if (currentPolicies && currentPolicies.length > 1) {
+ policyFields.remove(i);
+ } else {
+ setValue("parameters.policies", [DEFAULT_POLICY]);
+ }
+ }}
+ >
+ <FontAwesomeIcon icon={faTrash} />
+ </IconButton>
+ </div>
+ <div className="grid grid-cols-2 gap-x-3">
+ <Controller
+ control={control}
+ name={`parameters.policies.${i}.effect`}
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ label="Effect"
+ className="mb-0"
+ >
+ <Select
+ className="w-full"
+ position="popper"
+ value={field.value}
+ onValueChange={field.onChange}
+ >
+ {Object.entries(CLOUDFLARE_POLICY_EFFECT_MAP).map(([effect, label]) => (
+ <SelectItem key={effect} value={effect}>
+ {label}
+ </SelectItem>
+ ))}
+ </Select>
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name={`parameters.policies.${i}.scope`}
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ label="Scope"
+ className="mb-0"
+ >
+ <Select
+ className="w-full"
+ position="popper"
+ value={field.value}
+ onValueChange={(scope) => {
+ field.onChange(scope);
+ // the zones and permission group from the previous scope no longer apply
+ setValue(`parameters.policies.${i}.zoneIds`, []);
+ setValue(`parameters.policies.${i}.permissionGroupId`, "");
+ }}
+ >
+ {Object.entries(CLOUDFLARE_POLICY_SCOPE_MAP).map(([scope, label]) => (
+ <SelectItem key={scope} value={scope}>
+ {label}
+ </SelectItem>
+ ))}
+ </Select>
+ </FormControl>
+ )}
+ />
+ {showZones && (
+ <Controller
+ control={control}
+ name={`parameters.policies.${i}.zoneIds`}
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ label="Zones"
+ className="mt-3 mb-0"
+ >
+ <FilterableSelect
+ isMulti
+ isLoading={isZonesPending && Boolean(connectionId)}
+ isDisabled={!connectionId}
+ options={zones}
+ placeholder="Select zones..."
+ getOptionLabel={(option) => option.name}
+ getOptionValue={(option) => option.id}
+ value={zones?.filter((zone) => (value ?? []).includes(zone.id)) ?? []}
+ onChange={(option) =>
+ onChange(
+ (option as MultiValue<TCloudflareZone>).map((zone) => zone.id)
+ )
+ }
+ />
+ </FormControl>
+ )}
+ />
+ )}
+ <Controller
+ control={control}
+ name={`parameters.policies.${i}.permissionGroupId`}
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ label="Permission group"
+ // fills the row when there's no zone picker beside it
+ className={twMerge("mt-3 mb-0", showZones ? "" : "col-span-2")}
+ >
+ <FilterableSelect
+ isLoading={isPermissionGroupsPending && Boolean(connectionId)}
+ isDisabled={!connectionId}
+ options={permissionGroupOptions}
+ placeholder="Select a permission group..."
+ getOptionLabel={(option) => option.name}
+ getOptionValue={(option) => option.id}
+ value={permissionGroupOptions.find((group) => group.id === value) ?? null}
+ onChange={(option) =>
+ onChange((option as SingleValue<TCloudflarePermissionGroup>)?.id ?? "")
+ }
+ />
+ </FormControl>
+ )}
+ />
+ </div>
+ </div>
+ );
+ })}
+ <div>
+ <Button
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ size="xs"
+ variant="outline_bg"
+ onClick={() => policyFields.append(DEFAULT_POLICY)}
+ >
+ Add policy
+ </Button>
+ </div>
+ </div>
+ </TabPanel>
+ <TabPanel value={ParameterTab.Restrictions}>
+ <IpListField
+ control={control}
+ name="parameters.allowedIps"
+ label="Allowed IPs"
+ tooltipText="The generated token can only be used from these IP addresses or CIDR blocks. One entry per line. Leave empty to allow any IP."
+ />
+ <IpListField
+ control={control}
+ name="parameters.disallowedIps"
+ label="Disallowed IPs"
+ tooltipText="The generated token cannot be used from these IP addresses or CIDR blocks. One entry per line."
+ />
+ </TabPanel>
+ </Tabs>
+ );
+};
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SecretRotationV2ParametersFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SecretRotationV2ParametersFields.tsx
index 29798e9f55..7617ce30f9 100644
--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SecretRotationV2ParametersFields.tsx
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SecretRotationV2ParametersFields.tsx
@@ -6,6 +6,7 @@ import { TSecretRotationV2Form } from "../schemas";
import { Auth0ClientSecretRotationParametersFields } from "./Auth0ClientSecretRotationParametersFields";
import { AwsIamUserSecretRotationParametersFields } from "./AwsIamUserSecretRotationParametersFields";
import { AzureClientSecretRotationParametersFields } from "./AzureClientSecretRotationParametersFields";
+import { CloudflareApiTokenRotationParametersFields } from "./CloudflareApiTokenRotationParametersFields";
import { ConvexAccessKeyRotationParametersFields } from "./ConvexAccessKeyRotationParametersFields";
import { DatabricksServicePrincipalSecretRotationParametersFields } from "./DatabricksServicePrincipalSecretRotationParametersFields";
import { DatadogApiKeyRotationParametersFields } from "./DatadogApiKeyRotationParametersFields";
@@ -54,7 +55,8 @@ const COMPONENT_MAP: Record<SecretRotation, React.FC> = {
[SecretRotation.DatadogApiKey]: DatadogApiKeyRotationParametersFields,
[SecretRotation.ConvexAccessKey]: ConvexAccessKeyRotationParametersFields,
[SecretRotation.FireworksApiKey]: FireworksApiKeyRotationParametersFields,
- [SecretRotation.SnowflakeUserKeyPair]: SnowflakeUserKeyPairRotationParametersFields
+ [SecretRotation.SnowflakeUserKeyPair]: SnowflakeUserKeyPairRotationParametersFields,
+ [SecretRotation.CloudflareApiToken]: CloudflareApiTokenRotationParametersFields
};
export const SecretRotationV2ParametersFields = () => {
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/CloudflareApiTokenRotationReviewFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/CloudflareApiTokenRotationReviewFields.tsx
new file mode 100644
index 0000000000..2a019324c8
--- /dev/null
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/CloudflareApiTokenRotationReviewFields.tsx
@@ -0,0 +1,87 @@
+import { useFormContext } from "react-hook-form";
+import { z } from "zod";
+
+import { GenericFieldLabel } from "@app/components/v2";
+import { Badge } from "@app/components/v3";
+import {
+ useCloudflareConnectionListPermissionGroups,
+ useCloudflareConnectionListZones
+} from "@app/hooks/api/appConnections/cloudflare";
+
+import {
+ CLOUDFLARE_POLICY_EFFECT_MAP,
+ CLOUDFLARE_POLICY_SCOPE_MAP,
+ CloudflareApiTokenPolicyScope,
+ CloudflareApiTokenRotationSchema
+} from "../schemas/cloudflare-api-token-rotation-schema";
+import { SecretRotationReviewSection } from "./shared";
+
+// `watch` returns the raw form state, which holds one policy row per permission group — the schema's
+// input side. See the note in CloudflareApiTokenRotationParametersFields.
+type TCloudflareApiTokenForm = z.input<typeof CloudflareApiTokenRotationSchema>;
+
+export const CloudflareApiTokenRotationReviewFields = () => {
+ const { watch } = useFormContext<TCloudflareApiTokenForm>();
+
+ const [connectionId, parameters, { tokenId, apiToken }] = watch([
+ "connection.id",
+ "parameters",
+ "secretsMapping"
+ ]);
+
+ const { data: permissionGroups } = useCloudflareConnectionListPermissionGroups(connectionId, {
+ enabled: Boolean(connectionId)
+ });
+
+ const { data: zones } = useCloudflareConnectionListZones(
+ connectionId,
+ { enabled: Boolean(connectionId) },
+ true
+ );
+
+ const getPermissionGroupLabel = (permissionGroupId: string) =>
+ permissionGroups?.find((group) => group.id === permissionGroupId)?.name ?? permissionGroupId;
+
+ const getScopeLabel = (scope: CloudflareApiTokenPolicyScope, zoneIds?: string[]) => {
+ if (scope !== CloudflareApiTokenPolicyScope.Zones) return CLOUDFLARE_POLICY_SCOPE_MAP[scope];
+
+ return (zoneIds ?? [])
+ .map((zoneId) => zones?.find((zone) => zone.id === zoneId)?.name ?? zoneId)
+ .join(", ");
+ };
+
+ return (
+ <>
+ <SecretRotationReviewSection label="Parameters">
+ <GenericFieldLabel label="Token Name">{parameters.name}</GenericFieldLabel>
+ <div className="grid grid-cols-2 gap-2">
+ {parameters.policies.map((policy, i) => (
+ <GenericFieldLabel key={`policy-${i + 1}`} label={`Policy ${i + 1}`}>
+ <div className="flex flex-wrap items-center gap-2">
+ <span>{CLOUDFLARE_POLICY_EFFECT_MAP[policy.effect]}</span>
+ <Badge variant="neutral">{getScopeLabel(policy.scope, policy.zoneIds)}</Badge>
+ <span className="text-mineshaft-300">
+ {getPermissionGroupLabel(policy.permissionGroupId)}
+ </span>
+ </div>
+ </GenericFieldLabel>
+ ))}
+ </div>
+ {Boolean(parameters.allowedIps?.length) && (
+ <GenericFieldLabel label="Allowed IPs">
+ {parameters.allowedIps?.join(", ")}
+ </GenericFieldLabel>
+ )}
+ {Boolean(parameters.disallowedIps?.length) && (
+ <GenericFieldLabel label="Disallowed IPs">
+ {parameters.disallowedIps?.join(", ")}
+ </GenericFieldLabel>
+ )}
+ </SecretRotationReviewSection>
+ <SecretRotationReviewSection label="Secrets Mapping">
+ <GenericFieldLabel label="Token ID">{tokenId}</GenericFieldLabel>
+ <GenericFieldLabel label="API Token">{apiToken}</GenericFieldLabel>
+ </SecretRotationReviewSection>
+ </>
+ );
+};
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SecretRotationReviewFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SecretRotationReviewFields.tsx
index 0a4abf7930..e2dbb1d532 100644
--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SecretRotationReviewFields.tsx
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SecretRotationReviewFields.tsx
@@ -9,6 +9,7 @@ import { SecretRotation } from "@app/hooks/api/secretRotationsV2";
import { Auth0ClientSecretRotationReviewFields } from "./Auth0ClientSecretRotationReviewFields";
import { AwsIamUserSecretRotationReviewFields } from "./AwsIamUserSecretRotationReviewFields";
import { AzureClientSecretRotationReviewFields } from "./AzureClientSecretRotationReviewFields";
+import { CloudflareApiTokenRotationReviewFields } from "./CloudflareApiTokenRotationReviewFields";
import { ConvexAccessKeyRotationReviewFields } from "./ConvexAccessKeyRotationReviewFields";
import { DatabricksServicePrincipalSecretRotationReviewFields } from "./DatabricksServicePrincipalSecretRotationReviewFields";
import { DatadogApiKeyRotationReviewFields } from "./DatadogApiKeyRotationReviewFields";
@@ -56,7 +57,8 @@ const COMPONENT_MAP: Record<SecretRotation, React.FC> = {
[SecretRotation.DatadogApiKey]: DatadogApiKeyRotationReviewFields,
[SecretRotation.ConvexAccessKey]: ConvexAccessKeyRotationReviewFields,
[SecretRotation.FireworksApiKey]: FireworksApiKeyRotationReviewFields,
- [SecretRotation.SnowflakeUserKeyPair]: SnowflakeUserKeyPairRotationReviewFields
+ [SecretRotation.SnowflakeUserKeyPair]: SnowflakeUserKeyPairRotationReviewFields,
+ [SecretRotation.CloudflareApiToken]: CloudflareApiTokenRotationReviewFields
};
export const SecretRotationV2ReviewFields = () => {
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/CloudflareApiTokenRotationSecretsMappingFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/CloudflareApiTokenRotationSecretsMappingFields.tsx
new file mode 100644
index 0000000000..50c36e4bb3
--- /dev/null
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/CloudflareApiTokenRotationSecretsMappingFields.tsx
@@ -0,0 +1,58 @@
+import { Controller, useFormContext } from "react-hook-form";
+
+import { TSecretRotationV2Form } from "@app/components/secret-rotations-v2/forms/schemas";
+import { FormControl, Input } from "@app/components/v2";
+import { SecretRotation, useSecretRotationV2Option } from "@app/hooks/api/secretRotationsV2";
+
+import { SecretsMappingTable } from "./shared";
+
+export const CloudflareApiTokenRotationSecretsMappingFields = () => {
+ const { control } = useFormContext<
+ TSecretRotationV2Form & {
+ type: SecretRotation.CloudflareApiToken;
+ }
+ >();
+
+ const { rotationOption } = useSecretRotationV2Option(SecretRotation.CloudflareApiToken);
+
+ const items = [
+ {
+ name: "Token ID",
+ input: (
+ <Controller
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl isError={Boolean(error)} errorText={error?.message}>
+ <Input
+ value={value}
+ onChange={onChange}
+ placeholder={rotationOption?.template.secretsMapping.tokenId}
+ />
+ </FormControl>
+ )}
+ control={control}
+ name="secretsMapping.tokenId"
+ />
+ )
+ },
+ {
+ 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"
+ />
+ )
+ }
+ ];
+
+ return <SecretsMappingTable items={items} />;
+};
diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/SecretRotationV2SecretsMappingFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/SecretRotationV2SecretsMappingFields.tsx
index c9fc3321d9..fe31649ef2 100644
--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/SecretRotationV2SecretsMappingFields.tsx
+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/SecretRotationV2SecretsMappingFields.tsx
@@ -6,6 +6,7 @@ import { TSecretRotationV2Form } from "../schemas";
import { Auth0ClientSecretRotationSecretsMappingFields } from "./Auth0ClientSecretRotationSecretsMappingFields";
import { AwsIamUserSecretRotationSecretsMappingFields } from "./AwsIamUserSecretRotationSecretsMappingFields";
import { AzureClientSecretRotationSecretsMappingFields } from "./AzureClientSecretRotationSecretsMappingFields";
+import { CloudflareApiTokenRotationSecretsMappingFields } from "./CloudflareApiTokenRotationSecretsMappingFields";
import { ConvexAccessKeyRotationSecretsMappingFields } from "./ConvexAccessKeyRotationSecretsMappingFields";
import { DatabricksServicePrincipalSecretRotationSecretsMappingFields } from "./DatabricksServicePrincipalSecretRotationSecretsMappingFields";
import { DatadogApiKeyRotationSecretsMappingFields } from "./DatadogApiKeyRotationSecretsMappingFields";
@@ -55,7 +56,8 @@ const COMPONENT_MAP: Record<SecretRotation, React.FC> = {
[SecretRotation.DatadogApiKey]: DatadogApiKeyRotationSecretsMappingFields,
[SecretRotation.ConvexAccessKey]: ConvexAccessKeyRotationSecretsMappingFields,
[SecretRotation.FireworksApiKey]: FireworksApiKeyRotationSecretsMappingFields,
- [SecretRotation.SnowflakeUserKeyPair]: SnowflakeUserKeyPairRotationSecretsMappingFields
+ [SecretRotation.SnowflakeUserKeyPair]: SnowflakeUserKeyPairRotationSecretsMappingFields,
+ [SecretRotation.CloudflareApiToken]: CloudflareApiTokenRotationSecretsMappingFields
};
export const SecretRotationV2SecretsMappingFields = () => {
diff --git a/frontend/src/components/secret-rotations-v2/forms/schemas/cloudflare-api-token-rotation-schema.ts b/frontend/src/components/secret-rotations-v2/forms/schemas/cloudflare-api-token-rotation-schema.ts
new file mode 100644
index 0000000000..ca794ed158
--- /dev/null
+++ b/frontend/src/components/secret-rotations-v2/forms/schemas/cloudflare-api-token-rotation-schema.ts
@@ -0,0 +1,132 @@
+import { z } from "zod";
+
+import { BaseSecretRotationSchema } from "@app/components/secret-rotations-v2/forms/schemas/base-secret-rotation-v2-schema";
+import { isValidIpOrCidr } from "@app/helpers/ip";
+import { SecretRotation } from "@app/hooks/api/secretRotationsV2";
+import { groupBy, unique } from "@app/lib/fn/array";
+
+export enum CloudflareApiTokenPolicyEffect {
+ Allow = "allow",
+ Deny = "deny"
+}
+
+export enum CloudflareApiTokenPolicyScope {
+ Account = "account",
+ AllZones = "all-zones",
+ Zones = "zones"
+}
+
+export const CLOUDFLARE_POLICY_EFFECT_MAP: Record<CloudflareApiTokenPolicyEffect, string> = {
+ [CloudflareApiTokenPolicyEffect.Allow]: "Allow",
+ [CloudflareApiTokenPolicyEffect.Deny]: "Deny"
+};
+
+export const CLOUDFLARE_POLICY_SCOPE_MAP: Record<CloudflareApiTokenPolicyScope, string> = {
+ [CloudflareApiTokenPolicyScope.Account]: "Entire account",
+ [CloudflareApiTokenPolicyScope.AllZones]: "All zones",
+ [CloudflareApiTokenPolicyScope.Zones]: "Specific zones"
+};
+
+/** A permission group only applies to the resource types listed in its `scopes`. */
+export const CLOUDFLARE_POLICY_SCOPE_RESOURCE_MAP: Record<CloudflareApiTokenPolicyScope, string> = {
+ [CloudflareApiTokenPolicyScope.Account]: "com.cloudflare.api.account",
+ [CloudflareApiTokenPolicyScope.AllZones]: "com.cloudflare.api.account.zone",
+ [CloudflareApiTokenPolicyScope.Zones]: "com.cloudflare.api.account.zone"
+};
+
+/** Matches the backend schema — Cloudflare caps token names at 120 and we append a timestamp. */
+export const CLOUDFLARE_API_TOKEN_NAME_MAX_LENGTH = 100;
+
+const IpRestrictionsSchema = z
+ .string()
+ .trim()
+ .array()
+ .optional()
+ .refine(
+ (ips) => !ips || ips.every(isValidIpOrCidr),
+ "Each entry must be a valid IP address or CIDR block"
+ );
+
+/**
+ * What a form row holds: exactly one permission group, which keeps each row readable as a single
+ * sentence. Rows are merged into the API shape by `mergePolicyRows` on submit.
+ */
+export const CloudflareApiTokenPolicyRowSchema = z
+ .object({
+ effect: z.nativeEnum(CloudflareApiTokenPolicyEffect),
+ scope: z.nativeEnum(CloudflareApiTokenPolicyScope),
+ zoneIds: z.string().trim().array().optional(),
+ permissionGroupId: z.string().trim().min(1, "Permission group required")
+ })
+ .superRefine((policy, ctx) => {
+ if (policy.scope === CloudflareApiTokenPolicyScope.Zones && !policy.zoneIds?.length) {
+ ctx.addIssue({
+ code: z.ZodIssueCode.custom,
+ path: ["zoneIds"],
+ message: "At least one zone is required"
+ });
+ }
+ });
+
+export type TCloudflareApiTokenPolicyRow = z.infer<typeof CloudflareApiTokenPolicyRowSchema>;
+
+/** What the API stores: one policy per (effect, scope, zones) with all its permission groups. */
+export type TCloudflareApiTokenPolicyStored = Omit<
+ TCloudflareApiTokenPolicyRow,
+ "permissionGroupId"
+> & {
+ permissionGroupIds: string[];
+};
+
+const policyResourceKey = ({ effect, scope, zoneIds }: TCloudflareApiTokenPolicyRow) =>
+ `${effect}|${scope}|${[...(zoneIds ?? [])].sort().join(",")}`;
+
+/**
+ * Collapses form rows into the stored shape, gathering the permission groups of every row that targets
+ * the same resources. Zone ids are sorted in the grouping key only, so rows that name the same zones
+ * in a different order still merge; the stored order is left as the user entered it.
+ */
+export const mergePolicyRows = (
+ rows: TCloudflareApiTokenPolicyRow[]
+): TCloudflareApiTokenPolicyStored[] =>
+ Object.values(groupBy(rows, policyResourceKey)).map((group) => ({
+ effect: group[0].effect,
+ scope: group[0].scope,
+ zoneIds: group[0].zoneIds,
+ permissionGroupIds: unique(group.map((row) => row.permissionGroupId))
+ }));
+
+/** Inverse of `mergePolicyRows` — expands a stored policy into one row per permission group. */
+export const explodePolicies = (
+ policies: TCloudflareApiTokenPolicyStored[]
+): TCloudflareApiTokenPolicyRow[] =>
+ policies.flatMap(({ effect, scope, zoneIds, permissionGroupIds }) =>
+ permissionGroupIds.map((permissionGroupId) => ({ effect, scope, zoneIds, permissionGroupId }))
+ );
+
+export const isStoredPolicy = (policy: unknown): policy is TCloudflareApiTokenPolicyStored =>
+ typeof policy === "object" && policy !== null && "permissionGroupIds" in policy;
+
+export const CloudflareApiTokenRotationSchema = z
+ .object({
+ type: z.literal(SecretRotation.CloudflareApiToken),
+ parameters: z.object({
+ name: z
+ .string()
+ .trim()
+ .min(1, "Token name required")
+ .max(CLOUDFLARE_API_TOKEN_NAME_MAX_LENGTH, "Token name too long"),
+ // The form edits rows; zodResolver hands the transformed (merged) value to handleSubmit, so the
+ // API receives the stored shape without the generic rotation form knowing anything about it.
+ policies: CloudflareApiTokenPolicyRowSchema.array()
+ .min(1, "At least one policy is required")
+ .transform(mergePolicyRows),
+ allowedIps: IpRestrictionsSchema,
+ disallowedIps: IpRestrictionsSchema
+ }),
+ secretsMapping: z.object({
+ tokenId: z.string().trim().min(1, "Token ID secret name required"),
+ apiToken: z.string().trim().min(1, "API Token secret name required")
+ })
+ })
+ .merge(BaseSecretRotationSchema);
diff --git a/frontend/src/components/secret-rotations-v2/forms/schemas/index.ts b/frontend/src/components/secret-rotations-v2/forms/schemas/index.ts
index 20b68da7e7..2b7461be40 100644
--- a/frontend/src/components/secret-rotations-v2/forms/schemas/index.ts
+++ b/frontend/src/components/secret-rotations-v2/forms/schemas/index.ts
@@ -15,6 +15,7 @@ import { LdapPasswordRotationMethod } from "@app/hooks/api/secretRotationsV2/typ
import { UnixLinuxLocalAccountRotationMethod } from "@app/hooks/api/secretRotationsV2/types/unix-linux-local-account-rotation";
import { WindowsLocalAccountRotationMethod } from "@app/hooks/api/secretRotationsV2/types/windows-local-account-rotation";
+import { CloudflareApiTokenRotationSchema } from "./cloudflare-api-token-rotation-schema";
import { ConvexAccessKeyRotationSchema } from "./convex-access-key-rotation-schema";
import { DatadogApiKeyRotationSchema } from "./datadog-api-key-rotation-schema";
import { DatadogApplicationKeySecretRotationSchema } from "./datadog-application-key-secret-rotation-schema";
@@ -62,7 +63,8 @@ export const SecretRotationV2FormSchema = (isUpdate: boolean) =>
DatadogApiKeyRotationSchema,
ConvexAccessKeyRotationSchema,
FireworksApiKeyRotationSchema,
- SnowflakeUserKeyPairRotationSchema
+ SnowflakeUserKeyPairRotationSchema,
+ CloudflareApiTokenRotationSchema
]),
z.object({ id: z.string().optional() })
)
diff --git a/frontend/src/helpers/secretRotationsV2.ts b/frontend/src/helpers/secretRotationsV2.ts
index 899b8139a8..8289b32aa4 100644
--- a/frontend/src/helpers/secretRotationsV2.ts
+++ b/frontend/src/helpers/secretRotationsV2.ts
@@ -134,6 +134,11 @@ export const SECRET_ROTATION_MAP: Record<
name: "Snowflake User Key Pair",
image: "Snowflake.png",
size: 50
+ },
+ [SecretRotation.CloudflareApiToken]: {
+ name: "Cloudflare API Token",
+ image: "Cloudflare.png",
+ size: 50
}
};
@@ -163,7 +168,8 @@ export const SECRET_ROTATION_CONNECTION_MAP: Record<SecretRotation, AppConnectio
[SecretRotation.DatadogApiKey]: AppConnection.Datadog,
[SecretRotation.ConvexAccessKey]: AppConnection.Convex,
[SecretRotation.FireworksApiKey]: AppConnection.Fireworks,
- [SecretRotation.SnowflakeUserKeyPair]: AppConnection.Snowflake
+ [SecretRotation.SnowflakeUserKeyPair]: AppConnection.Snowflake,
+ [SecretRotation.CloudflareApiToken]: AppConnection.Cloudflare
};
// if a rotation can potentially have downtime due to rotating a single credential set this to false
@@ -193,7 +199,8 @@ export const IS_ROTATION_DUAL_CREDENTIALS: Record<SecretRotation, boolean> = {
[SecretRotation.DatadogApiKey]: true,
[SecretRotation.ConvexAccessKey]: true,
[SecretRotation.FireworksApiKey]: true,
- [SecretRotation.SnowflakeUserKeyPair]: true
+ [SecretRotation.SnowflakeUserKeyPair]: true,
+ [SecretRotation.CloudflareApiToken]: true
};
export const getRotateAtLocal = ({ hours, minutes }: TSecretRotationV2["rotateAtUtc"]) => {
diff --git a/frontend/src/hooks/api/appConnections/cloudflare/queries.tsx b/frontend/src/hooks/api/appConnections/cloudflare/queries.tsx
index 973943d1ea..05d9935057 100644
--- a/frontend/src/hooks/api/appConnections/cloudflare/queries.tsx
+++ b/frontend/src/hooks/api/appConnections/cloudflare/queries.tsx
@@ -3,7 +3,12 @@ import { useQuery, UseQueryOptions } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { appConnectionKeys } from "../queries";
-import { TCloudflarePagesProject, TCloudflareWorkersScript, TCloudflareZone } from "./types";
+import {
+ TCloudflarePagesProject,
+ TCloudflarePermissionGroup,
+ TCloudflareWorkersScript,
+ TCloudflareZone
+} from "./types";
const cloudflareConnectionKeys = {
all: [...appConnectionKeys.all, "cloudflare"] as const,
@@ -11,8 +16,10 @@ const cloudflareConnectionKeys = {
[...cloudflareConnectionKeys.all, "pages-projects", connectionId] as const,
listWorkersScripts: (connectionId: string) =>
[...cloudflareConnectionKeys.all, "workers-scripts", connectionId] as const,
- listZones: (connectionId: string) =>
- [...cloudflareConnectionKeys.all, "zones", connectionId] as const
+ listZones: (connectionId: string, scopeToAccount: boolean) =>
+ [...cloudflareConnectionKeys.all, "zones", connectionId, { scopeToAccount }] as const,
+ listPermissionGroups: (connectionId: string) =>
+ [...cloudflareConnectionKeys.all, "permission-groups", connectionId] as const
};
export const useCloudflareConnectionListPagesProjects = (
@@ -75,13 +82,42 @@ export const useCloudflareConnectionListZones = (
ReturnType<typeof cloudflareConnectionKeys.listZones>
>,
"queryKey" | "queryFn"
- >
+ >,
+ // Restricts the result to zones in the connection's account. Only needed by callers that reference
+ // zones from account-scoped resources, such as an account-owned API token's policies.
+ scopeToAccount = false
) => {
return useQuery({
- queryKey: cloudflareConnectionKeys.listZones(connectionId),
+ queryKey: cloudflareConnectionKeys.listZones(connectionId, scopeToAccount),
queryFn: async () => {
const { data } = await apiRequest.get<TCloudflareZone[]>(
- `/api/v1/app-connections/cloudflare/${connectionId}/cloudflare-zones`
+ `/api/v1/app-connections/cloudflare/${connectionId}/cloudflare-zones`,
+ { params: scopeToAccount ? { scopeToAccount: true } : undefined }
+ );
+
+ return data;
+ },
+ ...options
+ });
+};
+
+export const useCloudflareConnectionListPermissionGroups = (
+ connectionId: string,
+ options?: Omit<
+ UseQueryOptions<
+ TCloudflarePermissionGroup[],
+ unknown,
+ TCloudflarePermissionGroup[],
+ ReturnType<typeof cloudflareConnectionKeys.listPermissionGroups>
+ >,
+ "queryKey" | "queryFn"
+ >
+) => {
+ return useQuery({
+ queryKey: cloudflareConnectionKeys.listPermissionGroups(connectionId),
+ queryFn: async () => {
+ const { data } = await apiRequest.get<TCloudflarePermissionGroup[]>(
+ `/api/v1/app-connections/cloudflare/${connectionId}/cloudflare-permission-groups`
);
return data;
diff --git a/frontend/src/hooks/api/appConnections/cloudflare/types.ts b/frontend/src/hooks/api/appConnections/cloudflare/types.ts
index e8905e16c7..fa42542e45 100644
--- a/frontend/src/hooks/api/appConnections/cloudflare/types.ts
+++ b/frontend/src/hooks/api/appConnections/cloudflare/types.ts
@@ -11,3 +11,10 @@ export type TCloudflareZone = {
id: string;
name: string;
};
+
+export type TCloudflarePermissionGroup = {
+ id: string;
+ name: string;
+ // the resource types this permission group can be attached to, e.g. "com.cloudflare.api.account.zone"
+ scopes: string[];
+};
diff --git a/frontend/src/hooks/api/secretRotationsV2/enums.ts b/frontend/src/hooks/api/secretRotationsV2/enums.ts
index f86e55f7dd..9b536fc065 100644
--- a/frontend/src/hooks/api/secretRotationsV2/enums.ts
+++ b/frontend/src/hooks/api/secretRotationsV2/enums.ts
@@ -24,7 +24,8 @@ export enum SecretRotation {
DatadogApiKey = "datadog-api-key",
ConvexAccessKey = "convex-access-key",
FireworksApiKey = "fireworks-api-key",
- SnowflakeUserKeyPair = "snowflake-user-key-pair"
+ SnowflakeUserKeyPair = "snowflake-user-key-pair",
+ CloudflareApiToken = "cloudflare-api-token"
}
export enum SecretRotationStatus {
diff --git a/frontend/src/hooks/api/secretRotationsV2/types/cloudflare-api-token-rotation.ts b/frontend/src/hooks/api/secretRotationsV2/types/cloudflare-api-token-rotation.ts
new file mode 100644
index 0000000000..0cbfd0557a
--- /dev/null
+++ b/frontend/src/hooks/api/secretRotationsV2/types/cloudflare-api-token-rotation.ts
@@ -0,0 +1,43 @@
+import { TCloudflareApiTokenPolicyStored } from "@app/components/secret-rotations-v2/forms/schemas/cloudflare-api-token-rotation-schema";
+import { AppConnection } from "@app/hooks/api/appConnections/enums";
+import { SecretRotation } from "@app/hooks/api/secretRotationsV2";
+import {
+ TSecretRotationV2Base,
+ TSecretRotationV2GeneratedCredentialsResponseBase
+} from "@app/hooks/api/secretRotationsV2/types/shared";
+
+export type TCloudflareApiTokenPolicy = TCloudflareApiTokenPolicyStored;
+
+export type TCloudflareApiTokenRotation = TSecretRotationV2Base & {
+ type: SecretRotation.CloudflareApiToken;
+ parameters: {
+ name: string;
+ policies: TCloudflareApiTokenPolicy[];
+ allowedIps?: string[];
+ disallowedIps?: string[];
+ };
+ secretsMapping: {
+ tokenId: string;
+ apiToken: string;
+ };
+};
+
+export type TCloudflareApiTokenRotationGeneratedCredentials = {
+ tokenId: string;
+ apiToken: string;
+};
+
+export type TCloudflareApiTokenRotationGeneratedCredentialsResponse =
+ TSecretRotationV2GeneratedCredentialsResponseBase<
+ SecretRotation.CloudflareApiToken,
+ TCloudflareApiTokenRotationGeneratedCredentials
+ >;
+
+export type TCloudflareApiTokenRotationOption = {
+ name: string;
+ type: SecretRotation.CloudflareApiToken;
+ connection: AppConnection.Cloudflare;
+ template: {
+ secretsMapping: TCloudflareApiTokenRotation["secretsMapping"];
+ };
+};
diff --git a/frontend/src/hooks/api/secretRotationsV2/types/index.ts b/frontend/src/hooks/api/secretRotationsV2/types/index.ts
index 7255922210..d4d2797f5e 100644
--- a/frontend/src/hooks/api/secretRotationsV2/types/index.ts
+++ b/frontend/src/hooks/api/secretRotationsV2/types/index.ts
@@ -36,6 +36,11 @@ import { TSqlCredentialsRotationOption } from "@app/hooks/api/secretRotationsV2/
import { SecretV3RawSanitized } from "@app/hooks/api/secrets/types";
import { DiscriminativePick } from "@app/types";
+import {
+ TCloudflareApiTokenRotation,
+ TCloudflareApiTokenRotationGeneratedCredentialsResponse,
+ TCloudflareApiTokenRotationOption
+} from "./cloudflare-api-token-rotation";
import {
TConvexAccessKeyRotation,
TConvexAccessKeyRotationGeneratedCredentialsResponse,
@@ -157,6 +162,7 @@ export type TSecretRotationV2 = (
| TConvexAccessKeyRotation
| TFireworksApiKeyRotation
| TSnowflakeUserKeyPairRotation
+ | TCloudflareApiTokenRotation
) & {
secrets: (SecretV3RawSanitized | null)[];
};
@@ -184,7 +190,8 @@ export type TSecretRotationV2Option =
| TDatadogApiKeyRotationOption
| TConvexAccessKeyRotationOption
| TFireworksApiKeyRotationOption
- | TSnowflakeUserKeyPairRotationOption;
+ | TSnowflakeUserKeyPairRotationOption
+ | TCloudflareApiTokenRotationOption;
export type TListSecretRotationV2Options = { secretRotationOptions: TSecretRotationV2Option[] };
@@ -216,7 +223,8 @@ export type TViewSecretRotationGeneratedCredentialsResponse =
| TDatadogApiKeyRotationGeneratedCredentialsResponse
| TConvexAccessKeyRotationGeneratedCredentialsResponse
| TFireworksApiKeyRotationGeneratedCredentialsResponse
- | TSnowflakeUserKeyPairRotationGeneratedCredentialsResponse;
+ | TSnowflakeUserKeyPairRotationGeneratedCredentialsResponse
+ | TCloudflareApiTokenRotationGeneratedCredentialsResponse;
export type TCreateSecretRotationV2DTO = DiscriminativePick<
TSecretRotationV2,
@@ -297,6 +305,7 @@ export type TSecretRotationOptionMap = {
[SecretRotation.ConvexAccessKey]: TConvexAccessKeyRotationOption;
[SecretRotation.FireworksApiKey]: TFireworksApiKeyRotationOption;
[SecretRotation.SnowflakeUserKeyPair]: TSnowflakeUserKeyPairRotationOption;
+ [SecretRotation.CloudflareApiToken]: TCloudflareApiTokenRotationOption;
};
export type TSecretRotationGeneratedCredentialsResponseMap = {
@@ -326,6 +335,7 @@ export type TSecretRotationGeneratedCredentialsResponseMap = {
[SecretRotation.ConvexAccessKey]: TConvexAccessKeyRotationGeneratedCredentialsResponse;
[SecretRotation.FireworksApiKey]: TFireworksApiKeyRotationGeneratedCredentialsResponse;
[SecretRotation.SnowflakeUserKeyPair]: TSnowflakeUserKeyPairRotationGeneratedCredentialsResponse;
+ [SecretRotation.CloudflareApiToken]: TCloudflareApiTokenRotationGeneratedCredentialsResponse;
};
// Unified type for local account reconciliation (Unix/Linux, Windows, and HP iLO)