Skip to content

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

Merge remote-tracking branch 'upstream/main' into feat/windmill-integration

Sunil Kumarce08512ab5f5
diff --cc backend/src/integrations/apps.ts
index ed7a1a6d38,39dba64356..1b40695027
--- a/backend/src/integrations/apps.ts
+++ b/backend/src/integrations/apps.ts
@@@ -32,8 -32,9 +32,10 @@@ import
INTEGRATION_TRAVISCI_API_URL,
INTEGRATION_VERCEL,
INTEGRATION_VERCEL_API_URL,
+ INTEGRATION_CODEFRESH,
- INTEGRATION_CODEFRESH_API_URL
-
++ INTEGRATION_CODEFRESH_API_URL,
+ INTEGRATION_WINDMILL,
+ INTEGRATION_WINDMILL_API_URL,
} from "../variables";
interface App {
@@@ -147,11 -148,11 +149,16 @@@ const getApps = async (
accountId: accessId
})
break;
+ case INTEGRATION_CODEFRESH:
+ apps = await getAppsCodefresh({
+ accessToken,
+ });
+ break;
+ case INTEGRATION_WINDMILL:
+ apps = await getAppsWindmill({
+ accessToken,
+ });
+ break;
}
return apps;
@@@ -702,90 -703,61 +709,122 @@@ const getAppsCheckly = async ({ accessT
* @returns {Object[]} apps - Cloudflare Pages projects
* @returns {String} apps.name - name of Cloudflare Pages project
*/
- const getAppsCloudflarePages = async ({
- accessToken,
- accountId
+ const getAppsCloudflarePages = async ({
+ accessToken,
+ accountId
}: {
- accessToken: string;
- accountId?: string;
+ accessToken: string;
+ accountId?: string;
}) => {
- const { data } = await standardRequest.get(
- `${INTEGRATION_CLOUDFLARE_PAGES_API_URL}/client/v4/accounts/${accountId}/pages/projects`,
- {
- headers: {
- Authorization: `Bearer ${accessToken}`,
- "Accept": "application/json",
- },
- }
- );
+ const { data } = await standardRequest.get(
+ `${INTEGRATION_CLOUDFLARE_PAGES_API_URL}/client/v4/accounts/${accountId}/pages/projects`,
+ {
+ headers: {
+ Authorization: `Bearer ${accessToken}`,
+ "Accept": "application/json",
+ },
+ }
+ );
- const apps = data.result.map((a: any) => {
- return {
- name: a.name,
- appId: a.id,
- };
- });
- return apps;
+ const apps = data.result.map((a: any) => {
+ return {
+ name: a.name,
+ appId: a.id,
+ };
+ });
+ return apps;
}
-
+ /**
+ * Return list of projects for Supabase integration
+ * @param {Object} obj
+ * @param {String} obj.accessToken - access token for Supabase API
+ * @returns {Object[]} apps - names of Supabase apps
+ * @returns {String} apps.name - name of Supabase app
+ */
+
+ const getAppsCodefresh = async ({
+ accessToken,
+ }: {
+ accessToken: string;
+ }) => {
+ const res = (
+ await standardRequest.get(`${INTEGRATION_CODEFRESH_API_URL}/projects`, {
+ headers: {
+ Authorization: `Bearer ${accessToken}`,
+ "Accept-Encoding": "application/json",
+ },
+ })
+ ).data;
+
+ const apps = res.projects.map((a: any) => ({
+ name: a.projectName,
+ appId: a.id,
+ }));
+
+ return apps;
+
+ };
++
++
+/**
+ * Return list of projects for Windmill integration
+ * @param {Object} obj
+ * @param {String} obj.accessToken - access token for Windmill API
+ * @returns {Object[]} apps - names of Windmill workspaces
+ * @returns {String} apps.name - name of Windmill workspace
+ */
+const getAppsWindmill = async ({ accessToken }: { accessToken: string }) => {
+ const { data } = await standardRequest.get(
+ `${INTEGRATION_WINDMILL_API_URL}/workspaces/list`,
+ {
+ headers: {
+ Authorization: `Bearer ${accessToken}`,
+ "Accept-Encoding": "application/json",
+ },
+ }
+ );
+
+ // make calls for each app to check user is admin for that app or not
+ const authCheckForApps = async (data: any) => {
+ const allAppResponse = data.map(async (app: any) => {
+ return standardRequest.get(
+ `${INTEGRATION_WINDMILL_API_URL}/w/${app.name}/users/whoami`,
+ {
+ headers: {
+ Authorization: `Bearer ${accessToken}`,
+ "Accept-Encoding": "application/json",
+ },
+ }
+ )
+ .then((response: any) => {
+ const modifiedData = { ...response.data };
+ modifiedData.appName = app.name;
+ return modifiedData;
+ })
+ .catch((error: any) => {
+ return undefined;
+ });
+ });
+
+ const appPromiseResponses = await Promise.all(allAppResponse)
+ const filteredAppResponses = appPromiseResponses.filter((authRes: any) => (authRes !== undefined) && (authRes.is_admin));
+
+ return filteredAppResponses;
+ }
+
+ // get apps that user(auth token) is authorized for
+ const authorizedApps = await authCheckForApps(data);
+
+ const apps = authorizedApps.map((a: any) => {
+ return {
+ name: a.appName,
+ appId: a.workspace_id,
+ };
+ });
+
+ return apps;
+};
+
+
export { getApps };
diff --cc backend/src/integrations/sync.ts
index 59445ce4f0,129b3a63d2..e8e382ed96
--- a/backend/src/integrations/sync.ts
+++ b/backend/src/integrations/sync.ts
@@@ -42,10 -42,10 +42,12 @@@ import
INTEGRATION_TRAVISCI_API_URL,
INTEGRATION_VERCEL,
INTEGRATION_VERCEL_API_URL,
+ INTEGRATION_CODEFRESH,
- INTEGRATION_CODEFRESH_API_URL
++ INTEGRATION_CODEFRESH_API_URL,
+ INTEGRATION_WINDMILL,
+ INTEGRATION_WINDMILL_API_URL,
} from "../variables";
- import { standardRequest} from "../config/request";
+ import { standardRequest } from "../config/request";
/**
* Sync/push [secrets] to [app] in integration named [integration]
@@@ -201,20 -226,19 +231,27 @@@ const syncSecrets = async (
break;
case INTEGRATION_CLOUDFLARE_PAGES:
await syncSecretsCloudflarePages({
- integration,
- secrets,
- accessId,
- accessToken
+ integration,
+ secrets,
+ accessId,
+ accessToken
+ });
+ break;
+ case INTEGRATION_CODEFRESH:
+ await syncSecretsCodefresh({
+ integration,
+ secrets,
+ accessToken,
});
break;
+ case INTEGRATION_WINDMILL:
+ await syncSecretsWindmill({
+ integration,
+ secrets,
+ accessToken,
+ secretComments
+ });
+ break;
}
};
@@@ -1951,122 -1975,36 +1988,155 @@@ const syncSecretsCloudflarePages = asyn
}
/**
- * Sync/push [secrets] to Windmil with name [integration.app]
+ * Sync/push [secrets] to Codefresh with name [integration.app]
+ * @param {Object} obj
+ * @param {IIntegration} obj.integration - integration details
+ * @param {Object} obj.secrets - secrets to push to integration (object where keys are secret keys and values are secret values)
+ * @param {String} obj.accessToken - access token for Codefresh integration
+ */
+ const syncSecretsCodefresh = async ({
+ integration,
+ secrets,
+ accessToken,
+ }: {
+ integration: IIntegration;
+ secrets: any;
+ accessToken: string;
+ }) => {
+ await standardRequest.patch(
+ `${INTEGRATION_CODEFRESH_API_URL}/projects/${integration.appId}`,
+ {
+ variables: Object.keys(secrets).map((key) => ({
+ key,
+ value: secrets[key]
+ }))
+ },
+ {
+ headers: {
+ Authorization: `Bearer ${accessToken}`,
+ "Accept": "application/json",
+ },
+ }
+ );
+ };
+
++/**
++ * Sync/push [secrets] to Windmill with name [integration.app]
+ * @param {Object} obj
+ * @param {IIntegration} obj.integration - integration details
+ * @param {IIntegrationAuth} obj.integrationAuth - integration auth details
+ * @param {Object} obj.secrets - secrets to push to integration (object where keys are secret keys and values are secret values)
+ * @param {String} obj.accessToken - access token for windmill integration
+ * @param {Object} obj.secretComments - secret comments to push to integration (object where keys are secret keys and values are comment values)
+ */
+const syncSecretsWindmill = async ({
+ integration,
+ secrets,
+ accessToken,
+ secretComments
+}: {
+ integration: IIntegration;
+ secrets: any;
+ accessToken: string;
+ secretComments: any;
+}) => {
+ interface WindmillSecret {
+ path: string;
+ value: string;
+ is_secret: boolean;
+ description?: string;
+ }
+
+ // get secrets stored in windmill workspace
+ const { data: getSecretsRes } = await standardRequest.get(
+ `${INTEGRATION_WINDMILL_API_URL}/w/${integration.app}/variables/list`,
+ {
+ headers: {
+ Authorization: `Bearer ${accessToken}`,
+ "Accept-Encoding": "application/json",
+ },
+ }
+ );
+
+ // convert secret results to [key] format
+ const secretsResList = getSecretsRes.map((secretObj: any) => (secretObj.path));
+
+ // convert the secrets to [{}] format
+ const modifiedFormatForCreateSecretInjection: WindmillSecret[] = [];
+ const modifiedFormatForUpdateSecretInjection: WindmillSecret[] = [];
+
+ Object.keys(secrets).forEach(
+ (key) => {
+ const pattern = new RegExp('^([a-zA-Z0-9])\/([a-zA-Z-0-9])+\/([a-zA-Z0-9])+')
+ if((key.startsWith("u/") || key.startsWith("f/")) && pattern.test(key)) {
+ if(secretsResList.includes(key)) {
+ modifiedFormatForUpdateSecretInjection.push({
+ path: key,
+ value: secrets[key],
+ is_secret: true,
+ description: secretComments[key] || ""
+ });
+ } else {
+ modifiedFormatForCreateSecretInjection.push({
+ path: key,
+ value: secrets[key],
+ is_secret: true,
+ description: secretComments[key] || ""
+ });
+ }
+ };
+ }
+ );
+
+ // create new secrets in windmill workspace
+ modifiedFormatForCreateSecretInjection.forEach(async (secretObj: any) => {
+ await standardRequest.post(
+ `${INTEGRATION_WINDMILL_API_URL}/w/${integration.app}/variables/create`,
+ secretObj,
+ {
+ headers: {
+ Authorization: `Bearer ${accessToken}`,
+ "Accept-Encoding": "application/json",
+ },
+ }
+ );
+ })
+
+ // update old secrets already present in windmill workspace
+ modifiedFormatForUpdateSecretInjection.forEach(async (secretObj: any) => {
+ await standardRequest.post(
+ `${INTEGRATION_WINDMILL_API_URL}/w/${integration.app}/variables/update/${secretObj.path}`,
+ secretObj,
+ {
+ headers: {
+ Authorization: `Bearer ${accessToken}`,
+ "Accept-Encoding": "application/json",
+ },
+ }
+ )
+ })
+
+ // create list of secrets to delete
+ const secretsToDelete: string[] = [];
+ secretsResList.forEach((secret: string) => {
+ if(!(secret in secrets)) {
+ secretsToDelete.push(secret);
+ }
+ })
+
+ // delete all secrets from secretsToDelete List
+ secretsToDelete.forEach(async (secret: string) => {
+ await standardRequest.delete(
+ `${INTEGRATION_WINDMILL_API_URL}/w/${integration.app}/variables/delete/${secret}`,
+ {
+ headers: {
+ Authorization: `Bearer ${accessToken}`,
+ "Content-Type": "application/json",
+ "Accept-Encoding": "application/json",
+ }
+ }
+ );
+ });
+};
+
export { syncSecrets };
diff --cc backend/src/models/integration.ts
index 7c487cbfea,75a5d41932..a443c3f836
--- a/backend/src/models/integration.ts
+++ b/backend/src/models/integration.ts
@@@ -18,7 -18,7 +18,8 @@@ import
INTEGRATION_SUPABASE,
INTEGRATION_TRAVISCI,
INTEGRATION_VERCEL,
- INTEGRATION_CODEFRESH
++ INTEGRATION_CODEFRESH,
+ INTEGRATION_WINDMILL,
} from "../variables";
export interface IIntegration {
@@@ -56,7 -56,7 +57,8 @@@
| "checkly"
| "hashicorp-vault"
| "cloudflare-pages"
- | "codefresh";
++ | "codefresh"
+ | "windmill";
integrationAuth: Types.ObjectId;
}
@@@ -146,7 -146,7 +148,8 @@@ const integrationSchema = new Schema<II
INTEGRATION_CHECKLY,
INTEGRATION_HASHICORP_VAULT,
INTEGRATION_CLOUDFLARE_PAGES,
- INTEGRATION_CODEFRESH
++ INTEGRATION_CODEFRESH,
+ INTEGRATION_WINDMILL,
],
required: true,
},
diff --cc backend/src/models/integrationAuth.ts
index 3d18166f8e,2330c79383..219c1e428f
--- a/backend/src/models/integrationAuth.ts
+++ b/backend/src/models/integrationAuth.ts
@@@ -20,13 -20,13 +20,14 @@@ import
INTEGRATION_SUPABASE,
INTEGRATION_TRAVISCI,
INTEGRATION_VERCEL,
- INTEGRATION_CODEFRESH
++ INTEGRATION_CODEFRESH,
+ INTEGRATION_WINDMILL
} from "../variables";
export interface IIntegrationAuth extends Document {
_id: Types.ObjectId;
workspace: Types.ObjectId;
- integration: "heroku" | "vercel" | "netlify" | "github" | "gitlab" | "render" | "railway" | "flyio" | "azure-key-vault" | "laravel-forge" | "circleci" | "travisci" | "supabase" | "aws-parameter-store" | "aws-secret-manager" | "checkly" | "cloudflare-pages" | "windmill";
- integration: 'heroku' | 'vercel' | 'netlify' | 'github' | 'gitlab' | 'render' | 'railway' | 'flyio' | 'azure-key-vault' | 'laravel-forge' | 'circleci' | 'travisci' | 'supabase' | 'aws-parameter-store' | 'aws-secret-manager' | 'checkly' | 'cloudflare-pages' | 'codefresh';
++ integration: 'heroku' | 'vercel' | 'netlify' | 'github' | 'gitlab' | 'render' | 'railway' | 'flyio' | 'azure-key-vault' | 'laravel-forge' | 'circleci' | 'travisci' | 'supabase' | 'aws-parameter-store' | 'aws-secret-manager' | 'checkly' | 'cloudflare-pages' | 'windmill' | 'codefresh';
teamId: string;
accountId: string;
url: string;
@@@ -72,7 -72,7 +73,8 @@@ const integrationAuthSchema = new Schem
INTEGRATION_SUPABASE,
INTEGRATION_HASHICORP_VAULT,
INTEGRATION_CLOUDFLARE_PAGES,
- INTEGRATION_CODEFRESH
++ INTEGRATION_CODEFRESH,
+ INTEGRATION_WINDMILL,
],
required: true,
},
diff --cc backend/src/variables/integration.ts
index 12ff525bcb,ba3f0e9058..3c8bea7bea
--- a/backend/src/variables/integration.ts
+++ b/backend/src/variables/integration.ts
@@@ -26,7 -26,7 +26,8 @@@ export const INTEGRATION_SUPABASE = "su
export const INTEGRATION_CHECKLY = "checkly";
export const INTEGRATION_HASHICORP_VAULT = "hashicorp-vault";
export const INTEGRATION_CLOUDFLARE_PAGES = "cloudflare-pages";
+ export const INTEGRATION_CODEFRESH = "codefresh";
+export const INTEGRATION_WINDMILL = "windmill";
export const INTEGRATION_SET = new Set([
INTEGRATION_AZURE_KEY_VAULT,
INTEGRATION_HEROKU,
@@@ -43,7 -43,7 +44,8 @@@
INTEGRATION_CHECKLY,
INTEGRATION_HASHICORP_VAULT,
INTEGRATION_CLOUDFLARE_PAGES,
- INTEGRATION_CODEFRESH
++ INTEGRATION_CODEFRESH,
+ INTEGRATION_WINDMILL
]);
// integration types
@@@ -73,7 -73,7 +75,8 @@@ export const INTEGRATION_SUPABASE_API_U
export const INTEGRATION_LARAVELFORGE_API_URL = "https://forge.laravel.com";
export const INTEGRATION_CHECKLY_API_URL = "https://api.checklyhq.com";
export const INTEGRATION_CLOUDFLARE_PAGES_API_URL = "https://api.cloudflare.com";
+ export const INTEGRATION_CODEFRESH_API_URL = "https://g.codefresh.io/api";
+export const INTEGRATION_WINDMILL_API_URL = "https://app.windmill.dev/api";
export const getIntegrationOptions = async () => {
const INTEGRATION_OPTIONS = [
@@@ -249,16 -249,15 +252,25 @@@
clientId: "",
docsLink: ""
},
+ {
+ name: "Codefresh",
+ slug: "codefresh",
+ image: "Codefresh.png",
+ isAvailable: true,
+ type: "pat",
+ clientId: "",
+ docsLink: "",
+ },
+ {
+ name: "Windmill",
+ slug: "windmill",
+ image: "Windmill.png",
+ isAvailable: true,
+ type: "pat",
+ clientId: "",
+ docsLink: ""
+ },
+
]
return INTEGRATION_OPTIONS;
diff --cc frontend/public/data/frequentConstants.ts
index a6a21c966b,17c30d38c9..42aff4d09c
--- a/frontend/public/data/frequentConstants.ts
+++ b/frontend/public/data/frequentConstants.ts
@@@ -21,7 -21,7 +21,8 @@@ const integrationSlugNameMapping: Mappi
'checkly': 'Checkly',
'hashicorp-vault': 'Vault',
'cloudflare-pages': 'Cloudflare Pages',
- 'codefresh': 'Codefresh'
++ 'codefresh': 'Codefresh',
+ 'windmill': 'windmill'
}
const envMapping: Mapping = {
diff --cc frontend/src/views/IntegrationsPage/IntegrationPage.utils.tsx
index fa6633df0b,e2cfbc5ed0..d74c88893b
--- a/frontend/src/views/IntegrationsPage/IntegrationPage.utils.tsx
+++ b/frontend/src/views/IntegrationsPage/IntegrationPage.utils.tsx
@@@ -92,9 -92,10 +92,12 @@@ export const redirectForProviderAuth =
case "cloudflare-pages":
link = `${window.location.origin}/integrations/cloudflare-pages/authorize`;
break;
- case "codefresh":
++ case "codefresh":
+ link = `${window.location.origin}/integrations/codefresh/authorize`;
+ break;
-
+ case "windmill":
+ link = `${window.location.origin}/integrations/windmill/authorize`;
+ break;
default:
break;
}