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: cloudflare pages integration sync
Stijn-Kuijper17097965d958
diff --git a/backend/src/integrations/sync.ts b/backend/src/integrations/sync.tsindex 76d0099449..7d003b4f5f 100644--- a/backend/src/integrations/sync.ts+++ b/backend/src/integrations/sync.ts@@ -37,7 +37,9 @@ import {INTEGRATION_SUPABASE_API_URL,INTEGRATION_CHECKLY,INTEGRATION_CHECKLY_API_URL,- INTEGRATION_HASHICORP_VAULT+ INTEGRATION_HASHICORP_VAULT,+ INTEGRATION_CLOUDFLARE_PAGES,+ INTEGRATION_CLOUDFLARE_PAGES_API_URL} from "../variables";import { standardRequest} from '../config/request';@@ -210,6 +212,14 @@ const syncSecrets = async ({accessToken});break;+ case INTEGRATION_CLOUDFLARE_PAGES:+ await syncSecretsCloudflarePages({+ integration,+ secrets,+ accessId,+ accessToken+ });+ break;}};@@ -1833,4 +1843,64 @@ const syncSecretsHashiCorpVault = async ({);};+const syncSecretsCloudflarePages = async ({+ integration,+ secrets,+ accessId,+ accessToken,+}: {+ integration: IIntegration;+ secrets: any;+ accessId: string | null;+ accessToken: string;+}) => {+ // get secrets from cloudflare pages+ const getSecretsRes = (+ await standardRequest.get(+ `${INTEGRATION_CLOUDFLARE_PAGES_API_URL}/client/v4/accounts/${accessId}/pages/projects/${integration.app}`,+ {+ headers: {+ Authorization: `Bearer ${accessToken}`,+ "Accept": "application/json",+ },+ }+ )+ )+ .data.result['deployment_configs'].production['env_vars'];++ // copy the secrets object, so we can set deleted keys to null+ const secretsObj: any = {...secrets};++ for (const [key, val] of Object.entries(secretsObj)) {+ secretsObj[key] = { value: val };+ }++ for await (const key of Object.keys(getSecretsRes)) {+ if (!(key in secrets)) {+ // case: secret deos not exist in infisical+ // -> delete secret from cloudflare pages+ secretsObj[key] = null;+ }+ }++ await standardRequest.patch(+ `${INTEGRATION_CLOUDFLARE_PAGES_API_URL}/client/v4/accounts/${accessId}/pages/projects/${integration.app}`,+ {+ data: {+ "deployment_configs": {+ "production": {+ "env_vars": secretsObj+ }+ }+ }+ },+ {+ headers: {+ Authorization: `Bearer ${accessToken}`,+ "Accept": "application/json",+ },+ }+ )+}+export { syncSecrets };diff --git a/backend/src/models/integration.ts b/backend/src/models/integration.tsindex c23cf69f18..678cdcc569 100644--- a/backend/src/models/integration.ts+++ b/backend/src/models/integration.ts@@ -16,6 +16,7 @@ import {INTEGRATION_SUPABASE,INTEGRATION_CHECKLY,INTEGRATION_HASHICORP_VAULT,+ INTEGRATION_CLOUDFLARE_PAGES} from "../variables";export interface IIntegration {@@ -50,7 +51,8 @@ export interface IIntegration {| "travisci"| "supabase"| "checkly"- | "hashicorp-vault";+ | "hashicorp-vault"+ | "cloudflare-pages";integrationAuth: Types.ObjectId;}@@ -138,6 +140,7 @@ const integrationSchema = new Schema<IIntegration>(INTEGRATION_SUPABASE,INTEGRATION_CHECKLY,INTEGRATION_HASHICORP_VAULT,+ INTEGRATION_CLOUDFLARE_PAGES,],required: true,},