Skip to content

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

add way to select a specific git hub app on app connection

Thiago Araujo da Silva3fefbba82a9f
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts
index 30bd09fab4..16c46d8499 100644
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@ -1676,6 +1676,7 @@ export const registerRoutes = async (
secretVersionTagV2BridgeDAL,
resourceMetadataDAL,
appConnectionDAL,
+ gitHubAppDAL,
licenseService,
gatewayService,
gatewayV2Service,
@@ -2509,7 +2510,8 @@ export const registerRoutes = async (
gatewayV2DAL,
projectDAL,
appConnectionCredentialRotationService,
- identityUaDAL
+ identityUaDAL,
+ gitHubAppDAL
});
const honeyTokenConfigService = honeyTokenConfigServiceFactory({
diff --git a/backend/src/services/app-connection/app-connection-fns.ts b/backend/src/services/app-connection/app-connection-fns.ts
index 7ecd7d518c..d1526bb271 100644
--- a/backend/src/services/app-connection/app-connection-fns.ts
+++ b/backend/src/services/app-connection/app-connection-fns.ts
@@ -23,7 +23,9 @@ import {
validateSqlConnectionCredentials
} from "@app/services/app-connection/shared/sql";
import { EXTERNAL_MIGRATION_APP_CONNECTIONS } from "@app/services/external-migration/external-migration-map";
+import { TGitHubAppDALFactory } from "@app/services/github-app/github-app-dal";
import { TIdentityUaDALFactory } from "@app/services/identity-ua/identity-ua-dal";
+import { TKmsServiceFactory } from "@app/services/kms/kms-service";
import { KmsDataKey } from "@app/services/kms/kms-types";
import { SECRET_SYNC_CONNECTION_MAP } from "@app/services/secret-sync/secret-sync-maps";
@@ -141,7 +143,12 @@ import {
} from "./f5-big-ip";
import { FlyioConnectionMethod, getFlyioConnectionListItem, validateFlyioConnectionCredentials } from "./flyio";
import { GcpConnectionMethod, getGcpConnectionListItem, validateGcpConnectionCredentials } from "./gcp";
-import { getGitHubConnectionListItem, GitHubConnectionMethod, validateGitHubConnectionCredentials } from "./github";
+import {
+ getGitHubConnectionListItem,
+ GitHubConnectionMethod,
+ TGitHubConnectionConfig,
+ validateGitHubConnectionCredentials
+} from "./github";
import {
getGitHubRadarConnectionListItem,
GitHubRadarConnectionMethod,
@@ -496,12 +503,20 @@ export const validateAppConnectionCredentials = async (
appConnection: TAppConnectionConfig,
gatewayService: Pick<TGatewayServiceFactory, "fnGetGatewayClientTlsByGatewayId">,
gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">,
- deps: { identityUaDAL: Pick<TIdentityUaDALFactory, "findOne"> }
+ deps: {
+ identityUaDAL: Pick<TIdentityUaDALFactory, "findOne">;
+ gitHubAppDAL: Pick<TGitHubAppDALFactory, "findOne">;
+ kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">;
+ }
): Promise<TAppConnection["credentials"]> => {
const VALIDATE_APP_CONNECTION_CREDENTIALS_MAP: Record<AppConnection, TAppConnectionCredentialsValidator> = {
[AppConnection.AWS]: validateAwsConnectionCredentials as TAppConnectionCredentialsValidator,
[AppConnection.Databricks]: validateDatabricksConnectionCredentials as TAppConnectionCredentialsValidator,
- [AppConnection.GitHub]: validateGitHubConnectionCredentials as TAppConnectionCredentialsValidator,
+ [AppConnection.GitHub]: ((config: TAppConnectionConfig, gw, gw2) =>
+ validateGitHubConnectionCredentials(config as TGitHubConnectionConfig, gw, gw2, {
+ gitHubAppDAL: deps.gitHubAppDAL,
+ kmsService: deps.kmsService
+ })) as TAppConnectionCredentialsValidator,
[AppConnection.GitHubRadar]: validateGitHubRadarConnectionCredentials as TAppConnectionCredentialsValidator,
[AppConnection.GCP]: validateGcpConnectionCredentials as TAppConnectionCredentialsValidator,
[AppConnection.AzureKeyVault]: validateAzureKeyVaultConnectionCredentials as TAppConnectionCredentialsValidator,
diff --git a/backend/src/services/app-connection/app-connection-service.ts b/backend/src/services/app-connection/app-connection-service.ts
index a4d73ad2f7..ebc73a5557 100644
--- a/backend/src/services/app-connection/app-connection-service.ts
+++ b/backend/src/services/app-connection/app-connection-service.ts
@@ -37,6 +37,7 @@ import {
TRANSITION_CONNECTION_CREDENTIALS_TO_PLATFORM,
validateAppConnectionCredentials
} from "@app/services/app-connection/app-connection-fns";
+import { TGitHubAppDALFactory } from "@app/services/github-app/github-app-dal";
import { TIdentityUaDALFactory } from "@app/services/identity-ua/identity-ua-dal";
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
import { TProjectDALFactory } from "@app/services/project/project-dal";
@@ -184,6 +185,7 @@ export type TAppConnectionServiceFactoryDep = {
projectDAL: Pick<TProjectDALFactory, "findProjectById">;
appConnectionCredentialRotationService: TAppConnectionCredentialRotationServiceFactory;
identityUaDAL: Pick<TIdentityUaDALFactory, "findOne">;
+ gitHubAppDAL: Pick<TGitHubAppDALFactory, "findOne">;
};
export type TAppConnectionServiceFactory = ReturnType<typeof appConnectionServiceFactory>;
@@ -271,7 +273,8 @@ export const appConnectionServiceFactory = ({
gatewayV2DAL,
projectDAL,
appConnectionCredentialRotationService,
- identityUaDAL
+ identityUaDAL,
+ gitHubAppDAL
}: TAppConnectionServiceFactoryDep) => {
const listAppConnections = async (actor: OrgServiceActor, app?: AppConnection, projectId?: string) => {
let appConnections: TAppConnections[];
@@ -538,7 +541,7 @@ export const appConnectionServiceFactory = ({
} as TAppConnectionConfig,
gatewayService,
gatewayV2Service,
- { identityUaDAL }
+ { identityUaDAL, gitHubAppDAL, kmsService }
);
try {
@@ -770,7 +773,7 @@ export const appConnectionServiceFactory = ({
} as TAppConnectionConfig,
gatewayService,
gatewayV2Service,
- { identityUaDAL }
+ { identityUaDAL, gitHubAppDAL, kmsService }
);
if (!updatedCredentials)
@@ -1190,7 +1193,10 @@ export const appConnectionServiceFactory = ({
listAvailableAppConnectionsForUser,
findAppConnectionUsageById,
triggerCredentialRotation,
- github: githubConnectionService(connectAppConnectionById, gatewayService, gatewayV2Service, gatewayPoolService),
+ github: githubConnectionService(connectAppConnectionById, gatewayService, gatewayV2Service, gatewayPoolService, {
+ gitHubAppDAL,
+ kmsService
+ }),
githubRadar: githubRadarConnectionService(connectAppConnectionById),
gcp: gcpConnectionService(connectAppConnectionById),
databricks: databricksConnectionService(connectAppConnectionById, appConnectionDAL, kmsService),
diff --git a/backend/src/services/app-connection/github/github-connection-fns.ts b/backend/src/services/app-connection/github/github-connection-fns.ts
index db1b547612..eee8636a8d 100644
--- a/backend/src/services/app-connection/github/github-connection-fns.ts
+++ b/backend/src/services/app-connection/github/github-connection-fns.ts
@@ -15,11 +15,88 @@ import { withGatewayV2Proxy } from "@app/lib/gateway-v2/gateway-v2";
import { logger } from "@app/lib/logger";
import { blockLocalAndPrivateIpAddresses } from "@app/lib/validator";
import { getAppConnectionMethodName } from "@app/services/app-connection/app-connection-fns";
+import { TGitHubAppDALFactory } from "@app/services/github-app/github-app-dal";
+import { TKmsServiceFactory } from "@app/services/kms/kms-service";
+import { KmsDataKey } from "@app/services/kms/kms-types";
import { AppConnection } from "../app-connection-enums";
import { GitHubConnectionMethod } from "./github-connection-enums";
import { TGitHubConnection, TGitHubConnectionConfig } from "./github-connection-types";
+export type TGitHubAppCredentialResolverDeps = {
+ gitHubAppDAL: Pick<TGitHubAppDALFactory, "findOne">;
+ kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">;
+};
+
+type TResolvedGitHubAppCredentials = {
+ appId: string;
+ slug: string;
+ clientId: string;
+ clientSecret: string;
+ privateKey: string;
+};
+
+export const resolveGitHubAppCredentials = async (
+ {
+ gitHubAppId,
+ orgId
+ }: {
+ gitHubAppId?: string | null;
+ orgId: string;
+ },
+ { gitHubAppDAL, kmsService }: TGitHubAppCredentialResolverDeps
+): Promise<TResolvedGitHubAppCredentials> => {
+ if (gitHubAppId) {
+ const app = await gitHubAppDAL.findOne({ id: gitHubAppId, orgId });
+ if (!app) {
+ throw new BadRequestError({
+ message: `GitHub App with id ${gitHubAppId} not found in this organization.`
+ });
+ }
+
+ const { decryptor } = await kmsService.createCipherPairWithDataKey({
+ type: KmsDataKey.Organization,
+ orgId
+ });
+
+ return {
+ appId: decryptor({ cipherTextBlob: app.encryptedAppId }).toString(),
+ slug: decryptor({ cipherTextBlob: app.encryptedSlug }).toString(),
+ clientId: decryptor({ cipherTextBlob: app.encryptedClientId }).toString(),
+ clientSecret: decryptor({ cipherTextBlob: app.encryptedClientSecret }).toString(),
+ privateKey: decryptor({ cipherTextBlob: app.encryptedPrivateKey }).toString()
+ };
+ }
+
+ const {
+ INF_APP_CONNECTION_GITHUB_APP_ID,
+ INF_APP_CONNECTION_GITHUB_APP_SLUG,
+ INF_APP_CONNECTION_GITHUB_APP_CLIENT_ID,
+ INF_APP_CONNECTION_GITHUB_APP_CLIENT_SECRET,
+ INF_APP_CONNECTION_GITHUB_APP_PRIVATE_KEY
+ } = getConfig();
+
+ if (
+ !INF_APP_CONNECTION_GITHUB_APP_ID ||
+ !INF_APP_CONNECTION_GITHUB_APP_SLUG ||
+ !INF_APP_CONNECTION_GITHUB_APP_CLIENT_ID ||
+ !INF_APP_CONNECTION_GITHUB_APP_CLIENT_SECRET ||
+ !INF_APP_CONNECTION_GITHUB_APP_PRIVATE_KEY
+ ) {
+ throw new InternalServerError({
+ message: "GitHub App environment variables have not been configured"
+ });
+ }
+
+ return {
+ appId: INF_APP_CONNECTION_GITHUB_APP_ID,
+ slug: INF_APP_CONNECTION_GITHUB_APP_SLUG,
+ clientId: INF_APP_CONNECTION_GITHUB_APP_CLIENT_ID,
+ clientSecret: INF_APP_CONNECTION_GITHUB_APP_CLIENT_SECRET,
+ privateKey: INF_APP_CONNECTION_GITHUB_APP_PRIVATE_KEY
+ };
+};
+
export const getGitHubConnectionListItem = () => {
const { INF_APP_CONNECTION_GITHUB_OAUTH_CLIENT_ID, INF_APP_CONNECTION_GITHUB_APP_SLUG } = getConfig();
@@ -192,29 +269,25 @@ export const getGitHubAppAuthToken = async (
appConnection: TGitHubConnection,
gatewayService: Pick<TGatewayServiceFactory, "fnGetGatewayClientTlsByGatewayId">,
gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">,
- gatewayPoolService: Pick<TGatewayPoolServiceFactory, "resolveEffectiveGatewayId">
+ gatewayPoolService: Pick<TGatewayPoolServiceFactory, "resolveEffectiveGatewayId">,
+ deps: TGitHubAppCredentialResolverDeps
) => {
- const appCfg = getConfig();
- const appId = appCfg.INF_APP_CONNECTION_GITHUB_APP_ID;
- let appPrivateKey = appCfg.INF_APP_CONNECTION_GITHUB_APP_PRIVATE_KEY;
-
- if (!appId || !appPrivateKey) {
- throw new InternalServerError({
- message: `GitHub App keys are not configured.`
- });
- }
-
- appPrivateKey = appPrivateKey
- .split("\n")
- .map((line) => line.trim())
- .join("\n");
-
if (appConnection.method !== GitHubConnectionMethod.App) {
throw new InternalServerError({ message: "Cannot generate GitHub App token for non-app connection" });
}
assertPlatformGitHubHostAllowed(appConnection.credentials.host);
+ const { appId, privateKey } = await resolveGitHubAppCredentials(
+ { gitHubAppId: appConnection.credentials.gitHubAppId, orgId: appConnection.orgId },
+ deps
+ );
+
+ const appPrivateKey = privateKey
+ .split("\n")
+ .map((line) => line.trim())
+ .join("\n");
+
const now = Math.floor(Date.now() / 1000);
const payload = {
iat: now,
@@ -284,6 +357,7 @@ export const makePaginatedGitHubRequest = async <T, R = T[]>(
gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">,
gatewayPoolService: Pick<TGatewayPoolServiceFactory, "resolveEffectiveGatewayId">,
path: string,
+ deps: TGitHubAppCredentialResolverDeps,
dataMapper?: (data: R) => T[]
): Promise<T[]> => {
const { credentials, method } = appConnection;
@@ -298,7 +372,7 @@ export const makePaginatedGitHubRequest = async <T, R = T[]>(
token = credentials.personalAccessToken;
break;
default:
- token = await getGitHubAppAuthToken(appConnection, gatewayService, gatewayV2Service, gatewayPoolService);
+ token = await getGitHubAppAuthToken(appConnection, gatewayService, gatewayV2Service, gatewayPoolService, deps);
}
const baseUrl = `https://${await getGitHubInstanceApiUrl(appConnection)}${path}`;
@@ -438,7 +512,8 @@ export const getGitHubRepositories = async (
appConnection: TGitHubConnection,
gatewayService: Pick<TGatewayServiceFactory, "fnGetGatewayClientTlsByGatewayId">,
gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">,
- gatewayPoolService: Pick<TGatewayPoolServiceFactory, "resolveEffectiveGatewayId">
+ gatewayPoolService: Pick<TGatewayPoolServiceFactory, "resolveEffectiveGatewayId">,
+ deps: TGitHubAppCredentialResolverDeps
) => {
if (appConnection.method === GitHubConnectionMethod.App) {
return makePaginatedGitHubRequest<GitHubRepository, { repositories: GitHubRepository[] }>(
@@ -447,6 +522,7 @@ export const getGitHubRepositories = async (
gatewayV2Service,
gatewayPoolService,
"/installation/repositories",
+ deps,
(data) => data.repositories
);
}
@@ -456,7 +532,8 @@ export const getGitHubRepositories = async (
gatewayService,
gatewayV2Service,
gatewayPoolService,
- "/user/repos"
+ "/user/repos",
+ deps
);
return repos.filter((repo) => repo.permissions?.admin);
@@ -466,7 +543,8 @@ export const getGitHubOrganizations = async (
appConnection: TGitHubConnection,
gatewayService: Pick<TGatewayServiceFactory, "fnGetGatewayClientTlsByGatewayId">,
gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">,
- gatewayPoolService: Pick<TGatewayPoolServiceFactory, "resolveEffectiveGatewayId">
+ gatewayPoolService: Pick<TGatewayPoolServiceFactory, "resolveEffectiveGatewayId">,
+ deps: TGitHubAppCredentialResolverDeps
) => {
if (appConnection.method === GitHubConnectionMethod.App) {
const installationRepositories = await makePaginatedGitHubRequest<
@@ -478,6 +556,7 @@ export const getGitHubOrganizations = async (
gatewayV2Service,
gatewayPoolService,
"/installation/repositories",
+ deps,
(data) => data.repositories
);
@@ -496,7 +575,8 @@ export const getGitHubOrganizations = async (
gatewayService,
gatewayV2Service,
gatewayPoolService,
- "/user/orgs"
+ "/user/orgs",
+ deps
);
};
@@ -506,7 +586,8 @@ export const getGitHubEnvironments = async (
gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">,
gatewayPoolService: Pick<TGatewayPoolServiceFactory, "resolveEffectiveGatewayId">,
owner: string,
- repo: string
+ repo: string,
+ deps: TGitHubAppCredentialResolverDeps
) => {
try {
return await makePaginatedGitHubRequest<GitHubEnvironment, { environments: GitHubEnvironment[] }>(
@@ -515,6 +596,7 @@ export const getGitHubEnvironments = async (
gatewayV2Service,
gatewayPoolService,
`/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/environments`,
+ deps,
(data) => data.environments
);
} catch (error) {
@@ -542,7 +624,8 @@ export function isGithubErrorResponse(data: GithubTokenRespData): data is Github
export const validateGitHubConnectionCredentials = async (
config: TGitHubConnectionConfig,
gatewayService: Pick<TGatewayServiceFactory, "fnGetGatewayClientTlsByGatewayId">,
- gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">
+ gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">,
+ deps: TGitHubAppCredentialResolverDeps
) => {
const { credentials, method } = config;
@@ -586,25 +669,23 @@ export const validateGitHubConnectionCredentials = async (
}
}
- const {
- INF_APP_CONNECTION_GITHUB_OAUTH_CLIENT_ID,
- INF_APP_CONNECTION_GITHUB_OAUTH_CLIENT_SECRET,
- INF_APP_CONNECTION_GITHUB_APP_CLIENT_ID,
- INF_APP_CONNECTION_GITHUB_APP_CLIENT_SECRET,
- SITE_URL
- } = getConfig();
+ const { INF_APP_CONNECTION_GITHUB_OAUTH_CLIENT_ID, INF_APP_CONNECTION_GITHUB_OAUTH_CLIENT_SECRET, SITE_URL } =
+ getConfig();
- const { clientId, clientSecret } =
- method === GitHubConnectionMethod.App
- ? {
- clientId: INF_APP_CONNECTION_GITHUB_APP_CLIENT_ID,
- clientSecret: INF_APP_CONNECTION_GITHUB_APP_CLIENT_SECRET
- }
- : // oauth
- {
- clientId: INF_APP_CONNECTION_GITHUB_OAUTH_CLIENT_ID,
- clientSecret: INF_APP_CONNECTION_GITHUB_OAUTH_CLIENT_SECRET
- };
+ let clientId: string | undefined;
+ let clientSecret: string | undefined;
+
+ if (method === GitHubConnectionMethod.App) {
+ const resolved = await resolveGitHubAppCredentials(
+ { gitHubAppId: credentials.gitHubAppId, orgId: config.orgId },
+ deps
+ );
+ clientId = resolved.clientId;
+ clientSecret = resolved.clientSecret;
+ } else {
+ clientId = INF_APP_CONNECTION_GITHUB_OAUTH_CLIENT_ID;
+ clientSecret = INF_APP_CONNECTION_GITHUB_OAUTH_CLIENT_SECRET;
+ }
if (!clientId || !clientSecret) {
throw new InternalServerError({
@@ -713,6 +794,7 @@ export const validateGitHubConnectionCredentials = async (
case GitHubConnectionMethod.App:
return {
installationId: credentials.installationId,
+ gitHubAppId: credentials.gitHubAppId ?? null,
instanceType: credentials.instanceType,
host: credentials.host
};
diff --git a/backend/src/services/app-connection/github/github-connection-schemas.ts b/backend/src/services/app-connection/github/github-connection-schemas.ts
index 165a1c59f8..eb6c770a48 100644
--- a/backend/src/services/app-connection/github/github-connection-schemas.ts
+++ b/backend/src/services/app-connection/github/github-connection-schemas.ts
@@ -28,12 +28,14 @@ export const GitHubConnectionAppInputCredentialsSchema = z.union([
z.object({
code: z.string().trim().min(1, "GitHub App code required"),
installationId: z.string().min(1, "GitHub App Installation ID required"),
+ gitHubAppId: z.string().uuid().nullish(),
instanceType: z.literal("server"),
host: z.string().trim().min(1, "Host is required for server instance type")
}),
z.object({
code: z.string().trim().min(1, "GitHub App code required"),
installationId: z.string().min(1, "GitHub App Installation ID required"),
+ gitHubAppId: z.string().uuid().nullish(),
instanceType: z.literal("cloud").optional(),
host: z.string().trim().optional()
})
@@ -68,11 +70,13 @@ export const GitHubConnectionOAuthOutputCredentialsSchema = z.union([
export const GitHubConnectionAppOutputCredentialsSchema = z.union([
z.object({
installationId: z.string(),
+ gitHubAppId: z.string().uuid().nullish(),
instanceType: z.literal("server"),
host: z.string().trim().min(1)
}),
z.object({
installationId: z.string(),
+ gitHubAppId: z.string().uuid().nullish(),
instanceType: z.literal("cloud").optional(),
host: z.string().trim().optional()
})
diff --git a/backend/src/services/app-connection/github/github-connection-service.ts b/backend/src/services/app-connection/github/github-connection-service.ts
index dd590a7d5f..6d5426b350 100644
--- a/backend/src/services/app-connection/github/github-connection-service.ts
+++ b/backend/src/services/app-connection/github/github-connection-service.ts
@@ -6,7 +6,8 @@ import { AppConnection } from "@app/services/app-connection/app-connection-enums
import {
getGitHubEnvironments,
getGitHubOrganizations,
- getGitHubRepositories
+ getGitHubRepositories,
+ TGitHubAppCredentialResolverDeps
} from "@app/services/app-connection/github/github-connection-fns";
import { TGitHubConnection } from "@app/services/app-connection/github/github-connection-types";
@@ -26,7 +27,8 @@ export const githubConnectionService = (
getAppConnection: TGetAppConnectionFunc,
gatewayService: Pick<TGatewayServiceFactory, "fnGetGatewayClientTlsByGatewayId">,
gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">,
- gatewayPoolService: Pick<TGatewayPoolServiceFactory, "resolveEffectiveGatewayId">
+ gatewayPoolService: Pick<TGatewayPoolServiceFactory, "resolveEffectiveGatewayId">,
+ gitHubAppDeps: TGitHubAppCredentialResolverDeps
) => {
const listRepositories = async (connectionId: string, actor: OrgServiceActor) => {
const appConnection = await getAppConnection(AppConnection.GitHub, connectionId, actor);
@@ -35,7 +37,8 @@ export const githubConnectionService = (
appConnection,
gatewayService,
gatewayV2Service,
- gatewayPoolService
+ gatewayPoolService,
+ gitHubAppDeps
);
return repositories;
@@ -48,7 +51,8 @@ export const githubConnectionService = (
appConnection,
gatewayService,
gatewayV2Service,
- gatewayPoolService
+ gatewayPoolService,
+ gitHubAppDeps
);
return organizations;
@@ -66,7 +70,8 @@ export const githubConnectionService = (
gatewayV2Service,
gatewayPoolService,
owner,
- repo
+ repo,
+ gitHubAppDeps
);
return environments;
diff --git a/backend/src/services/app-connection/github/github-connection-types.ts b/backend/src/services/app-connection/github/github-connection-types.ts
index dd454fc823..31c9b1b9c0 100644
--- a/backend/src/services/app-connection/github/github-connection-types.ts
+++ b/backend/src/services/app-connection/github/github-connection-types.ts
@@ -20,4 +20,4 @@ export type TValidateGitHubConnectionCredentialsSchema = typeof ValidateGitHubCo
export type TGitHubConnectionConfig = DiscriminativePick<
TGitHubConnectionInput,
"method" | "app" | "credentials" | "gatewayId" | "gatewayPoolId"
->;
+> & { orgId: string };
diff --git a/backend/src/services/secret-sync/github/github-sync-fns.ts b/backend/src/services/secret-sync/github/github-sync-fns.ts
index 8586ca73f5..6aee7b669a 100644
--- a/backend/src/services/secret-sync/github/github-sync-fns.ts
+++ b/backend/src/services/secret-sync/github/github-sync-fns.ts
@@ -9,7 +9,8 @@ import {
getGitHubInstanceApiUrl,
GitHubConnectionMethod,
makePaginatedGitHubRequest,
- requestWithGitHubGateway
+ requestWithGitHubGateway,
+ TGitHubAppCredentialResolverDeps
} from "@app/services/app-connection/github";
import { GitHubSyncScope, GitHubSyncVisibility } from "@app/services/secret-sync/github/github-sync-enums";
import { SecretSyncError } from "@app/services/secret-sync/secret-sync-errors";
@@ -25,7 +26,8 @@ const getEncryptedSecrets = async (
secretSync: TGitHubSyncWithCredentials,
gatewayService: Pick<TGatewayServiceFactory, "fnGetGatewayClientTlsByGatewayId">,
gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">,
- gatewayPoolService: Pick<TGatewayPoolServiceFactory, "resolveEffectiveGatewayId">
+ gatewayPoolService: Pick<TGatewayPoolServiceFactory, "resolveEffectiveGatewayId">,
+ gitHubAppDeps: TGitHubAppCredentialResolverDeps
) => {
const { destinationConfig, connection } = secretSync;
@@ -52,6 +54,7 @@ const getEncryptedSecrets = async (
gatewayV2Service,
gatewayPoolService,
path,
+ gitHubAppDeps,
(data) => data.secrets
);
};
@@ -233,7 +236,8 @@ export const GithubSyncFns = {
ogSecretMap: TSecretMap,
gatewayService: Pick<TGatewayServiceFactory, "fnGetGatewayClientTlsByGatewayId">,
gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">,
- gatewayPoolService: Pick<TGatewayPoolServiceFactory, "resolveEffectiveGatewayId">
+ gatewayPoolService: Pick<TGatewayPoolServiceFactory, "resolveEffectiveGatewayId">,
+ gitHubAppDeps: TGitHubAppCredentialResolverDeps
) => {
const secretMap = Object.fromEntries(Object.entries(ogSecretMap).map(([i, v]) => [i.toUpperCase(), v]));
@@ -279,7 +283,13 @@ export const GithubSyncFns = {
token = connection.credentials.personalAccessToken;
break;
default:
- token = await getGitHubAppAuthToken(connection, gatewayService, gatewayV2Service, gatewayPoolService);
+ token = await getGitHubAppAuthToken(
+ connection,
+ gatewayService,
+ gatewayV2Service,
+ gatewayPoolService,
+ gitHubAppDeps
+ );
}
const resolvedSync = { ...secretSync, connection };
@@ -287,7 +297,8 @@ export const GithubSyncFns = {
resolvedSync,
gatewayService,
gatewayV2Service,
- gatewayPoolService
+ gatewayPoolService,
+ gitHubAppDeps
);
const publicKey = await getPublicKey(resolvedSync, gatewayService, gatewayV2Service, gatewayPoolService, token);
@@ -334,7 +345,8 @@ export const GithubSyncFns = {
ogSecretMap: TSecretMap,
gatewayService: Pick<TGatewayServiceFactory, "fnGetGatewayClientTlsByGatewayId">,
gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">,
- gatewayPoolService: Pick<TGatewayPoolServiceFactory, "resolveEffectiveGatewayId">
+ gatewayPoolService: Pick<TGatewayPoolServiceFactory, "resolveEffectiveGatewayId">,
+ gitHubAppDeps: TGitHubAppCredentialResolverDeps
) => {
const secretMap = Object.fromEntries(Object.entries(ogSecretMap).map(([i, v]) => [i.toUpperCase(), v]));
@@ -355,14 +367,21 @@ export const GithubSyncFns = {
token = connection.credentials.personalAccessToken;
break;
default:
- token = await getGitHubAppAuthToken(connection, gatewayService, gatewayV2Service, gatewayPoolService);
+ token = await getGitHubAppAuthToken(
+ connection,
+ gatewayService,
+ gatewayV2Service,
+ gatewayPoolService,
+ gitHubAppDeps
+ );
}
const encryptedSecrets = await getEncryptedSecrets(
resolvedSync,
gatewayService,
gatewayV2Service,
- gatewayPoolService
+ gatewayPoolService,
+ gitHubAppDeps
);
for await (const encryptedSecret of encryptedSecrets) {
diff --git a/backend/src/services/secret-sync/secret-sync-fns.ts b/backend/src/services/secret-sync/secret-sync-fns.ts
index a297089bf3..43b12173d7 100644
--- a/backend/src/services/secret-sync/secret-sync-fns.ts
+++ b/backend/src/services/secret-sync/secret-sync-fns.ts
@@ -33,6 +33,7 @@ import {
} from "@app/services/secret-sync/secret-sync-types";
import { TAppConnectionDALFactory } from "../app-connection/app-connection-dal";
+import { TGitHubAppDALFactory } from "../github-app/github-app-dal";
import { TKmsServiceFactory } from "../kms/kms-service";
import { ONEPASS_SYNC_LIST_OPTION, OnePassSyncFns } from "./1password";
import { AwsSecretsManagerSyncMappingBehavior } from "./aws-secrets-manager/aws-secrets-manager-sync-enums";
@@ -166,6 +167,7 @@ export const preSaveTransformDestinationConfig = async (
type TSyncSecretDeps = {
appConnectionDAL: Pick<TAppConnectionDALFactory, "findById" | "update" | "updateById">;
kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">;
+ gitHubAppDAL: Pick<TGitHubAppDALFactory, "findOne">;
gatewayService: Pick<TGatewayServiceFactory, "fnGetGatewayClientTlsByGatewayId">;
gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">;
gatewayPoolService: Pick<TGatewayPoolServiceFactory, "resolveEffectiveGatewayId">;
@@ -294,7 +296,14 @@ export const SecretSyncFns = {
syncSecrets: (
secretSync: TSecretSyncWithCredentials,
secretMap: TSecretMap,
- { kmsService, appConnectionDAL, gatewayService, gatewayV2Service, gatewayPoolService }: TSyncSecretDeps
+ {
+ kmsService,
+ appConnectionDAL,
+ gitHubAppDAL,
+ gatewayService,
+ gatewayV2Service,
+ gatewayPoolService
+ }: TSyncSecretDeps
): Promise<TSyncSecretsResult | void> => {
const schemaSecretMap = addSchema(secretMap, secretSync.environment?.slug || "", secretSync.syncOptions.keySchema);
@@ -309,7 +318,8 @@ export const SecretSyncFns = {
schemaSecretMap,
gatewayService,
gatewayV2Service,
- gatewayPoolService
+ gatewayPoolService,
+ { gitHubAppDAL, kmsService }
);
case SecretSync.GCPSecretManager:
return GcpSyncFns.syncSecrets(secretSync, schemaSecretMap);
@@ -580,7 +590,14 @@ export const SecretSyncFns = {
removeSecrets: (
secretSync: TSecretSyncWithCredentials,
secretMap: TSecretMap,
- { kmsService, appConnectionDAL, gatewayService, gatewayV2Service, gatewayPoolService }: TSyncSecretDeps
+ {
+ kmsService,
+ appConnectionDAL,
+ gitHubAppDAL,
+ gatewayService,
+ gatewayV2Service,
+ gatewayPoolService
+ }: TSyncSecretDeps
): Promise<void> => {
const schemaSecretMap = addSchema(secretMap, secretSync.environment?.slug || "", secretSync.syncOptions.keySchema);
@@ -595,7 +612,8 @@ export const SecretSyncFns = {
schemaSecretMap,
gatewayService,
gatewayV2Service,
- gatewayPoolService
+ gatewayPoolService,
+ { gitHubAppDAL, kmsService }
);
case SecretSync.GCPSecretManager:
return GcpSyncFns.removeSecrets(secretSync, schemaSecretMap);
diff --git a/backend/src/services/secret-sync/secret-sync-queue.ts b/backend/src/services/secret-sync/secret-sync-queue.ts
index 087e4ab470..5fbddee1fa 100644
--- a/backend/src/services/secret-sync/secret-sync-queue.ts
+++ b/backend/src/services/secret-sync/secret-sync-queue.ts
@@ -70,6 +70,7 @@ import { PostHogEventTypes } from "@app/services/telemetry/telemetry-types";
import { TAppConnectionDALFactory } from "../app-connection/app-connection-dal";
import { TFolderCommitServiceFactory } from "../folder-commit/folder-commit-service";
+import { TGitHubAppDALFactory } from "../github-app/github-app-dal";
import { TMicrosoftTeamsServiceFactory } from "../microsoft-teams/microsoft-teams-service";
import { TProjectMicrosoftTeamsConfigDALFactory } from "../microsoft-teams/project-microsoft-teams-config-dal";
import { TNotificationServiceFactory } from "../notification/notification-service";
@@ -89,6 +90,7 @@ type TSecretSyncQueueFactoryDep = {
kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">;
appConnectionDAL: Pick<TAppConnectionDALFactory, "findById" | "update" | "updateById">;
keyStore: Pick<TKeyStoreFactory, "acquireLock" | "incrementByAndRefreshExpiryIfUnderLimit" | "decrementByOrDelete">;
+ gitHubAppDAL: Pick<TGitHubAppDALFactory, "findOne">;
folderDAL: TSecretFolderDALFactory;
secretV2BridgeDAL: Pick<
TSecretV2BridgeDALFactory,
@@ -153,6 +155,7 @@ export const secretSyncQueueFactory = ({
cronJob,
kmsService,
appConnectionDAL,
+ gitHubAppDAL,
keyStore,
folderDAL,
secretV2BridgeDAL,
@@ -424,6 +427,7 @@ export const secretSyncQueueFactory = ({
const importedSecrets = await SecretSyncFns.getSecrets(secretSync, {
appConnectionDAL,
+ gitHubAppDAL,
kmsService,
gatewayService,
gatewayV2Service,
@@ -571,6 +575,7 @@ export const secretSyncQueueFactory = ({
const result = await SecretSyncFns.syncSecrets(secretSyncWithCredentials, secretMap, {
appConnectionDAL,
+ gitHubAppDAL,
kmsService,
gatewayService,
gatewayV2Service,
@@ -835,6 +840,7 @@ export const secretSyncQueueFactory = ({
secretMap,
{
appConnectionDAL,
+ gitHubAppDAL,
kmsService,
gatewayService,
gatewayV2Service,
diff --git a/frontend/src/hooks/api/appConnections/types/github-connection.ts b/frontend/src/hooks/api/appConnections/types/github-connection.ts
index 595e5adbb4..d6c3a29261 100644
--- a/frontend/src/hooks/api/appConnections/types/github-connection.ts
+++ b/frontend/src/hooks/api/appConnections/types/github-connection.ts
@@ -21,6 +21,7 @@ export type TGitHubConnection = TRootAppConnection & { app: AppConnection.GitHub
credentials: {
code: string;
installationId: string;
+ gitHubAppId?: string | null;
instanceType?: "cloud" | "server";
host?: string;
};
diff --git a/frontend/src/hooks/api/gitHubApps/index.ts b/frontend/src/hooks/api/gitHubApps/index.ts
index f6377e42f6..906dc28da4 100644
--- a/frontend/src/hooks/api/gitHubApps/index.ts
+++ b/frontend/src/hooks/api/gitHubApps/index.ts
@@ -1,3 +1,8 @@
export * from "./mutations";
export * from "./queries";
-export type { TDeleteGitHubAppDTO, TExchangeGitHubManifestCodeDTO, TGitHubApp, TRegisterGitHubAppDTO } from "./types";
+export type {
+ TDeleteGitHubAppDTO,
+ TExchangeGitHubManifestCodeDTO,
+ TGitHubApp,
+ TRegisterGitHubAppDTO
+} from "./types";
diff --git a/frontend/src/hooks/api/gitHubApps/mutations.tsx b/frontend/src/hooks/api/gitHubApps/mutations.tsx
index ee08fd4230..e80f4ecc98 100644
--- a/frontend/src/hooks/api/gitHubApps/mutations.tsx
+++ b/frontend/src/hooks/api/gitHubApps/mutations.tsx
@@ -2,7 +2,12 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
-import { TDeleteGitHubAppDTO, TExchangeGitHubManifestCodeDTO, TGitHubApp, TRegisterGitHubAppDTO } from "./types";
+import {
+ TDeleteGitHubAppDTO,
+ TExchangeGitHubManifestCodeDTO,
+ TGitHubApp,
+ TRegisterGitHubAppDTO
+} from "./types";
export const useExchangeGitHubManifestCode = () => {
const queryClient = useQueryClient();
@@ -17,7 +22,9 @@ export const useExchangeGitHubManifestCode = () => {
return data.gitHubApp;
},
onSuccess: () => {
- queryClient.invalidateQueries({ queryKey: ["github-apps"], exact: false });
+ queryClient.invalidateQueries({
+ predicate: (query) => query.queryKey.includes("github-apps")
+ });
}
});
};
@@ -35,7 +42,9 @@ export const useRegisterGitHubApp = () => {
return data.gitHubApp;
},
onSuccess: () => {
- queryClient.invalidateQueries({ queryKey: ["github-apps"], exact: false });
+ queryClient.invalidateQueries({
+ predicate: (query) => query.queryKey.includes("github-apps")
+ });
}
});
};
@@ -52,7 +61,9 @@ export const useDeleteGitHubApp = () => {
return data.gitHubApp;
},
onSuccess: () => {
- queryClient.invalidateQueries({ queryKey: ["github-apps"], exact: false });
+ queryClient.invalidateQueries({
+ predicate: (query) => query.queryKey.includes("github-apps")
+ });
}
});
};
diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/GitHubConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/GitHubConnectionForm.tsx
index c3c145a7f0..2640ec8850 100644
--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/GitHubConnectionForm.tsx
+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/GitHubConnectionForm.tsx
@@ -21,7 +21,7 @@ import {
Tooltip
} from "@app/components/v2";
import { GatewayPicker } from "@app/components/v3/platform/GatewayPicker";
-import { useSubscription } from "@app/context";
+import { useOrganization, useSubscription } from "@app/context";
import {
OrgGatewayPermissionActions,
OrgPermissionSubjects
@@ -38,6 +38,7 @@ import {
useGetAppConnectionOption
} from "@app/hooks/api/appConnections";
import { AppConnection } from "@app/hooks/api/appConnections/enums";
+import { useListGitHubApps } from "@app/hooks/api/gitHubApps";
import { GitHubFormData } from "../../../OauthCallbackPage/OauthCallbackPage.types";
import {
@@ -67,9 +68,22 @@ const baseCredentialsSchema = z.union([
})
]);
+const appCredentialsSchema = z.union([
+ z.object({
+ instanceType: z.literal("server"),
+ host: z.string().min(1, "Host is required for server instance type"),
+ gitHubAppId: z.string().nullish()
+ }),
+ z.object({
+ instanceType: z.literal("cloud").optional(),
+ host: z.string().optional(),
+ gitHubAppId: z.string().nullish()
+ })
+]);
+
const appSchema = rootSchema.extend({
method: z.literal(GitHubConnectionMethod.App),
- credentials: baseCredentialsSchema
+ credentials: appCredentialsSchema
});
const oauthSchema = rootSchema.extend({
@@ -116,7 +130,8 @@ export const GitHubConnectionForm = ({ appConnection, projectId, onSubmit }: Pro
gatewayId: null,
gatewayPoolId: null,
credentials: {
- instanceType: "cloud"
+ instanceType: "cloud",
+ gitHubAppId: null
}
}
});
@@ -130,6 +145,8 @@ export const GitHubConnectionForm = ({ appConnection, projectId, onSubmit }: Pro
} = form;
const { subscription } = useSubscription();
+ const { currentOrg } = useOrganization();
+ const { data: gitHubApps } = useListGitHubApps(currentOrg?.id);
const selectedMethod = watch("method");
const instanceType = watch("credentials.instanceType");
@@ -163,10 +180,15 @@ export const GitHubConnectionForm = ({ appConnection, projectId, onSubmit }: Pro
? `https://${formData.credentials.host}`
: "https://github.com";
+ const selectedAppSlug =
+ formData.method === GitHubConnectionMethod.App && formData.credentials.gitHubAppId
+ ? gitHubApps?.find((app) => app.id === formData.credentials.gitHubAppId)?.slug
+ : appClientSlug;
+
switch (formData.method) {
case GitHubConnectionMethod.App:
window.location.assign(
- `${githubHost}/${formData.credentials?.instanceType === "server" ? "github-apps" : "apps"}/${appClientSlug}/installations/new?state=${state}`
+ `${githubHost}/${formData.credentials?.instanceType === "server" ? "github-apps" : "apps"}/${selectedAppSlug}/installations/new?state=${state}`
);
break;
case GitHubConnectionMethod.OAuth:
@@ -186,7 +208,7 @@ export const GitHubConnectionForm = ({ appConnection, projectId, onSubmit }: Pro
isMissingConfig = !oauthClientId;
break;
case GitHubConnectionMethod.App:
- isMissingConfig = !appClientSlug;
+ isMissingConfig = !appClientSlug && !(gitHubApps && gitHubApps.length > 0);
break;
case GitHubConnectionMethod.Pat:
isMissingConfig = false;
@@ -261,6 +283,41 @@ export const GitHubConnectionForm = ({ appConnection, projectId, onSubmit }: Pro
</FormControl>
)}
/>
+ {selectedMethod === GitHubConnectionMethod.App && (
+ <Controller
+ name={"credentials.gitHubAppId" as never}
+ control={control}
+ shouldUnregister
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl
+ tooltipText="Select which GitHub App to install. Registered apps are managed under Organization Settings > Integrations."
+ errorText={error?.message}
+ isError={Boolean(error?.message)}
+ label="GitHub App"
+ >
+ <Select
+ isDisabled={isUpdate}
+ value={(value as string | null | undefined) ?? "__instance_default__"}
+ onValueChange={(val) => onChange(val === "__instance_default__" ? null : val)}
+ className="w-full border border-mineshaft-500"
+ position="popper"
+ dropdownContainerClassName="max-w-none"
+ >
+ {appClientSlug && (
+ <SelectItem value="__instance_default__" key="__instance_default__">
+ Instance default
+ </SelectItem>
+ )}
+ {(gitHubApps ?? []).map((app) => (
+ <SelectItem value={app.id} key={app.id}>
+ {app.name}
+ </SelectItem>
+ ))}
+ </Select>
+ </FormControl>
+ )}
+ />
+ )}
{selectedMethod === GitHubConnectionMethod.Pat && (
<Controller
name="credentials.personalAccessToken"
diff --git a/frontend/src/pages/organization/AppConnections/OauthCallbackPage/OauthCallbackPage.tsx b/frontend/src/pages/organization/AppConnections/OauthCallbackPage/OauthCallbackPage.tsx
index 6575a07805..5f4c26dea9 100644
--- a/frontend/src/pages/organization/AppConnections/OauthCallbackPage/OauthCallbackPage.tsx
+++ b/frontend/src/pages/organization/AppConnections/OauthCallbackPage/OauthCallbackPage.tsx
@@ -364,6 +364,7 @@ export const OAuthCallbackPage = () => {
let connection: TAppConnection;
try {
+ const gitHubAppId = (credentials as { gitHubAppId?: string | null } | undefined)?.gitHubAppId;
if (connectionId) {
connection = await updateAppConnection.mutateAsync({
app: AppConnection.GitHub,
@@ -373,6 +374,7 @@ export const OAuthCallbackPage = () => {
credentials: {
code: code as string,
installationId: installationId as string,
+ ...(gitHubAppId !== undefined && { gitHubAppId }),
...(credentials?.instanceType && { instanceType: credentials.instanceType }),
...(credentials?.host && { host: credentials.host })
},
@@ -401,6 +403,7 @@ export const OAuthCallbackPage = () => {
code: code as string,
...(credentials?.instanceType && { instanceType: credentials.instanceType }),
installationId: installationId as string,
+ ...(gitHubAppId !== undefined && { gitHubAppId }),
...(credentials?.host && { host: credentials.host })
},
gatewayId
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgIntegrationTab/AddGitHubAppModal.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgIntegrationTab/AddIntegrationModal.tsx
similarity index 63%
rename from frontend/src/pages/organization/SettingsPage/components/OrgIntegrationTab/AddGitHubAppModal.tsx
rename to frontend/src/pages/organization/SettingsPage/components/OrgIntegrationTab/AddIntegrationModal.tsx
index 94adf7972f..9d91a408be 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgIntegrationTab/AddGitHubAppModal.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgIntegrationTab/AddIntegrationModal.tsx
@@ -2,7 +2,8 @@ import crypto from "crypto";
import { useState } from "react";
import { Controller, useForm } from "react-hook-form";
-import { faGithub } from "@fortawesome/free-brands-svg-icons";
+import { BsMicrosoftTeams } from "react-icons/bs";
+import { faGithub, faSlack } from "@fortawesome/free-brands-svg-icons";
import { faArrowRight, faFileImport, faPlusCircle } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { zodResolver } from "@hookform/resolvers/zod";
@@ -13,23 +14,57 @@ import { createNotification } from "@app/components/notifications";
import { Button, FormControl, Input, Modal, ModalContent, TextArea } from "@app/components/v2";
import { useOrganization } from "@app/context";
import { useRegisterGitHubApp } from "@app/hooks/api/gitHubApps";
+import { WorkflowIntegrationPlatform } from "@app/hooks/api/workflowIntegrations/types";
+
+import { MicrosoftTeamsIntegrationForm } from "./MicrosoftTeamsIntegrationForm";
+import { SlackIntegrationForm } from "./SlackIntegrationForm";
type Props = {
isOpen?: boolean;
onToggle: (isOpen: boolean) => void;
};
+enum AppPlatform {
+ GitHub = "github"
+}
+
+type SelectedPlatform =
+ | WorkflowIntegrationPlatform.SLACK
+ | WorkflowIntegrationPlatform.MICROSOFT_TEAMS
+ | AppPlatform.GitHub
+ | null;
+
enum WizardSteps {
SelectPlatform = "select-platform",
- SelectMethod = "select-method",
+ WorkflowInputs = "workflow-inputs",
+ GitHubSelectMethod = "github-select-method",
GitHubManifest = "github-manifest",
GitHubManual = "github-manual"
}
-const PLATFORM_LIST = [
+type PlatformOption = {
+ icon: React.ReactNode;
+ platform: SelectedPlatform;
+ title: string;
+};
+
+const WORKFLOW_PLATFORMS: PlatformOption[] = [
+ {
+ icon: <FontAwesomeIcon icon={faSlack} size="lg" />,
+ platform: WorkflowIntegrationPlatform.SLACK,
+ title: "Slack"
+ },
+ {
+ icon: <BsMicrosoftTeams className="text-lg" />,
+ platform: WorkflowIntegrationPlatform.MICROSOFT_TEAMS,
+ title: "Microsoft Teams"
+ }
+];
+
+const APP_PLATFORMS: PlatformOption[] = [
{
icon: <FontAwesomeIcon icon={faGithub} size="lg" />,
- platform: "github",
+ platform: AppPlatform.GitHub,
title: "GitHub"
}
];
@@ -51,15 +86,24 @@ const manualFormSchema = z.object({
type TManifestFormData = z.infer<typeof manifestFormSchema>;
type TManualFormData = z.infer<typeof manualFormSchema>;
+const slugifyGitHubAppName = (name: string) =>
+ `infisical-${name
+ .trim()
+ .toLowerCase()
+ .replace(/\s+/g, "-")
+ .replace(/[^a-z0-9-]/g, "")
+ .replace(/-+/g, "-")
+ .replace(/^-|-$/g, "")}`;
+
const buildGitHubManifest = ({ orgId, name }: { orgId: string; name: string }) => {
const redirectUrl = `${window.location.origin}/organizations/${orgId}/settings/github-app/callback`;
return {
- name,
+ name: slugifyGitHubAppName(name),
url: window.location.origin,
redirect_url: redirectUrl,
callback_urls: [`${window.location.origin}/organization/app-connections/github/oauth/callback`],
- description: `Infisical GitHub App for organization ${orgId}`,
+ description: "Infisical GitHub App Integration",
public: false,
request_oauth_on_install: true,
default_permissions: {
@@ -105,9 +149,9 @@ const submitManifestForm = ({
form.submit();
};
-export const AddGitHubAppModal = ({ isOpen, onToggle }: Props) => {
+export const AddIntegrationModal = ({ isOpen, onToggle }: Props) => {
const [wizardStep, setWizardStep] = useState(WizardSteps.SelectPlatform);
- const [selectedPlatform, setSelectedPlatform] = useState<string | null>(null);
+ const [selectedPlatform, setSelectedPlatform] = useState<SelectedPlatform>(null);
const { currentOrg } = useOrganization();
const registerGitHubApp = useRegisterGitHubApp();
@@ -128,6 +172,15 @@ export const AddGitHubAppModal = ({ isOpen, onToggle }: Props) => {
manualForm.reset();
};
+ const handleSelectPlatform = (platform: SelectedPlatform) => {
+ setSelectedPlatform(platform);
+ if (platform === AppPlatform.GitHub) {
+ setWizardStep(WizardSteps.GitHubSelectMethod);
+ } else {
+ setWizardStep(WizardSteps.WorkflowInputs);
+ }
+ };
+
const handleSubmitManifest = ({ name, organization }: TManifestFormData) => {
if (!currentOrg) return;
submitManifestForm({ orgId: currentOrg.id, name, organization });
@@ -152,10 +205,29 @@ export const AddGitHubAppModal = ({ isOpen, onToggle }: Props) => {
const getModalTitle = () => {
if (wizardStep === WizardSteps.GitHubManifest) return "Create a new GitHub App";
if (wizardStep === WizardSteps.GitHubManual) return "Register an existing GitHub App";
- if (selectedPlatform === "github") return "Add a GitHub App";
- return "Add an app integration";
+ if (selectedPlatform === WorkflowIntegrationPlatform.SLACK) return "Add a Slack integration";
+ if (selectedPlatform === WorkflowIntegrationPlatform.MICROSOFT_TEAMS)
+ return "Add a Microsoft Teams integration";
+ if (selectedPlatform === AppPlatform.GitHub) return "Add a GitHub App";
+ return "Add an integration";
};
+ const renderPlatformCard = ({ icon, platform, title }: PlatformOption) => (
+ <div
+ key={platform ?? title}
+ className="flex h-28 w-32 cursor-pointer flex-col items-center space-y-4 rounded-sm border border-mineshaft-500 bg-bunker-600 p-6 transition-all hover:border-primary/70 hover:bg-primary/10 hover:text-white"
+ role="button"
+ tabIndex={0}
+ onClick={() => handleSelectPlatform(platform)}
+ onKeyDown={(evt) => {
+ if (evt.key === "Enter") handleSelectPlatform(platform);
+ }}
+ >
+ <div>{icon}</div>
+ <div className="text-center text-sm whitespace-pre-wrap">{title}</div>
+ </div>
+ );
+
return (
<Modal isOpen={isOpen} onOpenChange={(state) => handleFormReset(state)}>
<ModalContent title={getModalTitle()} className="my-4">
@@ -168,97 +240,113 @@ export const AddGitHubAppModal = ({ isOpen, onToggle }: Props) => {
animate={{ opacity: 1, translateX: 0 }}
exit={{ opacity: 0, translateX: -30 }}
>
- <div className="mb-4 text-mineshaft-300">Select a platform</div>
+ <div className="mb-2 text-sm font-medium text-mineshaft-200">Workflow</div>
+ <div className="mb-6 flex items-center space-x-4">
+ {WORKFLOW_PLATFORMS.map(renderPlatformCard)}
+ </div>
+ <div className="mb-2 text-sm font-medium text-mineshaft-200">Apps</div>
<div className="flex items-center space-x-4">
- {PLATFORM_LIST.map(({ icon, platform, title }) => (
+ {APP_PLATFORMS.map(renderPlatformCard)}
+ </div>
+ </motion.div>
+ )}
+ {wizardStep === WizardSteps.WorkflowInputs &&
+ selectedPlatform === WorkflowIntegrationPlatform.SLACK && (
+ <motion.div
+ key="slack-platform"
+ transition={{ duration: 0.1 }}
+ initial={{ opacity: 0, translateX: 30 }}
+ animate={{ opacity: 1, translateX: 0 }}
+ exit={{ opacity: 0, translateX: -30 }}
+ >
+ <SlackIntegrationForm onClose={() => handleFormReset(false)} />
+ </motion.div>
+ )}
+ {wizardStep === WizardSteps.WorkflowInputs &&
+ selectedPlatform === WorkflowIntegrationPlatform.MICROSOFT_TEAMS && (
+ <motion.div
+ key="microsoft-teams-platform"
+ transition={{ duration: 0.1 }}
+ initial={{ opacity: 0, translateX: 30 }}
+ animate={{ opacity: 1, translateX: 0 }}
+ exit={{ opacity: 0, translateX: -30 }}
+ >
+ <MicrosoftTeamsIntegrationForm onClose={() => handleFormReset(false)} />
+ </motion.div>
+ )}
+ {wizardStep === WizardSteps.GitHubSelectMethod &&
+ selectedPlatform === AppPlatform.GitHub && (
+ <motion.div
+ key="github-select-method"
+ transition={{ duration: 0.1 }}
+ initial={{ opacity: 0, translateX: 30 }}
+ animate={{ opacity: 1, translateX: 0 }}
+ exit={{ opacity: 0, translateX: -30 }}
+ >
+ <div className="mb-4 text-mineshaft-300">
+ How would you like to add a GitHub App?
+ </div>
+ <div className="flex flex-col space-y-3">
<div
- key={platform}
- className="flex h-28 w-32 cursor-pointer flex-col items-center space-y-4 rounded-sm border border-mineshaft-500 bg-bunker-600 p-6 transition-all hover:border-primary/70 hover:bg-primary/10 hover:text-white"
+ className="flex cursor-pointer items-start space-x-4 rounded-md border border-mineshaft-500 bg-bunker-600 p-4 transition-all hover:border-primary/70 hover:bg-primary/10"
role="button"
tabIndex={0}
- onClick={() => {
- setSelectedPlatform(platform);
- setWizardStep(WizardSteps.SelectMethod);
- }}
+ onClick={() => setWizardStep(WizardSteps.GitHubManifest)}
onKeyDown={(evt) => {
- if (evt.key === "Enter") {
- setSelectedPlatform(platform);
- setWizardStep(WizardSteps.SelectMethod);
- }
+ if (evt.key === "Enter") setWizardStep(WizardSteps.GitHubManifest);
}}
>
- <div>{icon}</div>
- <div className="text-center text-sm whitespace-pre-wrap">{title}</div>
- </div>
- ))}
- </div>
- </motion.div>
- )}
- {wizardStep === WizardSteps.SelectMethod && selectedPlatform === "github" && (
- <motion.div
- key="select-method"
- transition={{ duration: 0.1 }}
- initial={{ opacity: 0, translateX: 30 }}
- animate={{ opacity: 1, translateX: 0 }}
- exit={{ opacity: 0, translateX: -30 }}
- >
- <div className="mb-4 text-mineshaft-300">How would you like to add a GitHub App?</div>
- <div className="flex flex-col space-y-3">
- <div
- className="flex cursor-pointer items-start space-x-4 rounded-md border border-mineshaft-500 bg-bunker-600 p-4 transition-all hover:border-primary/70 hover:bg-primary/10"
- role="button"
- tabIndex={0}
- onClick={() => setWizardStep(WizardSteps.GitHubManifest)}
- onKeyDown={(evt) => {
- if (evt.key === "Enter") setWizardStep(WizardSteps.GitHubManifest);
- }}
- >
- <div className="mt-0.5 text-primary">
- <FontAwesomeIcon icon={faPlusCircle} size="lg" />
- </div>
- <div>
- <div className="font-medium text-mineshaft-100">Create via GitHub Manifest</div>
- <div className="mt-1 text-sm text-mineshaft-400">
- Let Infisical guide you through creating a new GitHub App directly on GitHub.
- Recommended for new setups.
+ <div className="mt-0.5 text-primary">
+ <FontAwesomeIcon icon={faPlusCircle} size="lg" />
</div>
- </div>
- <div className="ml-auto self-center text-mineshaft-400">
- <FontAwesomeIcon icon={faArrowRight} />
- </div>
- </div>
- <div
- className="flex cursor-pointer items-start space-x-4 rounded-md border border-mineshaft-500 bg-bunker-600 p-4 transition-all hover:border-primary/70 hover:bg-primary/10"
- role="button"
- tabIndex={0}
- onClick={() => setWizardStep(WizardSteps.GitHubManual)}
- onKeyDown={(evt) => {
- if (evt.key === "Enter") setWizardStep(WizardSteps.GitHubManual);
- }}
- >
- <div className="mt-0.5 text-primary">
- <FontAwesomeIcon icon={faFileImport} size="lg" />
- </div>
- <div>
- <div className="font-medium text-mineshaft-100">Register Existing App</div>
- <div className="mt-1 text-sm text-mineshaft-400">
- Already have a GitHub App? Provide its credentials to register it with
- Infisical.
+ <div>
+ <div className="font-medium text-mineshaft-100">
+ Create via GitHub Manifest
+ </div>
+ <div className="mt-1 text-sm text-mineshaft-400">
+ Let Infisical guide you through creating a new GitHub App directly on
+ GitHub. Recommended for new setups.
+ </div>
+ </div>
+ <div className="ml-auto self-center text-mineshaft-400">
+ <FontAwesomeIcon icon={faArrowRight} />
</div>
</div>
- <div className="ml-auto self-center text-mineshaft-400">
- <FontAwesomeIcon icon={faArrowRight} />
+ <div
+ className="flex cursor-pointer items-start space-x-4 rounded-md border border-mineshaft-500 bg-bunker-600 p-4 transition-all hover:border-primary/70 hover:bg-primary/10"
+ role="button"
+ tabIndex={0}
+ onClick={() => setWizardStep(WizardSteps.GitHubManual)}
+ onKeyDown={(evt) => {
+ if (evt.key === "Enter") setWizardStep(WizardSteps.GitHubManual);
+ }}
+ >
+ <div className="mt-0.5 text-primary">
+ <FontAwesomeIcon icon={faFileImport} size="lg" />
+ </div>
+ <div>
+ <div className="font-medium text-mineshaft-100">Register Existing App</div>
+ <div className="mt-1 text-sm text-mineshaft-400">
+ Already have a GitHub App? Provide its credentials to register it with
+ Infisical.
+ </div>
+ </div>
+ <div className="ml-auto self-center text-mineshaft-400">
+ <FontAwesomeIcon icon={faArrowRight} />
+ </div>
</div>
</div>
- </div>
- <div className="mt-4">
- <Button variant="outline_bg" onClick={() => setWizardStep(WizardSteps.SelectPlatform)}>
- Back
- </Button>
- </div>
- </motion.div>
- )}
- {wizardStep === WizardSteps.GitHubManifest && selectedPlatform === "github" && (
+ <div className="mt-4">
+ <Button
+ variant="outline_bg"
+ onClick={() => setWizardStep(WizardSteps.SelectPlatform)}
+ >
+ Back
+ </Button>
+ </div>
+ </motion.div>
+ )}
+ {wizardStep === WizardSteps.GitHubManifest && selectedPlatform === AppPlatform.GitHub && (
<motion.div
key="github-manifest"
transition={{ duration: 0.1 }}
@@ -273,17 +361,14 @@ export const AddGitHubAppModal = ({ isOpen, onToggle }: Props) => {
any of your GitHub organizations and use it as the basis for GitHub App connections
in Infisical.
</div>
- <form
- onSubmit={manifestForm.handleSubmit(handleSubmitManifest)}
- autoComplete="off"
- >
+ <form onSubmit={manifestForm.handleSubmit(handleSubmitManifest)} autoComplete="off">
<Controller
control={manifestForm.control}
name="name"
render={({ field, fieldState: { error } }) => (
<FormControl
label="GitHub App name"
- helperText="Used as the GitHub App's display name. Must be unique within this organization."
+ helperText="Used to identify this app in Infisical. Sent to GitHub as a slugified name prefixed with 'infisical-'."
isRequired
errorText={error?.message}
isError={Boolean(error)}
@@ -316,7 +401,7 @@ export const AddGitHubAppModal = ({ isOpen, onToggle }: Props) => {
</Button>
<Button
variant="outline_bg"
- onClick={() => setWizardStep(WizardSteps.SelectMethod)}
+ onClick={() => setWizardStep(WizardSteps.GitHubSelectMethod)}
>
Back
</Button>
@@ -324,7 +409,7 @@ export const AddGitHubAppModal = ({ isOpen, onToggle }: Props) => {
</form>
</motion.div>
)}
- {wizardStep === WizardSteps.GitHubManual && selectedPlatform === "github" && (
+ {wizardStep === WizardSteps.GitHubManual && selectedPlatform === AppPlatform.GitHub && (
<motion.div
key="github-manual"
transition={{ duration: 0.1 }}
@@ -336,10 +421,7 @@ export const AddGitHubAppModal = ({ isOpen, onToggle }: Props) => {
Provide your existing GitHub App credentials. These will be securely encrypted and
stored in Infisical.
</div>
- <form
- onSubmit={manualForm.handleSubmit(handleSubmitManual)}
- autoComplete="off"
- >
+ <form onSubmit={manualForm.handleSubmit(handleSubmitManual)} autoComplete="off">
<Controller
control={manualForm.control}
name="name"
@@ -444,7 +526,7 @@ export const AddGitHubAppModal = ({ isOpen, onToggle }: Props) => {
</Button>
<Button
variant="outline_bg"
- onClick={() => setWizardStep(WizardSteps.SelectMethod)}
+ onClick={() => setWizardStep(WizardSteps.GitHubSelectMethod)}
>
Back
</Button>
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgIntegrationTab/AddWorkflowIntegrationForm.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgIntegrationTab/AddWorkflowIntegrationForm.tsx
deleted file mode 100644
index 15acf5c975..0000000000
--- a/frontend/src/pages/organization/SettingsPage/components/OrgIntegrationTab/AddWorkflowIntegrationForm.tsx
+++ /dev/null
@@ -1,115 +0,0 @@
-import { useState } from "react";
-import { BsMicrosoftTeams } from "react-icons/bs";
-import { faSlack } from "@fortawesome/free-brands-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { AnimatePresence, motion } from "framer-motion";
-
-import { Modal, ModalContent } from "@app/components/v2";
-import { WorkflowIntegrationPlatform } from "@app/hooks/api/workflowIntegrations/types";
-
-import { MicrosoftTeamsIntegrationForm } from "./MicrosoftTeamsIntegrationForm";
-import { SlackIntegrationForm } from "./SlackIntegrationForm";
-
-type Props = {
- isOpen?: boolean;
- onToggle: (isOpen: boolean) => void;
-};
-
-enum WizardSteps {
- SelectPlatform = "select-platform",
- PlatformInputs = "platform-inputs"
-}
-
-const PLATFORM_LIST = [
- {
- icon: <FontAwesomeIcon icon={faSlack} size="lg" />,
- platform: WorkflowIntegrationPlatform.SLACK,
- title: "Slack"
- },
- {
- icon: <BsMicrosoftTeams className="text-lg" />,
- platform: WorkflowIntegrationPlatform.MICROSOFT_TEAMS,
- title: "Microsoft Teams"
- }
-];
-
-export const AddWorkflowIntegrationForm = ({ isOpen, onToggle }: Props) => {
- const [wizardStep, setWizardStep] = useState(WizardSteps.SelectPlatform);
- const [selectedPlatform, setSelectedPlatform] = useState<string | null>(null);
-
- const handleFormReset = (state: boolean = false) => {
- onToggle(state);
- setWizardStep(WizardSteps.SelectPlatform);
- setSelectedPlatform(null);
- };
-
- return (
- <Modal isOpen={isOpen} onOpenChange={(state) => handleFormReset(state)}>
- <ModalContent
- title={`Add a ${selectedPlatform?.replace("-", " ").replace(/\b\w/g, (char) => char.toUpperCase()) ?? "workflow"} integration`}
- className="my-4"
- >
- <AnimatePresence mode="wait">
- {wizardStep === WizardSteps.SelectPlatform && (
- <motion.div
- key="select-type-step"
- transition={{ duration: 0.1 }}
- initial={{ opacity: 0, translateX: 30 }}
- animate={{ opacity: 1, translateX: 0 }}
- exit={{ opacity: 0, translateX: -30 }}
- >
- <div className="mb-4 text-mineshaft-300">Select a platform</div>
- <div className="flex items-center space-x-4">
- {PLATFORM_LIST.map(({ icon, platform, title }) => (
- <div
- key={platform}
- className="flex h-28 w-32 cursor-pointer flex-col items-center space-y-4 rounded-sm border border-mineshaft-500 bg-bunker-600 p-6 transition-all hover:border-primary/70 hover:bg-primary/10 hover:text-white"
- role="button"
- tabIndex={0}
- onClick={() => {
- setSelectedPlatform(platform);
- setWizardStep(WizardSteps.PlatformInputs);
- }}
- onKeyDown={(evt) => {
- if (evt.key === "Enter") {
- setSelectedPlatform(platform);
- setWizardStep(WizardSteps.PlatformInputs);
- }
- }}
- >
- <div>{icon}</div>
- <div className="text-center text-sm whitespace-pre-wrap">{title}</div>
- </div>
- ))}
- </div>
- </motion.div>
- )}
- {wizardStep === WizardSteps.PlatformInputs &&
- selectedPlatform === WorkflowIntegrationPlatform.SLACK && (
- <motion.div
- key="slack-platform"
- transition={{ duration: 0.1 }}
- initial={{ opacity: 0, translateX: 30 }}
- animate={{ opacity: 1, translateX: 0 }}
- exit={{ opacity: 0, translateX: -30 }}
- >
- <SlackIntegrationForm onClose={() => onToggle(false)} />
- </motion.div>
- )}
- {wizardStep === WizardSteps.PlatformInputs &&
- selectedPlatform === WorkflowIntegrationPlatform.MICROSOFT_TEAMS && (
- <motion.div
- key="microsoft-teams-platform"
- transition={{ duration: 0.1 }}
- initial={{ opacity: 0, translateX: 30 }}
- animate={{ opacity: 1, translateX: 0 }}
- exit={{ opacity: 0, translateX: -30 }}
- >
- <MicrosoftTeamsIntegrationForm onClose={() => onToggle(false)} />
- </motion.div>
- )}
- </AnimatePresence>
- </ModalContent>
- </Modal>
- );
-};
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgIntegrationTab/OrgAppsSection.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgIntegrationTab/GitHubAppsTable.tsx
similarity index 73%
rename from frontend/src/pages/organization/SettingsPage/components/OrgIntegrationTab/OrgAppsSection.tsx
rename to frontend/src/pages/organization/SettingsPage/components/OrgIntegrationTab/GitHubAppsTable.tsx
index 22f9455ff8..1dbdd78616 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgIntegrationTab/OrgAppsSection.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgIntegrationTab/GitHubAppsTable.tsx
@@ -1,13 +1,11 @@
import { faGithub } from "@fortawesome/free-brands-svg-icons";
-import { faEllipsis, faPlug, faPlus } from "@fortawesome/free-solid-svg-icons";
+import { faEllipsis, faPlug, faTrash } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { format } from "date-fns";
import { twMerge } from "tailwind-merge";
import { createNotification } from "@app/components/notifications";
import { OrgPermissionCan } from "@app/components/permissions";
import {
- Button,
DeleteActionModal,
DropdownMenu,
DropdownMenuContent,
@@ -26,11 +24,8 @@ import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@a
import { usePopUp } from "@app/hooks";
import { useDeleteGitHubApp, useListGitHubApps } from "@app/hooks/api/gitHubApps";
-import { AddGitHubAppModal } from "./AddGitHubAppModal";
-
-export const OrgAppsSection = () => {
+export const GitHubAppsTable = () => {
const { popUp, handlePopUpOpen, handlePopUpToggle, handlePopUpClose } = usePopUp([
- "addAppConnection",
"removeAppConnection"
] as const);
@@ -43,10 +38,10 @@ export const OrgAppsSection = () => {
if (!popUp.removeAppConnection?.data?.id) return;
try {
await deleteGitHubApp({ id: popUp.removeAppConnection.data.id as string });
- createNotification({ text: "Successfully removed GitHub App.", type: "success" });
+ createNotification({ text: "Successfully removed app.", type: "success" });
} catch (err) {
createNotification({
- text: (err as Error).message || "Failed to delete GitHub App.",
+ text: (err as Error).message || "Failed to app.",
type: "error"
});
} finally {
@@ -55,22 +50,7 @@ export const OrgAppsSection = () => {
};
return (
- <div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
- <div className="flex justify-between">
- <p className="text-xl font-medium text-mineshaft-100">Apps</p>
- <OrgPermissionCan I={OrgPermissionActions.Create} an={OrgPermissionSubjects.Settings}>
- {(isAllowed) => (
- <Button
- onClick={() => handlePopUpOpen("addAppConnection")}
- isDisabled={!isAllowed}
- leftIcon={<FontAwesomeIcon icon={faPlus} />}
- >
- Add
- </Button>
- )}
- </OrgPermissionCan>
- </div>
- <p className="mb-4 text-gray-400">Connect Infisical to other apps for app connections integrations.</p>
+ <>
<TableContainer>
<Table>
<THead>
@@ -79,15 +59,14 @@ export const OrgAppsSection = () => {
<Td>Name</Td>
<Td>App ID</Td>
<Td>Slug</Td>
- <Td>Created</Td>
<Td />
</Tr>
</THead>
<TBody>
- {isPending && <TableSkeleton columns={6} innerKey="github-apps-loading" />}
+ {isPending && <TableSkeleton columns={5} innerKey="github-apps-loading" />}
{!isPending && gitHubApps && gitHubApps.length === 0 && (
<Tr>
- <Td colSpan={6}>
+ <Td colSpan={5}>
<EmptyState title="No app integrations found" icon={faPlug} />
</Td>
</Tr>
@@ -110,7 +89,6 @@ export const OrgAppsSection = () => {
{app.slug}
</a>
</Td>
- <Td>{format(new Date(app.createdAt), "yyyy-MM-dd")}</Td>
<Td>
<DropdownMenu>
<DropdownMenuTrigger asChild className="rounded-lg">
@@ -125,8 +103,10 @@ export const OrgAppsSection = () => {
>
{(isAllowed) => (
<DropdownMenuItem
- disabled={!isAllowed}
+ isDisabled={!isAllowed}
+ icon={<FontAwesomeIcon icon={faTrash} />}
className={twMerge(
+ "text-red",
!isAllowed && "pointer-events-none cursor-not-allowed opacity-50"
)}
onClick={(e) => {
@@ -137,7 +117,7 @@ export const OrgAppsSection = () => {
});
}}
>
- Delete
+ Delete app
</DropdownMenuItem>
)}
</OrgPermissionCan>
@@ -149,10 +129,6 @@ export const OrgAppsSection = () => {
</TBody>
</Table>
</TableContainer>
- <AddGitHubAppModal
- isOpen={popUp.addAppConnection.isOpen}
- onToggle={(state) => handlePopUpToggle("addAppConnection", state)}
- />
<DeleteActionModal
isOpen={popUp.removeAppConnection.isOpen}
title={`Are you sure you want to remove ${popUp?.removeAppConnection?.data?.name as string}?`}
@@ -160,6 +136,6 @@ export const OrgAppsSection = () => {
deleteKey="confirm"
onDeleteApproved={handleRemove}
/>
- </div>
+ </>
);
};
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgIntegrationTab/OrgIntegrationTab.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgIntegrationTab/OrgIntegrationTab.tsx
index 0c97321be9..ec80f4be4b 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgIntegrationTab/OrgIntegrationTab.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgIntegrationTab/OrgIntegrationTab.tsx
@@ -1,15 +1,9 @@
import { OrgPermissionActions, OrgPermissionSubjects } from "@app/context";
import { withPermission } from "@app/hoc";
-import { OrgAppsSection } from "./OrgAppsSection";
-import { OrgWorkflowIntegrationSection } from "./OrgWorkflowIntegrationSection";
+import { OrgIntegrationsSection } from "./OrgIntegrationsSection";
-export const OrgIntegrationTab = withPermission(
- () => (
- <>
- <OrgWorkflowIntegrationSection />
- <OrgAppsSection />
- </>
- ),
- { action: OrgPermissionActions.Read, subject: OrgPermissionSubjects.Settings }
-);
+export const OrgIntegrationTab = withPermission(() => <OrgIntegrationsSection />, {
+ action: OrgPermissionActions.Read,
+ subject: OrgPermissionSubjects.Settings
+});
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgIntegrationTab/OrgIntegrationsSection.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgIntegrationTab/OrgIntegrationsSection.tsx
new file mode 100644
index 0000000000..634c079ea4
--- /dev/null
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgIntegrationTab/OrgIntegrationsSection.tsx
@@ -0,0 +1,48 @@
+import { faPlus } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { OrgPermissionCan } from "@app/components/permissions";
+import { Button } from "@app/components/v2";
+import { OrgPermissionActions, OrgPermissionSubjects } from "@app/context";
+import { usePopUp } from "@app/hooks";
+
+import { AddIntegrationModal } from "./AddIntegrationModal";
+import { GitHubAppsTable } from "./GitHubAppsTable";
+import { WorkflowIntegrationsTable } from "./WorkflowIntegrationsTable";
+
+export const OrgIntegrationsSection = () => {
+ const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp(["addIntegration"] as const);
+
+ return (
+ <div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <div className="flex justify-between">
+ <p className="text-xl font-medium text-mineshaft-100">Integrations</p>
+ <OrgPermissionCan I={OrgPermissionActions.Create} an={OrgPermissionSubjects.Settings}>
+ {(isAllowed) => (
+ <Button
+ onClick={() => handlePopUpOpen("addIntegration")}
+ isDisabled={!isAllowed}
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ >
+ Add
+ </Button>
+ )}
+ </OrgPermissionCan>
+ </div>
+ <p className="mb-4 text-gray-400">
+ Connect Infisical to other platforms for workflow notifications and app integrations.
+ </p>
+
+ <div className="mb-2 text-sm font-medium text-mineshaft-200">Workflow</div>
+ <WorkflowIntegrationsTable />
+
+ <div className="mt-6 mb-2 text-sm font-medium text-mineshaft-200">Apps</div>
+ <GitHubAppsTable />
+
+ <AddIntegrationModal
+ isOpen={popUp.addIntegration.isOpen}
+ onToggle={(state) => handlePopUpToggle("addIntegration", state)}
+ />
+ </div>
+ );
+};
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgIntegrationTab/OrgWorkflowIntegrationSection.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgIntegrationTab/WorkflowIntegrationsTable.tsx
similarity index 89%
rename from frontend/src/pages/organization/SettingsPage/components/OrgIntegrationTab/OrgWorkflowIntegrationSection.tsx
rename to frontend/src/pages/organization/SettingsPage/components/OrgIntegrationTab/WorkflowIntegrationsTable.tsx
index 92cca0734f..a790f78396 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgIntegrationTab/OrgWorkflowIntegrationSection.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgIntegrationTab/WorkflowIntegrationsTable.tsx
@@ -1,5 +1,5 @@
import { BsMicrosoftTeams, BsSlack } from "react-icons/bs";
-import { faEllipsis, faGear, faInfoCircle, faPlus } from "@fortawesome/free-solid-svg-icons";
+import { faEllipsis, faGear, faInfoCircle } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import axios from "axios";
import { twMerge } from "tailwind-merge";
@@ -7,7 +7,6 @@ import { twMerge } from "tailwind-merge";
import { createNotification } from "@app/components/notifications";
import { OrgPermissionCan } from "@app/components/permissions";
import {
- Button,
DeleteActionModal,
DropdownMenu,
DropdownMenuContent,
@@ -38,7 +37,6 @@ import {
WorkflowIntegrationStatus
} from "@app/hooks/api/workflowIntegrations/types";
-import { AddWorkflowIntegrationForm } from "./AddWorkflowIntegrationForm";
import { IntegrationFormDetails } from "./IntegrationFormDetails";
const renderStatus = (status: WorkflowIntegrationStatus) => {
@@ -53,9 +51,8 @@ const renderStatus = (status: WorkflowIntegrationStatus) => {
return <Badge variant="danger">Failed</Badge>;
};
-export const OrgWorkflowIntegrationSection = () => {
+export const WorkflowIntegrationsTable = () => {
const { popUp, handlePopUpOpen, handlePopUpToggle, handlePopUpClose } = usePopUp([
- "addWorkflowIntegration",
"integrationDetails",
"removeIntegration"
] as const);
@@ -128,26 +125,7 @@ export const OrgWorkflowIntegrationSection = () => {
};
return (
- <div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
- <div className="flex justify-between">
- <p className="text-xl font-medium text-mineshaft-100">Workflows</p>
- <OrgPermissionCan I={OrgPermissionActions.Create} an={OrgPermissionSubjects.Settings}>
- {(isAllowed) => (
- <Button
- onClick={() => {
- handlePopUpOpen("addWorkflowIntegration");
- }}
- isDisabled={!isAllowed}
- leftIcon={<FontAwesomeIcon icon={faPlus} />}
- >
- Add
- </Button>
- )}
- </OrgPermissionCan>
- </div>
- <p className="mb-4 text-gray-400">
- Connect Infisical to other platforms for notification and workflow integrations.
- </p>
+ <>
<TableContainer>
<Table>
<THead>
@@ -291,10 +269,6 @@ export const OrgWorkflowIntegrationSection = () => {
</TBody>
</Table>
</TableContainer>
- <AddWorkflowIntegrationForm
- isOpen={popUp.addWorkflowIntegration.isOpen}
- onToggle={(state) => handlePopUpToggle("addWorkflowIntegration", state)}
- />
<IntegrationFormDetails
isOpen={popUp.integrationDetails?.isOpen}
workflowPlatform={popUp.integrationDetails?.data?.platform}
@@ -308,6 +282,6 @@ export const OrgWorkflowIntegrationSection = () => {
deleteKey="confirm"
onDeleteApproved={handleRemoveIntegration}
/>
- </div>
+ </>
);
};
diff --git a/frontend/src/routeTree.gen.ts b/frontend/src/routeTree.gen.ts
index fead125e24..a8dfb5bd1d 100644
--- a/frontend/src/routeTree.gen.ts
+++ b/frontend/src/routeTree.gen.ts
@@ -76,8 +76,8 @@ import { Route as organizationNetworkingPageRouteImport } from './pages/organiza
import { Route as organizationAppConnectionsAppConnectionsPageRouteImport } from './pages/organization/AppConnections/AppConnectionsPage/route'
import { Route as secretManagerRedirectsRedirectApprovalPageImport } from './pages/secret-manager/redirects/redirect-approval-page'
import { Route as organizationSettingsPageOauthCallbackPageRouteImport } from './pages/organization/SettingsPage/OauthCallbackPage/route'
-import { Route as organizationNetworkingPageRelayDetailsByIDPageRouteImport } from './pages/organization/NetworkingPage/RelayDetailsByIDPage/route'
import { Route as organizationSettingsPageGitHubAppCallbackPageRouteImport } from './pages/organization/SettingsPage/GitHubAppCallbackPage/route'
+import { Route as organizationNetworkingPageRelayDetailsByIDPageRouteImport } from './pages/organization/NetworkingPage/RelayDetailsByIDPage/route'
import { Route as organizationNetworkingPageGatewayDetailsByIDPageRouteImport } from './pages/organization/NetworkingPage/GatewayDetailsByIDPage/route'
import { Route as sshLayoutImport } from './pages/ssh/layout'
import { Route as secretScanningLayoutImport } from './pages/secret-scanning/layout'
@@ -1029,14 +1029,6 @@ const organizationSettingsPageOauthCallbackPageRouteRoute =
AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdSettingsRoute,
} as any)
-const organizationNetworkingPageRelayDetailsByIDPageRouteRoute =
- organizationNetworkingPageRelayDetailsByIDPageRouteImport.update({
- id: '/relays/$relayId',
- path: '/relays/$relayId',
- getParentRoute: () =>
- AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdNetworkingRoute,
- } as any)
-
const organizationSettingsPageGitHubAppCallbackPageRouteRoute =
organizationSettingsPageGitHubAppCallbackPageRouteImport.update({
id: '/github-app/callback',
@@ -1045,6 +1037,14 @@ const organizationSettingsPageGitHubAppCallbackPageRouteRoute =
AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdSettingsRoute,
} as any)
+const organizationNetworkingPageRelayDetailsByIDPageRouteRoute =
+ organizationNetworkingPageRelayDetailsByIDPageRouteImport.update({
+ id: '/relays/$relayId',
+ path: '/relays/$relayId',
+ getParentRoute: () =>
+ AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdNetworkingRoute,
+ } as any)
+
const organizationNetworkingPageGatewayDetailsByIDPageRouteRoute =
organizationNetworkingPageGatewayDetailsByIDPageRouteImport.update({
id: '/gateways/$gatewayId',