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 GCP Service Account Key rotation support
Dimitris Staratzis204bb6bebba1
diff --git a/backend/src/ee/routes/v2/secret-rotation-v2-routers/gcp-service-account-key-rotation-router.ts b/backend/src/ee/routes/v2/secret-rotation-v2-routers/gcp-service-account-key-rotation-router.tsnew file mode 100644index 0000000000..d1447cf3f7--- /dev/null+++ b/backend/src/ee/routes/v2/secret-rotation-v2-routers/gcp-service-account-key-rotation-router.ts@@ -0,0 +1,19 @@+import {+ CreateGcpServiceAccountKeyRotationSchema,+ GcpServiceAccountKeyRotationGeneratedCredentialsSchema,+ GcpServiceAccountKeyRotationSchema,+ UpdateGcpServiceAccountKeyRotationSchema+} from "@app/ee/services/secret-rotation-v2/gcp-service-account-key";+import { SecretRotation } from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-enums";++import { registerSecretRotationEndpoints } from "./secret-rotation-v2-endpoints";++export const registerGcpServiceAccountKeyRotationRouter = async (server: FastifyZodProvider) =>+ registerSecretRotationEndpoints({+ type: SecretRotation.GcpServiceAccountKey,+ server,+ responseSchema: GcpServiceAccountKeyRotationSchema,+ createSchema: CreateGcpServiceAccountKeyRotationSchema,+ updateSchema: UpdateGcpServiceAccountKeyRotationSchema,+ generatedCredentialsSchema: GcpServiceAccountKeyRotationGeneratedCredentialsSchema+ });diff --git a/backend/src/ee/routes/v2/secret-rotation-v2-routers/index.ts b/backend/src/ee/routes/v2/secret-rotation-v2-routers/index.tsindex 8184295ba6..d5b7964f27 100644--- a/backend/src/ee/routes/v2/secret-rotation-v2-routers/index.ts+++ b/backend/src/ee/routes/v2/secret-rotation-v2-routers/index.ts@@ -11,6 +11,7 @@ import { registerDatadogApiKeyRotationRouter } from "./datadog-api-key-rotation-import { registerDatadogApplicationKeySecretRotationRouter } from "./datadog-application-key-secret-rotation-router";import { registerDbtServiceTokenRotationRouter } from "./dbt-service-token-rotation-router";import { registerFireworksApiKeyRotationRouter } from "./fireworks-api-key-rotation-router";+import { registerGcpServiceAccountKeyRotationRouter } from "./gcp-service-account-key-rotation-router";import { registerHpIloRotationRouter } from "./hp-ilo-rotation-router";import { registerLdapPasswordRotationRouter } from "./ldap-password-rotation-router";import { registerLiteLLMApiKeyRotationRouter } from "./litellm-api-key-rotation-router";@@ -64,5 +65,6 @@ export const SECRET_ROTATION_REGISTER_ROUTER_MAP: Record<[SecretRotation.SnowflakeUserKeyPair]: registerSnowflakeUserKeyPairRotationRouter,[SecretRotation.CloudflareApiToken]: registerCloudflareApiTokenRotationRouter,[SecretRotation.CloudflareR2AccessKey]: registerCloudflareR2AccessKeyRotationRouter,- [SecretRotation.StripeApiKey]: registerStripeApiKeyRotationRouter+ [SecretRotation.StripeApiKey]: registerStripeApiKeyRotationRouter,+ [SecretRotation.GcpServiceAccountKey]: registerGcpServiceAccountKeyRotationRouter};diff --git a/backend/src/ee/routes/v2/secret-rotation-v2-routers/secret-rotation-v2-router.ts b/backend/src/ee/routes/v2/secret-rotation-v2-routers/secret-rotation-v2-router.tsindex ca11302386..2833bd8980 100644--- a/backend/src/ee/routes/v2/secret-rotation-v2-routers/secret-rotation-v2-router.ts+++ b/backend/src/ee/routes/v2/secret-rotation-v2-routers/secret-rotation-v2-router.ts@@ -12,6 +12,7 @@ import { DatadogApiKeyRotationListItemSchema } from "@app/ee/services/secret-rotimport { DatadogApplicationKeySecretRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/datadog-application-key-secret";import { DbtServiceTokenRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/dbt-service-token";import { FireworksApiKeyRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/fireworks-api-key";+import { GcpServiceAccountKeyRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/gcp-service-account-key";import { HpIloRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/hp-ilo-rotation";import { LdapPasswordRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/ldap-password";import { LiteLLMApiKeyRotationListItemSchema } from "@app/ee/services/secret-rotation-v2/litellm-api-key";@@ -65,7 +66,8 @@ const SecretRotationV2OptionsSchema = z.discriminatedUnion("type", [SnowflakeUserKeyPairRotationListItemSchema,CloudflareApiTokenRotationListItemSchema,CloudflareR2AccessKeyRotationListItemSchema,- StripeApiKeyRotationListItemSchema+ StripeApiKeyRotationListItemSchema,+ GcpServiceAccountKeyRotationListItemSchema]);export const registerSecretRotationV2Router = async (server: FastifyZodProvider) => {diff --git a/backend/src/ee/services/secret-rotation-v2/gcp-service-account-key/gcp-service-account-key-rotation-constants.ts b/backend/src/ee/services/secret-rotation-v2/gcp-service-account-key/gcp-service-account-key-rotation-constants.tsnew file mode 100644index 0000000000..468ab06c77--- /dev/null+++ b/backend/src/ee/services/secret-rotation-v2/gcp-service-account-key/gcp-service-account-key-rotation-constants.ts@@ -0,0 +1,14 @@+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";++export const GCP_SERVICE_ACCOUNT_KEY_ROTATION_LIST_OPTION: TSecretRotationV2ListItem = {+ name: "GCP Service Account Key",+ type: SecretRotation.GcpServiceAccountKey,+ connection: AppConnection.GCP,+ template: {+ secretsMapping: {+ serviceAccountKey: "GCP_SERVICE_ACCOUNT_KEY"+ }+ }+};diff --git a/backend/src/ee/services/secret-rotation-v2/gcp-service-account-key/gcp-service-account-key-rotation-fns.ts b/backend/src/ee/services/secret-rotation-v2/gcp-service-account-key/gcp-service-account-key-rotation-fns.tsnew file mode 100644index 0000000000..d473a19769--- /dev/null+++ b/backend/src/ee/services/secret-rotation-v2/gcp-service-account-key/gcp-service-account-key-rotation-fns.ts@@ -0,0 +1,280 @@+import { AxiosError } from "axios";+import { JWT } from "google-auth-library";++import {+ TRotationFactory,+ TRotationFactoryCheckActiveCredentials,+ TRotationFactoryGetSecretsPayload,+ TRotationFactoryIssueCredentials,+ TRotationFactoryRevokeCredentials,+ TRotationFactoryRotateCredentials+} from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-types";+import { request } from "@app/lib/config/request";+import { delay } from "@app/lib/delay";+import { BadRequestError } from "@app/lib/errors";+import { logger } from "@app/lib/logger";+import { getGcpConnectionAuthToken } from "@app/services/app-connection/gcp";+import { IntegrationUrls } from "@app/services/integration-auth/integration-list";++import {+ TGcpServiceAccountKeyCreateResponse,+ TGcpServiceAccountKeyFile,+ TGcpServiceAccountKeyRotationGeneratedCredentials,+ TGcpServiceAccountKeyRotationWithConnection+} from "./gcp-service-account-key-rotation-types";++// GCP documents that a new key can take 60 seconds or more before it is accepted, but the rotation+// holds a 60 second lock, so polling stops well short of that and the attempt fails instead.+const KEY_VERIFICATION_MAX_ATTEMPTS = 12;+const KEY_VERIFICATION_INTERVAL_MS = 3000;++type TGoogleApiError = {+ error?: { status?: string; message?: string };+};++const getGoogleApiError = (error: unknown) =>+ error instanceof AxiosError ? (error.response?.data as TGoogleApiError | undefined)?.error : undefined;++const getErrorMessage = (error: unknown): string => {+ if (error instanceof AxiosError) return getGoogleApiError(error)?.message ?? error.message;++ return error instanceof Error ? error.message : "Unknown error";+};++const getErrorStatus = (error: unknown) => (error instanceof AxiosError ? error.response?.status : undefined);++export const gcpServiceAccountKeyRotationFactory: TRotationFactory<+ TGcpServiceAccountKeyRotationWithConnection,+ TGcpServiceAccountKeyRotationGeneratedCredentials+> = (secretRotation) => {+ const {+ connection,+ parameters: { serviceAccountEmail },+ secretsMapping+ } = secretRotation;++ const keysUrl = `${IntegrationUrls.GCP_IAM_URL}/v1/projects/-/serviceAccounts/${encodeURIComponent(serviceAccountEmail)}/keys`;++ const $getRequestConfig = (accessToken: string) => ({+ headers: {+ Authorization: `Bearer ${accessToken}`,+ "Content-Type": "application/json"+ }+ });++ const $toKeyManagementError = (error: unknown, action: string) => {+ const message = getErrorMessage(error);+ const status = getErrorStatus(error);++ if (status === 403) {+ if (message.includes("has not been used in project") || message.includes("is disabled")) {+ return new BadRequestError({+ message: `Failed to ${action}: the Identity and Access Management (IAM) API is not enabled on the GCP project of the connection's service account. Enable it in the Google Cloud console and try again.`+ });+ }++ return new BadRequestError({+ message: `Failed to ${action}: the connection's service account is not allowed to manage keys of GCP service account "${serviceAccountEmail}". Grant it the Service Account Key Admin role (roles/iam.serviceAccountKeyAdmin) on that service account and try again.`+ });+ }++ if (status === 404) {+ return new BadRequestError({+ message: `Failed to ${action}: GCP service account "${serviceAccountEmail}" was not found.`+ });+ }++ if (getGoogleApiError(error)?.status === "FAILED_PRECONDITION") {+ return new BadRequestError({+ message: `Failed to ${action}: ${message} This usually means GCP service account "${serviceAccountEmail}" already has the maximum of 10 keys, or an organization policy (iam.disableServiceAccountKeyCreation) blocks key creation.`+ });+ }++ return new BadRequestError({ message: `Failed to ${action}: ${message}` });+ };++ const $deleteKey = async (accessToken: string, keyId: string) => {+ try {+ await request.delete(`${keysUrl}/${encodeURIComponent(keyId)}`, $getRequestConfig(accessToken));+ } catch (error) {+ // The key is already gone, e.g. deleted by hand in the console or by an earlier attempt.+ if (getErrorStatus(error) === 404) return;++ throw $toKeyManagementError(error, `delete key "${keyId}" of GCP service account "${serviceAccountEmail}"`);+ }+ };++ /**+ * A key exists in GCP before the rotation row records it, so anything that fails after the key is+ * created has to delete it, or it is left behind untracked and counts toward GCP's 10 key limit.+ */+ const $deleteOnFailure = async <T>(accessToken: string, keyId: string, action: () => Promise<T>): Promise<T> => {+ try {+ return await action();+ } catch (actionError) {+ try {+ await $deleteKey(accessToken, keyId);+ } catch (cleanupError) {+ throw new BadRequestError({+ message: `${getErrorMessage(actionError)} The new key "${keyId}" could not be deleted and may need to be removed manually from GCP service account "${serviceAccountEmail}": ${getErrorMessage(cleanupError)}`+ });+ }++ throw actionError;+ }+ };++ const $authenticateWithKey = async (serviceAccountKey: string) => {+ let keyFile: TGcpServiceAccountKeyFile;++ try {+ keyFile = JSON.parse(serviceAccountKey) as TGcpServiceAccountKeyFile;+ } catch {+ // the parse error can quote part of the input, which here is the private key+ throw new BadRequestError({ message: "The service account key is not valid JSON." });+ }++ await new JWT({+ email: keyFile.client_email,+ key: keyFile.private_key,+ scopes: [IntegrationUrls.GCP_CLOUD_PLATFORM_SCOPE]+ }).authorize();+ };++ // Apps read the mapped secret as soon as it changes, so a scheduled rotation only publishes a key once GCP+ // accepts it. Rotations run from an HTTP request skip this, so the wait never holds a request open.+ const $waitUntilKeyAccepted = async (keyId: string, serviceAccountKey: string) => {+ let lastError: unknown;++ for (let attempt = 1; attempt <= KEY_VERIFICATION_MAX_ATTEMPTS; attempt += 1) {+ try {+ // eslint-disable-next-line no-await-in-loop+ await $authenticateWithKey(serviceAccountKey);++ if (attempt > 1) {+ logger.info(+ `secretRotation: GCP accepted new service account key [serviceAccountEmail=${serviceAccountEmail}] [keyId=${keyId}] [attempt=${attempt}]`+ );+ }++ return;+ } catch (error) {+ lastError = error;+ }++ // eslint-disable-next-line no-await-in-loop+ if (attempt < KEY_VERIFICATION_MAX_ATTEMPTS) await delay(KEY_VERIFICATION_INTERVAL_MS);+ }++ throw new BadRequestError({+ message: `GCP did not accept the new key "${keyId}" for service account "${serviceAccountEmail}" in time: ${getErrorMessage(lastError)}`+ });+ };++ const $createKey = async (accessToken: string, shouldWaitUntilAccepted: boolean) => {+ let data: TGcpServiceAccountKeyCreateResponse;++ try {+ ({ data } = await request.post<TGcpServiceAccountKeyCreateResponse>(keysUrl, {}, $getRequestConfig(accessToken)));+ } catch (error) {+ throw $toKeyManagementError(error, `create a key for GCP service account "${serviceAccountEmail}"`);+ }++ const keyId = data?.name?.split("/").pop();++ if (!keyId) {+ throw new BadRequestError({+ message: `GCP did not return an ID for the new key of service account "${serviceAccountEmail}".`+ });+ }++ return $deleteOnFailure(accessToken, keyId, async () => {+ if (!data.privateKeyData) {+ throw new BadRequestError({+ message: `GCP did not return the private key for the new key "${keyId}" of service account "${serviceAccountEmail}".`+ });+ }++ const serviceAccountKey = Buffer.from(data.privateKeyData, "base64").toString("utf8");++ if (shouldWaitUntilAccepted) await $waitUntilKeyAccepted(keyId, serviceAccountKey);++ return { keyId, serviceAccountKey };+ });+ };++ const issueCredentials: TRotationFactoryIssueCredentials<TGcpServiceAccountKeyRotationGeneratedCredentials> = async (+ callback+ ) => {+ const accessToken = await getGcpConnectionAuthToken(connection);++ // creating a rotation always runs inside an HTTP request+ const credentials = await $createKey(accessToken, false);++ return $deleteOnFailure(accessToken, credentials.keyId, () => callback(credentials));+ };++ const revokeCredentials: TRotationFactoryRevokeCredentials<+ TGcpServiceAccountKeyRotationGeneratedCredentials+ > = async (credentials, callback) => {+ if (!credentials?.length) return callback();++ const accessToken = await getGcpConnectionAuthToken(connection);++ // The key apps are using is deleted last, so a failure part way through leaves the rotation and its+ // secret in place with a key that still works, rather than one that is already gone.+ const { activeIndex } = secretRotation;+ const deletionOrder = [+ ...credentials.filter((_, index) => index !== activeIndex),+ ...credentials.filter((_, index) => index === activeIndex)+ ];++ for await (const { keyId } of deletionOrder) {+ await $deleteKey(accessToken, keyId);+ }++ return callback();+ };++ const rotateCredentials: TRotationFactoryRotateCredentials<+ TGcpServiceAccountKeyRotationGeneratedCredentials+ > = async (credentialsToRevoke, callback, _activeCredentials, options) => {+ const accessToken = await getGcpConnectionAuthToken(connection);++ const newCredentials = await $createKey(accessToken, Boolean(options?.isBackgroundJob));++ // Delete before committing, so a failure leaves GCP and the rotation agreeing with each other and the+ // new key is cleaned up rather than left untracked across retries.+ if (credentialsToRevoke?.keyId) {+ await $deleteOnFailure(accessToken, newCredentials.keyId, () =>+ $deleteKey(accessToken, credentialsToRevoke.keyId)+ );+ }++ return $deleteOnFailure(accessToken, newCredentials.keyId, () => callback(newCredentials));+ };++ const getSecretsPayload: TRotationFactoryGetSecretsPayload<TGcpServiceAccountKeyRotationGeneratedCredentials> = ({+ serviceAccountKey+ }) => [{ key: secretsMapping.serviceAccountKey, value: serviceAccountKey }];++ const checkActiveCredentials: TRotationFactoryCheckActiveCredentials<+ TGcpServiceAccountKeyRotationGeneratedCredentials+ > = async ({ keyId, serviceAccountKey }) => {+ try {+ await $authenticateWithKey(serviceAccountKey);+ } catch (error) {+ throw new BadRequestError({+ message: `GCP rejected key "${keyId}" of service account "${serviceAccountEmail}": ${getErrorMessage(error)}`+ });+ }+ };++ return {+ issueCredentials,+ revokeCredentials,+ rotateCredentials,+ getSecretsPayload,+ checkActiveCredentials+ };+};diff --git a/backend/src/ee/services/secret-rotation-v2/gcp-service-account-key/gcp-service-account-key-rotation-schemas.ts b/backend/src/ee/services/secret-rotation-v2/gcp-service-account-key/gcp-service-account-key-rotation-schemas.tsnew file mode 100644index 0000000000..5a281e276f--- /dev/null+++ b/backend/src/ee/services/secret-rotation-v2/gcp-service-account-key/gcp-service-account-key-rotation-schemas.ts@@ -0,0 +1,74 @@+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";++export const GCP_SERVICE_ACCOUNT_EMAIL_MAX_LENGTH = 254;++export const GcpServiceAccountKeyRotationGeneratedCredentialsSchema = z+ .object({+ keyId: z.string(),+ serviceAccountKey: z.string()+ })+ .array()+ .min(1)+ .max(2);++const GcpServiceAccountKeyRotationParametersSchema = z.object({+ serviceAccountEmail: z+ .string()+ .trim()+ .min(1, "Service account email required")+ .max(+ GCP_SERVICE_ACCOUNT_EMAIL_MAX_LENGTH,+ `Service account email must be ${GCP_SERVICE_ACCOUNT_EMAIL_MAX_LENGTH} characters or fewer`+ )+ .email("Service account email must be a valid email address")+ .describe(SecretRotations.PARAMETERS.GCP_SERVICE_ACCOUNT_KEY.serviceAccountEmail)+});++const GcpServiceAccountKeyRotationSecretsMappingSchema = z.object({+ serviceAccountKey: SecretNameSchema.describe(+ SecretRotations.SECRETS_MAPPING.GCP_SERVICE_ACCOUNT_KEY.serviceAccountKey+ )+});++export const GcpServiceAccountKeyRotationTemplateSchema = z.object({+ secretsMapping: z.object({+ serviceAccountKey: z.string()+ })+});++export const GcpServiceAccountKeyRotationSchema = BaseSecretRotationSchema(SecretRotation.GcpServiceAccountKey).extend({+ type: z.literal(SecretRotation.GcpServiceAccountKey),+ parameters: GcpServiceAccountKeyRotationParametersSchema,+ secretsMapping: GcpServiceAccountKeyRotationSecretsMappingSchema+});++export const CreateGcpServiceAccountKeyRotationSchema = BaseCreateSecretRotationSchema(+ SecretRotation.GcpServiceAccountKey+).extend({+ parameters: GcpServiceAccountKeyRotationParametersSchema,+ secretsMapping: GcpServiceAccountKeyRotationSecretsMappingSchema+});++export const UpdateGcpServiceAccountKeyRotationSchema = BaseUpdateSecretRotationSchema(+ SecretRotation.GcpServiceAccountKey+).extend({+ parameters: GcpServiceAccountKeyRotationParametersSchema.optional(),+ secretsMapping: GcpServiceAccountKeyRotationSecretsMappingSchema.optional()+});++export const GcpServiceAccountKeyRotationListItemSchema = z.object({+ name: z.literal("GCP Service Account Key"),+ connection: z.literal(AppConnection.GCP),+ type: z.literal(SecretRotation.GcpServiceAccountKey),+ template: GcpServiceAccountKeyRotationTemplateSchema+});diff --git a/backend/src/ee/services/secret-rotation-v2/gcp-service-account-key/gcp-service-account-key-rotation-types.ts b/backend/src/ee/services/secret-rotation-v2/gcp-service-account-key/gcp-service-account-key-rotation-types.tsnew file mode 100644index 0000000000..dd058a5c81--- /dev/null+++ b/backend/src/ee/services/secret-rotation-v2/gcp-service-account-key/gcp-service-account-key-rotation-types.ts@@ -0,0 +1,36 @@+import { z } from "zod";++import { TGcpConnection } from "@app/services/app-connection/gcp";++import {+ CreateGcpServiceAccountKeyRotationSchema,+ GcpServiceAccountKeyRotationGeneratedCredentialsSchema,+ GcpServiceAccountKeyRotationListItemSchema,+ GcpServiceAccountKeyRotationSchema+} from "./gcp-service-account-key-rotation-schemas";++export type TGcpServiceAccountKeyRotation = z.infer<typeof GcpServiceAccountKeyRotationSchema>;++export type TGcpServiceAccountKeyRotationInput = z.infer<typeof CreateGcpServiceAccountKeyRotationSchema>;++export type TGcpServiceAccountKeyRotationListItem = z.infer<typeof GcpServiceAccountKeyRotationListItemSchema>;++export type TGcpServiceAccountKeyRotationWithConnection = TGcpServiceAccountKeyRotation & {+ connection: TGcpConnection;+};++export type TGcpServiceAccountKeyRotationGeneratedCredentials = z.infer<+ typeof GcpServiceAccountKeyRotationGeneratedCredentialsSchema+>;++export type TGcpServiceAccountKeyCreateResponse = {+ // projects/{projectId}/serviceAccounts/{email}/keys/{keyId}+ name?: string;+ // base64 of the JSON key file+ privateKeyData?: string;+};++export type TGcpServiceAccountKeyFile = {+ client_email: string;+ private_key: string;+};diff --git a/backend/src/ee/services/secret-rotation-v2/gcp-service-account-key/index.ts b/backend/src/ee/services/secret-rotation-v2/gcp-service-account-key/index.tsnew file mode 100644index 0000000000..bb7d18b039--- /dev/null+++ b/backend/src/ee/services/secret-rotation-v2/gcp-service-account-key/index.ts@@ -0,0 +1,3 @@+export * from "./gcp-service-account-key-rotation-constants";+export * from "./gcp-service-account-key-rotation-schemas";+export * from "./gcp-service-account-key-rotation-types";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 57fd9fa339..18ac53d8db 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@@ -27,7 +27,8 @@ export enum SecretRotation {SnowflakeUserKeyPair = "snowflake-user-key-pair",CloudflareApiToken = "cloudflare-api-token",CloudflareR2AccessKey = "cloudflare-r2-access-key",- StripeApiKey = "stripe-api-key"+ StripeApiKey = "stripe-api-key",+ GcpServiceAccountKey = "gcp-service-account-key"}export enum SecretRotationStatus {diff --git a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-fns.ts b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-fns.tsindex ef2489ff70..9ee8b9a805 100644--- a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-fns.ts+++ b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-fns.ts@@ -20,6 +20,7 @@ import {} from "./datadog-application-key-secret";import { DBT_SERVICE_TOKEN_ROTATION_LIST_OPTION } from "./dbt-service-token";import { FIREWORKS_API_KEY_ROTATION_LIST_OPTION } from "./fireworks-api-key";+import { GCP_SERVICE_ACCOUNT_KEY_ROTATION_LIST_OPTION, TGcpServiceAccountKeyRotation } from "./gcp-service-account-key";import { HP_ILO_ROTATION_LIST_OPTION, THpIloRotation } from "./hp-ilo-rotation";import { LDAP_PASSWORD_ROTATION_LIST_OPTION, TLdapPasswordRotation } from "./ldap-password";import { LITELLM_API_KEY_ROTATION_LIST_OPTION } from "./litellm-api-key";@@ -85,7 +86,8 @@ const SECRET_ROTATION_LIST_OPTIONS: Record<SecretRotation, TSecretRotationV2List[SecretRotation.SnowflakeUserKeyPair]: SNOWFLAKE_USER_KEY_PAIR_ROTATION_LIST_OPTION,[SecretRotation.CloudflareApiToken]: CLOUDFLARE_API_TOKEN_ROTATION_LIST_OPTION,[SecretRotation.CloudflareR2AccessKey]: CLOUDFLARE_R2_ACCESS_KEY_ROTATION_LIST_OPTION,- [SecretRotation.StripeApiKey]: STRIPE_API_KEY_ROTATION_LIST_OPTION+ [SecretRotation.StripeApiKey]: STRIPE_API_KEY_ROTATION_LIST_OPTION,+ [SecretRotation.GcpServiceAccountKey]: GCP_SERVICE_ACCOUNT_KEY_ROTATION_LIST_OPTION};export const listSecretRotationOptions = () => {@@ -430,6 +432,17 @@ export const throwOnImmutableParameterUpdate = (throw new BadRequestError({ message: "Cannot update username" });}break;+ case SecretRotation.GcpServiceAccountKey:+ if (+ haveUnequalProperties(+ updatePayload.parameters as TGcpServiceAccountKeyRotation["parameters"],+ secretRotation.parameters as TGcpServiceAccountKeyRotation["parameters"],+ ["serviceAccountEmail"]+ )+ ) {+ throw new BadRequestError({ message: "Cannot update service account email" });+ }+ break;default:// do nothing}diff --git a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-maps.ts b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-maps.tsindex 6e5feb9119..0e0a14ce69 100644--- a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-maps.ts+++ b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-maps.ts@@ -30,7 +30,8 @@ export const SECRET_ROTATION_NAME_MAP: Record<SecretRotation, string> = {[SecretRotation.SnowflakeUserKeyPair]: "Snowflake User Key Pair",[SecretRotation.CloudflareApiToken]: "Cloudflare API Token",[SecretRotation.CloudflareR2AccessKey]: "Cloudflare R2 Access Key",- [SecretRotation.StripeApiKey]: "Stripe API Key"+ [SecretRotation.StripeApiKey]: "Stripe API Key",+ [SecretRotation.GcpServiceAccountKey]: "GCP Service Account Key"};export const SECRET_ROTATION_CONNECTION_MAP: Record<SecretRotation, AppConnection> = {@@ -62,5 +63,6 @@ export const SECRET_ROTATION_CONNECTION_MAP: Record<SecretRotation, AppConnectio[SecretRotation.SnowflakeUserKeyPair]: AppConnection.Snowflake,[SecretRotation.CloudflareApiToken]: AppConnection.Cloudflare,[SecretRotation.CloudflareR2AccessKey]: AppConnection.Cloudflare,- [SecretRotation.StripeApiKey]: AppConnection.Stripe+ [SecretRotation.StripeApiKey]: AppConnection.Stripe,+ [SecretRotation.GcpServiceAccountKey]: AppConnection.GCP};diff --git a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-service.ts b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-service.tsindex 66d26c43e3..5beddb14f7 100644--- a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-service.ts+++ b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-service.ts@@ -21,6 +21,7 @@ import { databricksServicePrincipalSecretRotationFactory } from "@app/ee/serviceimport { datadogApiKeyRotationFactory } from "@app/ee/services/secret-rotation-v2/datadog-api-key/datadog-api-key-rotation-fns";import { datadogApplicationKeySecretRotationFactory } from "@app/ee/services/secret-rotation-v2/datadog-application-key-secret/datadog-application-key-secret-rotation-fns";import { fireworksApiKeyRotationFactory } from "@app/ee/services/secret-rotation-v2/fireworks-api-key/fireworks-api-key-rotation-fns";+import { gcpServiceAccountKeyRotationFactory } from "@app/ee/services/secret-rotation-v2/gcp-service-account-key/gcp-service-account-key-rotation-fns";import { ldapPasswordRotationFactory } from "@app/ee/services/secret-rotation-v2/ldap-password/ldap-password-rotation-fns";import { salesforceOauthCredentialsRotationFactory } from "@app/ee/services/secret-rotation-v2/salesforce-oauth-credentials/salesforce-oauth-credentials-rotation-fns";import { SecretRotation, SecretRotationStatus } from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-enums";@@ -219,7 +220,8 @@ const SECRET_ROTATION_FACTORY_MAP: Record<SecretRotation, TRotationFactoryImplem[SecretRotation.SnowflakeUserKeyPair]: snowflakeUserKeyPairRotationFactory as TRotationFactoryImplementation,[SecretRotation.CloudflareApiToken]: cloudflareApiTokenRotationFactory as TRotationFactoryImplementation,[SecretRotation.CloudflareR2AccessKey]: cloudflareR2AccessKeyRotationFactory as TRotationFactoryImplementation,- [SecretRotation.StripeApiKey]: stripeApiKeyRotationFactory as TRotationFactoryImplementation+ [SecretRotation.StripeApiKey]: stripeApiKeyRotationFactory as TRotationFactoryImplementation,+ [SecretRotation.GcpServiceAccountKey]: gcpServiceAccountKeyRotationFactory as TRotationFactoryImplementation};export const secretRotationV2ServiceFactory = ({@@ -1428,7 +1430,8 @@ export const secretRotationV2ServiceFactory = ({);});},- activeCredentials+ activeCredentials,+ { isBackgroundJob: Boolean(jobId) });await auditLogService.createAuditLog({diff --git a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-types.ts b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-types.tsindex 295f94cddd..c7406c399b 100644--- a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-types.ts+++ b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-types.ts@@ -86,6 +86,13 @@ import {TFireworksApiKeyRotationListItem,TFireworksApiKeyRotationWithConnection} from "./fireworks-api-key";+import {+ TGcpServiceAccountKeyRotation,+ TGcpServiceAccountKeyRotationGeneratedCredentials,+ TGcpServiceAccountKeyRotationInput,+ TGcpServiceAccountKeyRotationListItem,+ TGcpServiceAccountKeyRotationWithConnection+} from "./gcp-service-account-key";import {THpIloRotation,THpIloRotationGeneratedCredentials,@@ -239,7 +246,8 @@ export type TSecretRotationV2 =| TSnowflakeUserKeyPairRotation| TCloudflareApiTokenRotation| TCloudflareR2AccessKeyRotation- | TStripeApiKeyRotation;+ | TStripeApiKeyRotation+ | TGcpServiceAccountKeyRotation;export type TSecretRotationV2WithConnection =| TPostgresCredentialsRotationWithConnection@@ -270,7 +278,8 @@ export type TSecretRotationV2WithConnection =| TSnowflakeUserKeyPairRotationWithConnection| TCloudflareApiTokenRotationWithConnection| TCloudflareR2AccessKeyRotationWithConnection- | TStripeApiKeyRotationWithConnection;+ | TStripeApiKeyRotationWithConnection+ | TGcpServiceAccountKeyRotationWithConnection;export type TSecretRotationV2GeneratedCredentials =| TSqlCredentialsRotationGeneratedCredentials@@ -297,7 +306,8 @@ export type TSecretRotationV2GeneratedCredentials =| TSnowflakeUserKeyPairRotationGeneratedCredentials| TCloudflareApiTokenRotationGeneratedCredentials| TCloudflareR2AccessKeyRotationGeneratedCredentials- | TStripeApiKeyRotationGeneratedCredentials;+ | TStripeApiKeyRotationGeneratedCredentials+ | TGcpServiceAccountKeyRotationGeneratedCredentials;export type TSecretRotationV2Input =| TPostgresCredentialsRotationInput@@ -328,7 +338,8 @@ export type TSecretRotationV2Input =| TSnowflakeUserKeyPairRotationInput| TCloudflareApiTokenRotationInput| TCloudflareR2AccessKeyRotationInput- | TStripeApiKeyRotationInput;+ | TStripeApiKeyRotationInput+ | TGcpServiceAccountKeyRotationInput;export type TSecretRotationV2ListItem =| TPostgresCredentialsRotationListItem@@ -359,7 +370,8 @@ export type TSecretRotationV2ListItem =| TSnowflakeUserKeyPairRotationListItem| TCloudflareApiTokenRotationListItem| TCloudflareR2AccessKeyRotationListItem- | TStripeApiKeyRotationListItem;+ | TStripeApiKeyRotationListItem+ | TGcpServiceAccountKeyRotationListItem;export type TSecretRotationV2TemporaryParameters =| TLdapPasswordRotationInput["temporaryParameters"]@@ -505,10 +517,15 @@ export type TRotationFactoryRevokeCredentials<T extends TSecretRotationV2Generatcallback: () => Promise<TSecretRotationV2Raw>) => Promise<TSecretRotationV2Raw>;+// isBackgroundJob is true when a queue job runs the rotation rather than an HTTP request, so a factory+// can do slow work, such as waiting for the provider to accept new credentials, without holding a request open.+export type TRotationFactoryRotateCredentialsOptions = { isBackgroundJob: boolean };+export type TRotationFactoryRotateCredentials<T extends TSecretRotationV2GeneratedCredentials> = (credentialsToRevoke: T[number] | undefined,callback: (newCredentials: T[number]) => Promise<TSecretRotationV2Raw>,- activeCredentials: T[number]+ activeCredentials: T[number],+ options?: TRotationFactoryRotateCredentialsOptions) => Promise<TSecretRotationV2Raw>;export type TRotationFactoryGetSecretsPayload<T extends TSecretRotationV2GeneratedCredentials> = (diff --git a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-union-schema.ts b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-union-schema.tsindex c49c9504c5..cc6af87284 100644--- a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-union-schema.ts+++ b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-union-schema.ts@@ -26,6 +26,7 @@ import { CloudflareR2AccessKeyRotationSchema } from "./cloudflare-r2-access-key"import { ConvexAccessKeyRotationSchema } from "./convex-access-key";import { DbtServiceTokenRotationSchema } from "./dbt-service-token";import { FireworksApiKeyRotationSchema } from "./fireworks-api-key";+import { GcpServiceAccountKeyRotationSchema } from "./gcp-service-account-key";import { HpIloRotationSchema } from "./hp-ilo-rotation";import { SnowflakeUserKeyPairRotationSchema } from "./snowflake-user-key-pair";import { StripeApiKeyRotationSchema } from "./stripe-api-key";@@ -60,5 +61,6 @@ export const SecretRotationV2Schema = z.discriminatedUnion("type", [SnowflakeUserKeyPairRotationSchema,CloudflareApiTokenRotationSchema,CloudflareR2AccessKeyRotationSchema,- StripeApiKeyRotationSchema+ StripeApiKeyRotationSchema,+ GcpServiceAccountKeyRotationSchema]);diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.tsindex 2767140655..35f78c552c 100644--- a/backend/src/lib/api-docs/constants.ts+++ b/backend/src/lib/api-docs/constants.ts@@ -3741,6 +3741,10 @@ export const SecretRotations = {"The name for each Stripe API key this rotation creates, up to 80 characters. Infisical appends a timestamp so the old and new key can be told apart. Defaults to 'infisical-managed'.",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."+ },+ GCP_SERVICE_ACCOUNT_KEY: {+ serviceAccountEmail:+ "The email of the GCP service account whose keys will be rotated, e.g. [email protected]. The connection's service account needs the Service Account Key Admin role (roles/iam.serviceAccountKeyAdmin) on it."}},SECRETS_MAPPING: {@@ -3843,6 +3847,10 @@ export const SecretRotations = {},STRIPE_API_KEY: {apiKey: "The name of the secret that the rotated Stripe API key will be mapped to."+ },+ GCP_SERVICE_ACCOUNT_KEY: {+ serviceAccountKey:+ "The name of the secret that the rotated service account key (the JSON key file) will be mapped to."}}};diff --git a/backend/src/services/integration-auth/integration-list.ts b/backend/src/services/integration-auth/integration-list.tsindex 49e04b704f..2870672bf6 100644--- a/backend/src/services/integration-auth/integration-list.ts+++ b/backend/src/services/integration-auth/integration-list.ts@@ -117,6 +117,7 @@ export enum IntegrationUrls {GCP_CLOUD_DNS_SERVICE_NAME = "dns.googleapis.com",GCP_CLOUD_DNS_URL = `https://${GCP_CLOUD_DNS_SERVICE_NAME}`,GCP_SERVICE_USAGE_URL = "https://serviceusage.googleapis.com",+ GCP_IAM_URL = "https://iam.googleapis.com",GCP_CLOUD_PLATFORM_SCOPE = "https://www.googleapis.com/auth/cloud-platform",GITHUB_USER_INSTALLATIONS = "https://api.github.com/user/installations",diff --git a/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewGcpServiceAccountKeyRotationGeneratedCredentials.tsx b/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewGcpServiceAccountKeyRotationGeneratedCredentials.tsxnew file mode 100644index 0000000000..abd25459a1--- /dev/null+++ b/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewGcpServiceAccountKeyRotationGeneratedCredentials.tsx@@ -0,0 +1,38 @@+import { CredentialDisplay } from "@app/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/shared/CredentialDisplay";+import { TGcpServiceAccountKeyRotationGeneratedCredentialsResponse } from "@app/hooks/api/secretRotationsV2/types/gcp-service-account-key-rotation";++import { ViewRotationGeneratedCredentialsDisplay } from "./shared";++type Props = {+ generatedCredentialsResponse: TGcpServiceAccountKeyRotationGeneratedCredentialsResponse;+};++export const ViewGcpServiceAccountKeyRotationGeneratedCredentials = ({+ generatedCredentialsResponse: { generatedCredentials, activeIndex }+}: Props) => {+ const inactiveIndex = activeIndex === 0 ? 1 : 0;++ const activeCredentials = generatedCredentials[activeIndex];+ const inactiveCredentials = generatedCredentials[inactiveIndex];++ return (+ <ViewRotationGeneratedCredentialsDisplay+ activeCredentials={+ <>+ <CredentialDisplay label="Key ID">{activeCredentials?.keyId}</CredentialDisplay>+ <CredentialDisplay isSensitive label="Service Account Key">+ {activeCredentials?.serviceAccountKey}+ </CredentialDisplay>+ </>+ }+ inactiveCredentials={+ <>+ <CredentialDisplay label="Key ID">{inactiveCredentials?.keyId}</CredentialDisplay>+ <CredentialDisplay isSensitive label="Service Account Key">+ {inactiveCredentials?.serviceAccountKey}+ </CredentialDisplay>+ </>+ }+ />+ );+};diff --git a/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewSecretRotationV2GeneratedCredentials.tsx b/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewSecretRotationV2GeneratedCredentials.tsxindex 790cb65be9..14e638b8da 100644--- a/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewSecretRotationV2GeneratedCredentials.tsx+++ b/frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewSecretRotationV2GeneratedCredentials.tsx@@ -30,6 +30,7 @@ import { ViewDatadogApiKeyRotationGeneratedCredentials } from "./ViewDatadogApiKimport { ViewDatadogApplicationKeySecretRotationGeneratedCredentials } from "./ViewDatadogApplicationKeySecretRotationGeneratedCredentials";import { ViewDbtServiceTokenRotationGeneratedCredentials } from "./ViewDbtSeviceTokenRotationGeneratedCredentials";import { ViewFireworksApiKeyRotationGeneratedCredentials } from "./ViewFireworksApiKeyRotationGeneratedCredentials";+import { ViewGcpServiceAccountKeyRotationGeneratedCredentials } from "./ViewGcpServiceAccountKeyRotationGeneratedCredentials";import { ViewHpIloRotationGeneratedCredentials } from "./ViewHpIloRotationGeneratedCredentials";import { ViewLiteLLMApiKeyRotationGeneratedCredentials } from "./ViewLiteLLMApiKeyRotationGeneratedCredentials";import { ViewOktaClientSecretRotationGeneratedCredentials } from "./ViewOktaClientSecretRotationGeneratedCredentials";@@ -260,6 +261,13 @@ const Content = ({ secretRotation }: ContentProps) => {/>);break;+ case SecretRotation.GcpServiceAccountKey:+ Component = (+ <ViewGcpServiceAccountKeyRotationGeneratedCredentials+ generatedCredentialsResponse={generatedCredentialsResponse}+ />+ );+ break;default:throw new Error("Unhandled View Generated Credential Rotation Type");}diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/GcpServiceAccountKeyRotationParametersFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/GcpServiceAccountKeyRotationParametersFields.tsxnew file mode 100644index 0000000000..63e04c550f--- /dev/null+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/GcpServiceAccountKeyRotationParametersFields.tsx@@ -0,0 +1,56 @@+import { Controller, useFormContext } from "react-hook-form";++import { TSecretRotationV2Form } from "@app/components/secret-rotations-v2/forms/schemas";+import { GCP_SERVICE_ACCOUNT_EMAIL_MAX_LENGTH } from "@app/components/secret-rotations-v2/forms/schemas/gcp-service-account-key-rotation-schema";+import { FieldLabelWithTooltip } from "@app/components/secret-rotations-v2/forms/shared";+import { Field, FieldFeedback, Input } from "@app/components/v3";+import { SecretRotation } from "@app/hooks/api/secretRotationsV2";++export const GcpServiceAccountKeyRotationParametersFields = () => {+ const { control, watch } = useFormContext<+ TSecretRotationV2Form & {+ type: SecretRotation.GcpServiceAccountKey;+ }+ >();++ const isUpdate = Boolean(watch("id"));++ return (+ <Controller+ name="parameters.serviceAccountEmail"+ control={control}+ render={({ field: { value, onChange, onBlur, ref }, fieldState: { error } }) => (+ <Field data-invalid={Boolean(error)}>+ <FieldLabelWithTooltip+ htmlFor="gcp-service-account-email"+ tooltip="The service account whose keys will be rotated. The connection's service account needs the Service Account Key Admin role (roles/iam.serviceAccountKeyAdmin) on it."+ tooltipClassName="max-w-sm"+ >+ Service Account Email+ </FieldLabelWithTooltip>+ <Input+ ref={ref}+ id="gcp-service-account-email"+ disabled={isUpdate}+ value={value}+ onBlur={onBlur}+ onChange={onChange}+ placeholder="[email protected]"+ maxLength={GCP_SERVICE_ACCOUNT_EMAIL_MAX_LENGTH}+ isError={Boolean(error)}+ aria-describedby={+ isUpdate || error?.message ? "gcp-service-account-email-feedback" : undefined+ }+ />+ {(isUpdate || error?.message) && (+ <FieldFeedback+ id="gcp-service-account-email-feedback"+ description={isUpdate ? "Cannot be updated." : undefined}+ error={error?.message}+ />+ )}+ </Field>+ )}+ />+ );+};diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SecretRotationV2ParametersFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SecretRotationV2ParametersFields.tsxindex 5585af7e8f..64d0113dca 100644--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SecretRotationV2ParametersFields.tsx+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/SecretRotationV2ParametersFields.tsx@@ -14,6 +14,7 @@ import { DatadogApiKeyRotationParametersFields } from "./DatadogApiKeyRotationPaimport { DatadogApplicationKeySecretRotationParametersFields } from "./DatadogApplicationKeySecretRotationParametersFields";import { DbtServiceTokenRotationParametersFields } from "./DbtServiceTokenRotationParametersFields";import { FireworksApiKeyRotationParametersFields } from "./FireworksApiKeyRotationParametersFields";+import { GcpServiceAccountKeyRotationParametersFields } from "./GcpServiceAccountKeyRotationParametersFields";import { HpIloRotationParametersFields } from "./HpIloRotationParametersFields";import { LdapPasswordRotationParametersFields } from "./LdapPasswordRotationParametersFields";import { LiteLLMApiKeyRotationParametersFields } from "./LiteLLMApiKeyRotationParametersFields";@@ -60,7 +61,8 @@ const COMPONENT_MAP: Record<SecretRotation, React.FC> = {[SecretRotation.SnowflakeUserKeyPair]: SnowflakeUserKeyPairRotationParametersFields,[SecretRotation.CloudflareApiToken]: CloudflareApiTokenRotationParametersFields,[SecretRotation.CloudflareR2AccessKey]: CloudflareR2AccessKeyRotationParametersFields,- [SecretRotation.StripeApiKey]: StripeApiKeyRotationParametersFields+ [SecretRotation.StripeApiKey]: StripeApiKeyRotationParametersFields,+ [SecretRotation.GcpServiceAccountKey]: GcpServiceAccountKeyRotationParametersFields};export const SecretRotationV2ParametersFields = () => {diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/GcpServiceAccountKeyRotationReviewFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/GcpServiceAccountKeyRotationReviewFields.tsxnew file mode 100644index 0000000000..018d02b81c--- /dev/null+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/GcpServiceAccountKeyRotationReviewFields.tsx@@ -0,0 +1,28 @@+import { useFormContext } from "react-hook-form";++import { TSecretRotationV2Form } from "@app/components/secret-rotations-v2/forms/schemas";+import { ReviewField } from "@app/components/secret-rotations-v2/forms/shared";+import { SecretRotation } from "@app/hooks/api/secretRotationsV2";++import { SecretRotationReviewSection } from "./shared";++export const GcpServiceAccountKeyRotationReviewFields = () => {+ const { watch } = useFormContext<+ TSecretRotationV2Form & {+ type: SecretRotation.GcpServiceAccountKey;+ }+ >();++ const [parameters, { serviceAccountKey }] = watch(["parameters", "secretsMapping"]);++ return (+ <>+ <SecretRotationReviewSection label="Parameters">+ <ReviewField label="Service Account Email">{parameters.serviceAccountEmail}</ReviewField>+ </SecretRotationReviewSection>+ <SecretRotationReviewSection label="Secrets Mapping">+ <ReviewField label="Service Account Key">{serviceAccountKey}</ReviewField>+ </SecretRotationReviewSection>+ </>+ );+};diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SecretRotationReviewFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SecretRotationReviewFields.tsxindex 08e80103db..2411eef4a0 100644--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SecretRotationReviewFields.tsx+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/SecretRotationReviewFields.tsx@@ -18,6 +18,7 @@ import { DatadogApiKeyRotationReviewFields } from "./DatadogApiKeyRotationReviewimport { DatadogApplicationKeySecretRotationReviewFields } from "./DatadogApplicationKeySecretRotationReviewFields";import { DbtServiceTokenRotationReviewFields } from "./DbtServiceTokenRotationReviewFields";import { FireworksApiKeyRotationReviewFields } from "./FireworksApiKeyRotationReviewFields";+import { GcpServiceAccountKeyRotationReviewFields } from "./GcpServiceAccountKeyRotationReviewFields";import { HpIloRotationReviewFields } from "./HpIloRotationReviewFields";import { LdapPasswordRotationReviewFields } from "./LdapPasswordRotationReviewFields";import { LiteLLMApiKeyRotationReviewFields } from "./LiteLLMApiKeyRotationReviewFields";@@ -63,7 +64,8 @@ const COMPONENT_MAP: Record<SecretRotation, React.FC> = {[SecretRotation.SnowflakeUserKeyPair]: SnowflakeUserKeyPairRotationReviewFields,[SecretRotation.CloudflareApiToken]: CloudflareApiTokenRotationReviewFields,[SecretRotation.CloudflareR2AccessKey]: CloudflareR2AccessKeyRotationReviewFields,- [SecretRotation.StripeApiKey]: StripeApiKeyRotationReviewFields+ [SecretRotation.StripeApiKey]: StripeApiKeyRotationReviewFields,+ [SecretRotation.GcpServiceAccountKey]: GcpServiceAccountKeyRotationReviewFields};export const SecretRotationV2ReviewFields = () => {diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/GcpServiceAccountKeyRotationSecretsMappingFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/GcpServiceAccountKeyRotationSecretsMappingFields.tsxnew file mode 100644index 0000000000..42578aeafb--- /dev/null+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/GcpServiceAccountKeyRotationSecretsMappingFields.tsx@@ -0,0 +1,44 @@+import { Controller, useFormContext } from "react-hook-form";++import { TSecretRotationV2Form } from "@app/components/secret-rotations-v2/forms/schemas";+import { Field, FieldError, Input } from "@app/components/v3";+import { SecretRotation, useSecretRotationV2Option } from "@app/hooks/api/secretRotationsV2";++import { SecretsMappingTable } from "./shared";++export const GcpServiceAccountKeyRotationSecretsMappingFields = () => {+ const { control } = useFormContext<+ TSecretRotationV2Form & {+ type: SecretRotation.GcpServiceAccountKey;+ }+ >();++ const { rotationOption } = useSecretRotationV2Option(SecretRotation.GcpServiceAccountKey);++ const items = [+ {+ name: "Service Account Key",+ input: (+ <Controller+ render={({ field: { value, onChange, onBlur, ref }, fieldState: { error } }) => (+ <Field data-invalid={Boolean(error)}>+ <Input+ ref={ref}+ value={value}+ onBlur={onBlur}+ onChange={onChange}+ placeholder={rotationOption?.template.secretsMapping.serviceAccountKey}+ isError={Boolean(error)}+ />+ <FieldError>{error?.message}</FieldError>+ </Field>+ )}+ control={control}+ name="secretsMapping.serviceAccountKey"+ />+ )+ }+ ];++ 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.tsxindex 0e3618b616..0a97358d23 100644--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/SecretRotationV2SecretsMappingFields.tsx+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/SecretRotationV2SecretsMappingFields.tsx@@ -14,6 +14,7 @@ import { DatadogApiKeyRotationSecretsMappingFields } from "./DatadogApiKeyRotatiimport { DatadogApplicationKeySecretRotationSecretsMappingFields } from "./DatadogApplicationKeySecretRotationSecretsMappingFields";import { DbtServiceTokenRotationSecretsMappingFields } from "./DbtServiceTokenRotationSecretsMappingFields";import { FireworksApiKeyRotationSecretsMappingFields } from "./FireworksApiKeyRotationSecretsMappingFields";+import { GcpServiceAccountKeyRotationSecretsMappingFields } from "./GcpServiceAccountKeyRotationSecretsMappingFields";import { HpIloRotationSecretsMappingFields } from "./HpIloRotationSecretsMappingFields";import { LdapPasswordRotationSecretsMappingFields } from "./LdapPasswordRotationSecretsMappingFields";import { LiteLLMApiKeyRotationSecretsMappingFields } from "./LiteLLMApiKeyRotationSecretsMappingFields";@@ -61,7 +62,8 @@ const COMPONENT_MAP: Record<SecretRotation, React.FC> = {[SecretRotation.SnowflakeUserKeyPair]: SnowflakeUserKeyPairRotationSecretsMappingFields,[SecretRotation.CloudflareApiToken]: CloudflareApiTokenRotationSecretsMappingFields,[SecretRotation.CloudflareR2AccessKey]: CloudflareR2AccessKeyRotationSecretsMappingFields,- [SecretRotation.StripeApiKey]: StripeApiKeyRotationSecretsMappingFields+ [SecretRotation.StripeApiKey]: StripeApiKeyRotationSecretsMappingFields,+ [SecretRotation.GcpServiceAccountKey]: GcpServiceAccountKeyRotationSecretsMappingFields};export const SecretRotationV2SecretsMappingFields = () => {diff --git a/frontend/src/components/secret-rotations-v2/forms/schemas/gcp-service-account-key-rotation-schema.ts b/frontend/src/components/secret-rotations-v2/forms/schemas/gcp-service-account-key-rotation-schema.tsnew file mode 100644index 0000000000..12ca9cf95b--- /dev/null+++ b/frontend/src/components/secret-rotations-v2/forms/schemas/gcp-service-account-key-rotation-schema.ts@@ -0,0 +1,23 @@+import { z } from "zod";++import { BaseSecretRotationSchema } from "@app/components/secret-rotations-v2/forms/schemas/base-secret-rotation-v2-schema";+import { SecretRotation } from "@app/hooks/api/secretRotationsV2";++export const GCP_SERVICE_ACCOUNT_EMAIL_MAX_LENGTH = 254;++export const GcpServiceAccountKeyRotationSchema = z+ .object({+ type: z.literal(SecretRotation.GcpServiceAccountKey),+ parameters: z.object({+ serviceAccountEmail: z+ .string()+ .trim()+ .min(1, "Service Account Email required")+ .max(GCP_SERVICE_ACCOUNT_EMAIL_MAX_LENGTH)+ .email("Service Account Email must be a valid email address")+ }),+ secretsMapping: z.object({+ serviceAccountKey: z.string().trim().min(1, "Service Account Key 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.tsindex 004b29402e..88986ed390 100644--- a/frontend/src/components/secret-rotations-v2/forms/schemas/index.ts+++ b/frontend/src/components/secret-rotations-v2/forms/schemas/index.ts@@ -22,6 +22,7 @@ import { DatadogApiKeyRotationSchema } from "./datadog-api-key-rotation-schema";import { DatadogApplicationKeySecretRotationSchema } from "./datadog-application-key-secret-rotation-schema";import { DbtServiceTokenRotationSchema } from "./dbt-service-token-rotation-schema";import { FireworksApiKeyRotationSchema } from "./fireworks-api-key-rotation-schema";+import { GcpServiceAccountKeyRotationSchema } from "./gcp-service-account-key-rotation-schema";import { HpIloRotationSchema } from "./hp-ilo-rotation-schema";import { LiteLLMApiKeyRotationSchema } from "./litellm-api-key-rotation-schema";import { OktaClientSecretRotationSchema } from "./okta-client-secret-rotation-schema";@@ -68,7 +69,8 @@ export const SecretRotationV2FormSchema = (isUpdate: boolean) =>SnowflakeUserKeyPairRotationSchema,CloudflareApiTokenRotationSchema,CloudflareR2AccessKeyRotationSchema,- StripeApiKeyRotationSchema+ StripeApiKeyRotationSchema,+ GcpServiceAccountKeyRotationSchema]),z.object({ id: z.string().optional() }))diff --git a/frontend/src/helpers/secretRotationsV2.ts b/frontend/src/helpers/secretRotationsV2.tsindex f2f7a7f39f..0319f1b2cc 100644--- a/frontend/src/helpers/secretRotationsV2.ts+++ b/frontend/src/helpers/secretRotationsV2.ts@@ -149,6 +149,11 @@ export const SECRET_ROTATION_MAP: Record<name: "Stripe API Key",image: "Stripe.svg",size: 50+ },+ [SecretRotation.GcpServiceAccountKey]: {+ name: "GCP Service Account Key",+ image: "Google Cloud Platform.png",+ size: 50}};@@ -181,7 +186,8 @@ export const SECRET_ROTATION_CONNECTION_MAP: Record<SecretRotation, AppConnectio[SecretRotation.SnowflakeUserKeyPair]: AppConnection.Snowflake,[SecretRotation.CloudflareApiToken]: AppConnection.Cloudflare,[SecretRotation.CloudflareR2AccessKey]: AppConnection.Cloudflare,- [SecretRotation.StripeApiKey]: AppConnection.Stripe+ [SecretRotation.StripeApiKey]: AppConnection.Stripe,+ [SecretRotation.GcpServiceAccountKey]: AppConnection.GCP};// if a rotation can potentially have downtime due to rotating a single credential set this to false@@ -214,7 +220,8 @@ export const IS_ROTATION_DUAL_CREDENTIALS: Record<SecretRotation, boolean> = {[SecretRotation.SnowflakeUserKeyPair]: true,[SecretRotation.CloudflareApiToken]: true,[SecretRotation.CloudflareR2AccessKey]: true,- [SecretRotation.StripeApiKey]: true+ [SecretRotation.StripeApiKey]: true,+ [SecretRotation.GcpServiceAccountKey]: true};export const getRotateAtLocal = ({ hours, minutes }: TSecretRotationV2["rotateAtUtc"]) => {diff --git a/frontend/src/hooks/api/secretRotationsV2/enums.ts b/frontend/src/hooks/api/secretRotationsV2/enums.tsindex 0d634dbd81..289104c5b6 100644--- a/frontend/src/hooks/api/secretRotationsV2/enums.ts+++ b/frontend/src/hooks/api/secretRotationsV2/enums.ts@@ -27,7 +27,8 @@ export enum SecretRotation {SnowflakeUserKeyPair = "snowflake-user-key-pair",CloudflareApiToken = "cloudflare-api-token",CloudflareR2AccessKey = "cloudflare-r2-access-key",- StripeApiKey = "stripe-api-key"+ StripeApiKey = "stripe-api-key",+ GcpServiceAccountKey = "gcp-service-account-key"}export enum SecretRotationStatus {diff --git a/frontend/src/hooks/api/secretRotationsV2/types/gcp-service-account-key-rotation.ts b/frontend/src/hooks/api/secretRotationsV2/types/gcp-service-account-key-rotation.tsnew file mode 100644index 0000000000..6c8af68161--- /dev/null+++ b/frontend/src/hooks/api/secretRotationsV2/types/gcp-service-account-key-rotation.ts@@ -0,0 +1,36 @@+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 TGcpServiceAccountKeyRotation = TSecretRotationV2Base & {+ type: SecretRotation.GcpServiceAccountKey;+ parameters: {+ serviceAccountEmail: string;+ };+ secretsMapping: {+ serviceAccountKey: string;+ };+};++export type TGcpServiceAccountKeyRotationGeneratedCredentials = {+ keyId: string;+ serviceAccountKey: string;+};++export type TGcpServiceAccountKeyRotationGeneratedCredentialsResponse =+ TSecretRotationV2GeneratedCredentialsResponseBase<+ SecretRotation.GcpServiceAccountKey,+ TGcpServiceAccountKeyRotationGeneratedCredentials+ >;++export type TGcpServiceAccountKeyRotationOption = {+ name: string;+ type: SecretRotation.GcpServiceAccountKey;+ connection: AppConnection.GCP;+ template: {+ secretsMapping: TGcpServiceAccountKeyRotation["secretsMapping"];+ };+};diff --git a/frontend/src/hooks/api/secretRotationsV2/types/index.ts b/frontend/src/hooks/api/secretRotationsV2/types/index.tsindex 712fd3f92d..913cf19770 100644--- a/frontend/src/hooks/api/secretRotationsV2/types/index.ts+++ b/frontend/src/hooks/api/secretRotationsV2/types/index.ts@@ -71,6 +71,11 @@ import {TFireworksApiKeyRotationGeneratedCredentialsResponse,TFireworksApiKeyRotationOption} from "./fireworks-api-key-rotation";+import {+ TGcpServiceAccountKeyRotation,+ TGcpServiceAccountKeyRotationGeneratedCredentialsResponse,+ TGcpServiceAccountKeyRotationOption+} from "./gcp-service-account-key-rotation";import {THpIloRotation,THpIloRotationGeneratedCredentialsResponse,@@ -175,6 +180,7 @@ export type TSecretRotationV2 = (| TCloudflareApiTokenRotation| TCloudflareR2AccessKeyRotation| TStripeApiKeyRotation+ | TGcpServiceAccountKeyRotation) & {secrets: (SecretV3RawSanitized | null)[];};@@ -205,7 +211,8 @@ export type TSecretRotationV2Option =| TSnowflakeUserKeyPairRotationOption| TCloudflareApiTokenRotationOption| TCloudflareR2AccessKeyRotationOption- | TStripeApiKeyRotationOption;+ | TStripeApiKeyRotationOption+ | TGcpServiceAccountKeyRotationOption;export type TListSecretRotationV2Options = { secretRotationOptions: TSecretRotationV2Option[] };@@ -240,7 +247,8 @@ export type TViewSecretRotationGeneratedCredentialsResponse =| TSnowflakeUserKeyPairRotationGeneratedCredentialsResponse| TCloudflareApiTokenRotationGeneratedCredentialsResponse| TCloudflareR2AccessKeyRotationGeneratedCredentialsResponse- | TStripeApiKeyRotationGeneratedCredentialsResponse;+ | TStripeApiKeyRotationGeneratedCredentialsResponse+ | TGcpServiceAccountKeyRotationGeneratedCredentialsResponse;export type TCreateSecretRotationV2DTO = DiscriminativePick<TSecretRotationV2,@@ -324,6 +332,7 @@ export type TSecretRotationOptionMap = {[SecretRotation.CloudflareApiToken]: TCloudflareApiTokenRotationOption;[SecretRotation.CloudflareR2AccessKey]: TCloudflareR2AccessKeyRotationOption;[SecretRotation.StripeApiKey]: TStripeApiKeyRotationOption;+ [SecretRotation.GcpServiceAccountKey]: TGcpServiceAccountKeyRotationOption;};export type TSecretRotationGeneratedCredentialsResponseMap = {@@ -356,6 +365,7 @@ export type TSecretRotationGeneratedCredentialsResponseMap = {[SecretRotation.CloudflareApiToken]: TCloudflareApiTokenRotationGeneratedCredentialsResponse;[SecretRotation.CloudflareR2AccessKey]: TCloudflareR2AccessKeyRotationGeneratedCredentialsResponse;[SecretRotation.StripeApiKey]: TStripeApiKeyRotationGeneratedCredentialsResponse;+ [SecretRotation.GcpServiceAccountKey]: TGcpServiceAccountKeyRotationGeneratedCredentialsResponse;};// Unified type for local account reconciliation (Unix/Linux, Windows, and HP iLO)