Skip to content

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

Merge branch 'calvin/eng-5685-add-stripe-api-key-secret-rotation-integration' of https://github.com/Infisical/infisical into calvin/eng-5685-add-stripe-api-key-secret-rotation-integration

varonix001a458ce2b7
diff --cc backend/src/ee/services/secret-rotation-v2/stripe-api-key/stripe-api-key-rotation-fns.ts
index 990fa2d1b9,2e41dd4738..a7856b9a57
--- a/backend/src/ee/services/secret-rotation-v2/stripe-api-key/stripe-api-key-rotation-fns.ts
+++ b/backend/src/ee/services/secret-rotation-v2/stripe-api-key/stripe-api-key-rotation-fns.ts
@@@ -32,23 -32,24 +32,24 @@@ const STRIPE_KEY_NAME_MAX_LENGTH = 100
export const stripeApiKeyRotationFactory: TRotationFactory<
TStripeApiKeyRotationWithConnection,
TStripeApiKeyRotationGeneratedCredentials
- > = (secretRotation, appConnectionDAL, kmsService) => {
+ > = (secretRotation, appConnectionDAL, kmsService, _gatewayV2Service, _gatewayPoolService, keyStore) => {
const {
connection,
- parameters: { permissions, connectPermissions },
+ parameters: { permissions, keyName },
secretsMapping
} = secretRotation;
const { accountId } = connection.credentials;
+ // The default name leaves out the mapped secret's name, which would otherwise show in the Stripe
+ // dashboard. The timestamp keeps the old and new key apart while both are live, and is what makes
+ // a key stranded by a timed-out create identifiable there.
+ const $keyName = () => `${keyName ?? `infisical-managed`}-${Date.now()}`.slice(0, STRIPE_KEY_NAME_MAX_LENGTH);
// Runs once at the start of each operation, not per request, so the cleanup a failed operation
// does (expiring a key it just created) never fails on authorization half way through.
- const $assertAuthorized = () => assertStripeConnectionAuthorized(connection.id, appConnectionDAL, kmsService);
+ const $assertAuthorized = () =>
+ assertStripeConnectionAuthorized(connection.id, { appConnectionDAL, kmsService, keyStore });
- // The factory is built without an id at create time, so the name comes from the mapped secret.
- // It is what makes a key stranded by a timed-out create identifiable in the Stripe dashboard.
- const $keyName = () => `infisical-${secretsMapping.apiKey}-${Date.now()}`.slice(0, STRIPE_KEY_NAME_MAX_LENGTH);
-
/** No 404 on a double expire has ever been observed, so a non-404 failure on retiring a key that
* was already expired can't be told apart from a real failure by status code alone. This is only
* ever consulted after the expire call itself has failed, to check whether the key was already