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(secret-rotation): add Stripe API key rotation schemas
Calvin5ca583452038
diff --git a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-enums.ts b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-enums.tsindex 272a640ea0..57fd9fa339 100644--- a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-enums.ts+++ b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-enums.ts@@ -26,7 +26,8 @@ export enum SecretRotation {FireworksApiKey = "fireworks-api-key",SnowflakeUserKeyPair = "snowflake-user-key-pair",CloudflareApiToken = "cloudflare-api-token",- CloudflareR2AccessKey = "cloudflare-r2-access-key"+ CloudflareR2AccessKey = "cloudflare-r2-access-key",+ StripeApiKey = "stripe-api-key"}export enum SecretRotationStatus {diff --git a/backend/src/ee/services/secret-rotation-v2/stripe-api-key/index.ts b/backend/src/ee/services/secret-rotation-v2/stripe-api-key/index.tsnew file mode 100644index 0000000000..befda78a98--- /dev/null+++ b/backend/src/ee/services/secret-rotation-v2/stripe-api-key/index.ts@@ -0,0 +1,3 @@+export * from "./stripe-api-key-rotation-constants";+export * from "./stripe-api-key-rotation-schemas";+export * from "./stripe-api-key-rotation-types";diff --git a/backend/src/ee/services/secret-rotation-v2/stripe-api-key/stripe-api-key-rotation-constants.ts b/backend/src/ee/services/secret-rotation-v2/stripe-api-key/stripe-api-key-rotation-constants.tsnew file mode 100644index 0000000000..7dcfe8bd31--- /dev/null+++ b/backend/src/ee/services/secret-rotation-v2/stripe-api-key/stripe-api-key-rotation-constants.ts@@ -0,0 +1,183 @@+import { SecretRotation } from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-enums";+import { TSecretRotationV2ListItem } from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-types";+import { AppConnection } from "@app/services/app-connection/app-connection-enums";++/**+ * Every permission the Managed API Keys API accepts. There is no wildcard, no unrestricted key type+ * and no endpoint that lists these, so full access means naming all 158. Verified by probing each+ * one against a gated sandbox.+ */+export const STRIPE_API_KEY_PERMISSIONS = [+ "account_link_write",+ "adjustment_read",+ "api_key_write",+ "apple_pay_domain_read",+ "apple_pay_domain_write",+ "application_fee_read",+ "application_fee_write",+ "balance_read",+ "balance_transaction_source_read",+ "billing_analytics_meter_usage_read",+ "billing_clock_read",+ "billing_clock_write",+ "billing_intent_read",+ "billing_meter_event_read",+ "billing_meter_event_write",+ "billing_meter_read",+ "billing_meter_write",+ "billing_profile_read",+ "billing_profile_write",+ "billing_settings_read",+ "billing_settings_write",+ "capital_for_platforms_financing_offer_read",+ "capital_for_platforms_financing_offer_write",+ "capital_for_platforms_financing_summary_read",+ "capital_for_platforms_financing_transaction_read",+ "charge_read",+ "charge_write",+ "checkout_session_read",+ "checkout_session_write",+ "confirmation_token_client_read",+ "confirmation_token_client_write",+ "confirmation_token_read",+ "connected_account_read",+ "coupon_read",+ "coupon_write",+ "credit_note_read",+ "credit_note_write",+ "customer_portal_read",+ "customer_portal_write",+ "customer_read",+ "customer_session_read",+ "customer_session_write",+ "customer_write",+ "dispute_read",+ "dispute_write",+ "edit_link_write",+ "entitlement_read",+ "event_read",+ "fee_domain_resources_read",+ "file_read",+ "file_write",+ "financial_account_read",+ "inbound_transfer_read",+ "invoice_read",+ "invoice_write",+ "issuing_authorization_read",+ "issuing_authorization_write",+ "issuing_card_read",+ "issuing_card_write",+ "issuing_cardholder_read",+ "issuing_cardholder_write",+ "issuing_credit_ledger_read",+ "issuing_credit_ledger_write",+ "issuing_dispute_read",+ "issuing_dispute_write",+ "issuing_read",+ "issuing_token_network_data_read",+ "issuing_token_read",+ "issuing_token_write",+ "issuing_transaction_read",+ "issuing_transaction_write",+ "issuing_verification_write",+ "issuing_write",+ "mandate_read",+ "mandate_write",+ "order_read",+ "order_write",+ "outbound_payment_read",+ "outbound_transfer_read",+ "payment_intent_read",+ "payment_intent_write",+ "payment_links_read",+ "payment_links_write",+ "payment_method_configurations_read",+ "payment_method_configurations_write",+ "payment_method_domain_read",+ "payment_method_domain_write",+ "payment_method_read",+ "payment_method_write",+ "payment_records_read",+ "payment_records_write",+ "payout_intent_read",+ "payout_read",+ "payout_write",+ "plan_read",+ "plan_write",+ "product_catalog_import_read",+ "product_catalog_import_write",+ "product_read",+ "product_write",+ "promotion_code_read",+ "promotion_code_write",+ "provisioning_account_request_read",+ "provisioning_account_request_write",+ "provisioning_project_read",+ "provisioning_project_write",+ "provisioning_resource_read",+ "provisioning_resource_write",+ "quote_read",+ "quote_write",+ "rate_card_subscription_write",+ "rate_card_write",+ "received_credit_read",+ "received_debit_read",+ "recipient_verification_read",+ "report_runs_and_report_types_read",+ "report_runs_and_report_types_write",+ "review_read",+ "review_write",+ "secret_read",+ "secret_write",+ "setup_intent_read",+ "setup_intent_write",+ "shipping_rate_read",+ "shipping_rate_write",+ "sku_read",+ "sku_write",+ "source_read",+ "source_write",+ "subscription_read",+ "subscription_write",+ "tax_calculations_and_transactions_read",+ "tax_calculations_and_transactions_write",+ "tax_locations_read",+ "tax_locations_write",+ "tax_rate_read",+ "tax_rate_write",+ "tax_settings_read",+ "tax_settings_write",+ "terminal_configuration_read",+ "terminal_configuration_write",+ "terminal_connection_token_write",+ "terminal_location_read",+ "terminal_location_write",+ "terminal_reader_read",+ "terminal_reader_write",+ "token_read",+ "token_write",+ "top_up_read",+ "top_up_write",+ "transaction_read",+ "transfer_read",+ "transfer_write",+ "treasury_transaction_read",+ "usage_record_read",+ "usage_record_write",+ "webhook_read",+ "webhook_write"+] as const;++export const STRIPE_API_KEY_ROTATION_LIST_OPTION: TSecretRotationV2ListItem = {+ name: "Stripe API Key",+ type: SecretRotation.StripeApiKey,+ connection: AppConnection.Stripe,+ template: {+ secretsMapping: {+ apiKey: "STRIPE_API_KEY"+ },+ // The frontend picker reads the permission names from here. It cannot import this file, since+ // the frontend is a separate package, and Stripe has no endpoint that lists them.+ permissions: [...STRIPE_API_KEY_PERMISSIONS]+ }+};diff --git a/backend/src/ee/services/secret-rotation-v2/stripe-api-key/stripe-api-key-rotation-schemas.ts b/backend/src/ee/services/secret-rotation-v2/stripe-api-key/stripe-api-key-rotation-schemas.tsnew file mode 100644index 0000000000..9c1649fea2--- /dev/null+++ b/backend/src/ee/services/secret-rotation-v2/stripe-api-key/stripe-api-key-rotation-schemas.ts@@ -0,0 +1,69 @@+import { z } from "zod";++import { SecretRotation } from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-enums";+import {+ BaseCreateSecretRotationSchema,+ BaseSecretRotationSchema,+ BaseUpdateSecretRotationSchema+} from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-schemas";+import { SecretRotations } from "@app/lib/api-docs";+import { SecretNameSchema } from "@app/server/lib/schemas";+import { AppConnection } from "@app/services/app-connection/app-connection-enums";++import { STRIPE_API_KEY_PERMISSIONS } from "./stripe-api-key-rotation-constants";++export const StripeApiKeyPermissionSchema = z.enum(STRIPE_API_KEY_PERMISSIONS);++export const StripeApiKeyRotationGeneratedCredentialsSchema = z+ .object({+ keyId: z.string(),+ apiKey: z.string()+ })+ .array()+ .min(1)+ .max(2);++const StripeApiKeyRotationParametersSchema = z.object({+ permissions: StripeApiKeyPermissionSchema.array()+ .min(1, "At least one permission is required")+ .max(STRIPE_API_KEY_PERMISSIONS.length)+ .describe(SecretRotations.PARAMETERS.STRIPE_API_KEY.permissions),+ connectPermissions: StripeApiKeyPermissionSchema.array()+ .max(STRIPE_API_KEY_PERMISSIONS.length)+ .optional()+ .describe(SecretRotations.PARAMETERS.STRIPE_API_KEY.connectPermissions)+});++const StripeApiKeyRotationSecretsMappingSchema = z.object({+ apiKey: SecretNameSchema.describe(SecretRotations.SECRETS_MAPPING.STRIPE_API_KEY.apiKey)+});++export const StripeApiKeyRotationTemplateSchema = z.object({+ secretsMapping: z.object({+ apiKey: z.string()+ }),+ permissions: z.string().array()+});++export const StripeApiKeyRotationSchema = BaseSecretRotationSchema(SecretRotation.StripeApiKey).extend({+ type: z.literal(SecretRotation.StripeApiKey),+ parameters: StripeApiKeyRotationParametersSchema,+ secretsMapping: StripeApiKeyRotationSecretsMappingSchema+});++export const CreateStripeApiKeyRotationSchema = BaseCreateSecretRotationSchema(SecretRotation.StripeApiKey).extend({+ parameters: StripeApiKeyRotationParametersSchema,+ secretsMapping: StripeApiKeyRotationSecretsMappingSchema+});++export const UpdateStripeApiKeyRotationSchema = BaseUpdateSecretRotationSchema(SecretRotation.StripeApiKey).extend({+ parameters: StripeApiKeyRotationParametersSchema.optional(),+ secretsMapping: StripeApiKeyRotationSecretsMappingSchema.optional()+});++export const StripeApiKeyRotationListItemSchema = z.object({+ name: z.literal("Stripe API Key"),+ connection: z.literal(AppConnection.Stripe),+ type: z.literal(SecretRotation.StripeApiKey),+ template: StripeApiKeyRotationTemplateSchema+});diff --git a/backend/src/ee/services/secret-rotation-v2/stripe-api-key/stripe-api-key-rotation-types.ts b/backend/src/ee/services/secret-rotation-v2/stripe-api-key/stripe-api-key-rotation-types.tsnew file mode 100644index 0000000000..5cfed76187--- /dev/null+++ b/backend/src/ee/services/secret-rotation-v2/stripe-api-key/stripe-api-key-rotation-types.ts@@ -0,0 +1,28 @@+import { z } from "zod";++import { TStripeConnection } from "@app/services/app-connection/stripe";++import { TStripeSecretKeyField } from "./stripe-api-key-jwe";+import {+ CreateStripeApiKeyRotationSchema,+ StripeApiKeyRotationGeneratedCredentialsSchema,+ StripeApiKeyRotationListItemSchema,+ StripeApiKeyRotationSchema+} from "./stripe-api-key-rotation-schemas";++export type TStripeApiKeyRotation = z.infer<typeof StripeApiKeyRotationSchema>;++export type TStripeApiKeyRotationInput = z.infer<typeof CreateStripeApiKeyRotationSchema>;++export type TStripeApiKeyRotationListItem = z.infer<typeof StripeApiKeyRotationListItemSchema>;++export type TStripeApiKeyRotationWithConnection = TStripeApiKeyRotation & {+ connection: TStripeConnection;+};++export type TStripeApiKeyRotationGeneratedCredentials = z.infer<typeof StripeApiKeyRotationGeneratedCredentialsSchema>;++export type TStripeApiKeyCreateResponse = {+ id?: string;+ secret_key?: TStripeSecretKeyField;+};diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.tsindex c71bf0321f..285a77b134 100644--- a/backend/src/lib/api-docs/constants.ts+++ b/backend/src/lib/api-docs/constants.ts@@ -3647,6 +3647,12 @@ export const SecretRotations = {username:"The Snowflake user whose RSA key pair will be rotated. If the user does not exist, it is created as a key-pair-only SERVICE user.",modulusLength: "The modulus length in bits of the generated RSA key pairs. Defaults to 2048."+ },+ STRIPE_API_KEY: {+ permissions:+ "The permissions granted to the generated Stripe API key. Stripe has no wildcard permission, so this is the full list of what the key may do.",+ connectPermissions:+ "The permissions the generated Stripe API key has over connected accounts. Only meaningful when the account is a Connect platform."}},SECRETS_MAPPING: {@@ -3746,6 +3752,9 @@ export const SecretRotations = {SNOWFLAKE_USER_KEY_PAIR: {privateKey: "The name of the secret that the generated RSA private key (PKCS#8 PEM) will be mapped to.",publicKey: "The name of the secret that the generated RSA public key (SPKI PEM) will be mapped to."+ },+ STRIPE_API_KEY: {+ apiKey: "The name of the secret that the rotated Stripe API key will be mapped to."}}};