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
remove instalation picker
Thiago Araujo da Silvaa07414a7b178
diff --git a/backend/src/keystore/keystore.ts b/backend/src/keystore/keystore.tsindex 2b42ff9d70..a26ec66c6d 100644--- a/backend/src/keystore/keystore.ts+++ b/backend/src/keystore/keystore.ts@@ -91,7 +91,6 @@ export const KeyStorePrefixes = {UsedGitHubManifestState: (jti: string) => `used-github-manifest-state:${jti}` as const,GitHubManifestNameLock: (orgId: string, projectId: string | null, name: string) =>`github-manifest-name-lock:${orgId}:${projectId ?? "org"}:${name}` as const,- UsedGitHubInstallationsToken: (jti: string) => `used-github-installations-token:${jti}` as const,AiMcpServerOAuth: (sessionId: string) => `ai-mcp-server-oauth:${sessionId}` as const,diff --git a/backend/src/server/routes/v1/github-app-router.ts b/backend/src/server/routes/v1/github-app-router.tsindex 1f82ba1097..0713d53d59 100644--- a/backend/src/server/routes/v1/github-app-router.ts+++ b/backend/src/server/routes/v1/github-app-router.ts@@ -109,57 +109,6 @@ export const registerGitHubAppRouter = async (server: FastifyZodProvider) => {}});- server.route({- method: "POST",- url: "/resolve-installations",- config: {- rateLimit: writeLimit- },- onRequest: verifyAuth([AuthMode.JWT]),- schema: {- body: z- .object({- code: z.string().trim().min(1),- gitHubAppId: z.string().uuid().optional(),- host: z.string().trim().optional(),- instanceType: z.enum(["cloud", "server"]).optional(),- gatewayId: z.string().uuid().optional(),- gatewayPoolId: z.string().uuid().optional(),- projectId: z.string().optional()- })- .refine((data) => !(data.gatewayId && data.gatewayPoolId), {- message: "Cannot specify both a gateway and a gateway pool",- path: ["gatewayPoolId"]- }),- response: {- 200: z.object({- installations: z- .object({- id: z.string(),- accountLogin: z.string(),- accountType: z.string()- })- .array(),- installationsToken: z.string()- })- }- },- handler: async (req) => {- const result = await server.services.gitHubApp.resolveUserInstallations({- orgPermission: req.permission,- code: req.body.code,- gitHubAppId: req.body.gitHubAppId,- host: req.body.host,- instanceType: req.body.instanceType,- gatewayId: req.body.gatewayId,- gatewayPoolId: req.body.gatewayPoolId,- projectId: req.body.projectId- });-- return result;- }- });-server.route({method: "DELETE",url: "/:id",diff --git a/backend/src/services/app-connection/app-connection-fns.ts b/backend/src/services/app-connection/app-connection-fns.tsindex cac874dc1f..fc9ef18929 100644--- a/backend/src/services/app-connection/app-connection-fns.ts+++ b/backend/src/services/app-connection/app-connection-fns.ts@@ -520,9 +520,7 @@ export const validateAppConnectionCredentials = async ([AppConnection.GitHub]: ((config: TAppConnectionConfig, gw, gw2) =>validateGitHubConnectionCredentials(config as TGitHubConnectionConfig, gw, gw2, {gitHubAppDAL: deps.gitHubAppDAL,- kmsService: deps.kmsService,- keyStore: deps.keyStore,- actorId: deps.actorId+ kmsService: deps.kmsService})) as TAppConnectionCredentialsValidator,[AppConnection.GitHubRadar]: validateGitHubRadarConnectionCredentials as TAppConnectionCredentialsValidator,[AppConnection.GCP]: validateGcpConnectionCredentials as TAppConnectionCredentialsValidator,diff --git a/backend/src/services/app-connection/app-connection-service.ts b/backend/src/services/app-connection/app-connection-service.tsindex 75e814b364..25136cf555 100644--- a/backend/src/services/app-connection/app-connection-service.ts+++ b/backend/src/services/app-connection/app-connection-service.ts@@ -110,11 +110,7 @@ import { ValidateFlyioConnectionCredentialsSchema } from "./flyio";import { flyioConnectionService } from "./flyio/flyio-connection-service";import { ValidateGcpConnectionCredentialsSchema } from "./gcp";import { gcpConnectionService } from "./gcp/gcp-connection-service";-import {- GitHubConnectionMethod,- releaseGitHubInstallationsTokenClaim,- ValidateGitHubConnectionCredentialsSchema-} from "./github";+import { GitHubConnectionMethod, ValidateGitHubConnectionCredentialsSchema } from "./github";import { githubConnectionService } from "./github/github-connection-service";import { ValidateGitHubRadarConnectionCredentialsSchema } from "./github-radar";import { githubRadarConnectionService } from "./github-radar/github-radar-connection-service";@@ -665,11 +661,6 @@ export const appConnectionServiceFactory = ({configuration} as TAppConnection;} catch (err) {- if (app === AppConnection.GitHub && method === GitHubConnectionMethod.App) {- const installationsToken = (credentials as { installationsToken?: string } | undefined)?.installationsToken;- if (installationsToken) await releaseGitHubInstallationsTokenClaim(installationsToken, keyStore);- }-if (err instanceof DatabaseError && (err.error as { code: string })?.code === DatabaseErrorCode.UniqueViolation) {throw new BadRequestError({ message: `An App Connection with the name "${params.name}" already exists` });}@@ -1014,11 +1005,6 @@ export const appConnectionServiceFactory = ({return await decryptAppConnection(updatedConnection, kmsService);} catch (err) {- if (app === AppConnection.GitHub && method === GitHubConnectionMethod.App) {- const installationsToken = (credentials as { installationsToken?: string } | undefined)?.installationsToken;- if (installationsToken) await releaseGitHubInstallationsTokenClaim(installationsToken, keyStore);- }-if (err instanceof DatabaseError && (err.error as { code: string })?.code === DatabaseErrorCode.UniqueViolation) {throw new BadRequestError({ message: `An App Connection with the name "${params.name}" already exists` });}diff --git a/backend/src/services/app-connection/github/github-connection-fns.ts b/backend/src/services/app-connection/github/github-connection-fns.tsindex 5e5b53f6d3..b69097b784 100644--- a/backend/src/services/app-connection/github/github-connection-fns.ts+++ b/backend/src/services/app-connection/github/github-connection-fns.ts@@ -6,7 +6,6 @@ import { verifyHostInputValidity } from "@app/ee/services/dynamic-secret/dynamicimport { TGatewayServiceFactory } from "@app/ee/services/gateway/gateway-service";import { TGatewayPoolServiceFactory } from "@app/ee/services/gateway-pool/gateway-pool-service";import { TGatewayV2ServiceFactory } from "@app/ee/services/gateway-v2/gateway-v2-service";-import { KeyStorePrefixes, TKeyStoreFactory } from "@app/keystore/keystore";import { getConfig } from "@app/lib/config/env";import { request as httpRequest } from "@app/lib/config/request";import { crypto } from "@app/lib/crypto";@@ -125,38 +124,6 @@ export const resolveGitHubAppCredentials = async (};};-export type TGitHubAppInstallationsTokenPayload = {- jti: string;- orgId: string;- actorId: string;- gitHubAppId: string | null;- host: string;- instanceType: "cloud" | "server";- installationIds: string[];-};--export const GITHUB_APP_INSTALLATIONS_TOKEN_TTL = "10m";--export const signGitHubAppInstallationsToken = (payload: TGitHubAppInstallationsTokenPayload) => {- const { AUTH_SECRET } = getConfig();- return crypto.jwt().sign(payload, AUTH_SECRET, { expiresIn: GITHUB_APP_INSTALLATIONS_TOKEN_TTL });-};--export const releaseGitHubInstallationsTokenClaim = async (- installationsToken: string,- keyStore: Pick<TKeyStoreFactory, "deleteItem">-) => {- try {- const { AUTH_SECRET } = getConfig();- const payload = crypto.jwt().verify(installationsToken, AUTH_SECRET) as TGitHubAppInstallationsTokenPayload;- if (payload.jti) {- await keyStore.deleteItem(KeyStorePrefixes.UsedGitHubInstallationsToken(payload.jti));- }- } catch {- // ignore — the claim will expire on its TTL if it can't be released here- }-};-export const getGitHubConnectionListItem = () => {const { INF_APP_CONNECTION_GITHUB_OAUTH_CLIENT_ID, INF_APP_CONNECTION_GITHUB_APP_SLUG } = getConfig();@@ -796,10 +763,7 @@ export const validateGitHubConnectionCredentials = async (config: TGitHubConnectionConfig,gatewayService: Pick<TGatewayServiceFactory, "fnGetGatewayClientTlsByGatewayId">,gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">,- deps: TGitHubAppCredentialResolverDeps & {- keyStore: Pick<TKeyStoreFactory, "setItemWithExpiryNX">;- actorId?: string;- }+ deps: TGitHubAppCredentialResolverDeps) => {const { credentials, method } = config;@@ -823,73 +787,6 @@ export const validateGitHubConnectionCredentials = async (}}- if (method === GitHubConnectionMethod.App && credentials.installationsToken) {- const { AUTH_SECRET } = getConfig();-- let tokenPayload: TGitHubAppInstallationsTokenPayload & { exp: number };- try {- tokenPayload = crypto- .jwt()- .verify(credentials.installationsToken, AUTH_SECRET) as TGitHubAppInstallationsTokenPayload & { exp: number };- } catch {- throw new BadRequestError({- message: "Invalid or expired GitHub installation token. Please reconnect and try again."- });- }-- if (!tokenPayload.jti || !Array.isArray(tokenPayload.installationIds)) {- throw new BadRequestError({- message: "Invalid or expired GitHub installation token. Please reconnect and try again."- });- }-- if (tokenPayload.orgId !== config.orgId || (deps.actorId && tokenPayload.actorId !== deps.actorId)) {- throw new ForbiddenRequestError({- message: "GitHub installation token does not belong to this actor or organization."- });- }-- if ((tokenPayload.gitHubAppId ?? null) !== (credentials.gitHubAppId ?? null)) {- throw new BadRequestError({- message: "GitHub installation token was issued for a different GitHub App."- });- }-- if (!tokenPayload.installationIds.includes(credentials.installationId)) {- throw new ForbiddenRequestError({- message: "User does not have access to the provided installation"- });- }-- const boundHost = credentials.gitHubAppId- ? (resolvedAppCredentials!.host ?? undefined)- : tokenPayload.host || undefined;- const boundInstanceType = credentials.gitHubAppId- ? (resolvedAppCredentials!.instanceType ?? "cloud")- : tokenPayload.instanceType;-- assertPlatformGitHubHostAllowed(boundHost);-- const ttlSeconds = Math.max(1, tokenPayload.exp - Math.floor(Date.now() / 1000));- const claimed = await deps.keyStore.setItemWithExpiryNX(- KeyStorePrefixes.UsedGitHubInstallationsToken(tokenPayload.jti),- ttlSeconds,- "1"- );- if (!claimed) {- throw new BadRequestError({- message: "This GitHub installation token has already been used. Please reconnect and try again."- });- }-- return {- installationId: credentials.installationId,- gitHubAppId: credentials.gitHubAppId ?? null,- instanceType: boundInstanceType,- host: boundHost- };- }-if (method === GitHubConnectionMethod.App && !credentials.code) {throw new BadRequestError({ message: "GitHub App code required" });}diff --git a/backend/src/services/app-connection/github/github-connection-schemas.ts b/backend/src/services/app-connection/github/github-connection-schemas.tsindex e5b356e498..de1150a72b 100644--- a/backend/src/services/app-connection/github/github-connection-schemas.ts+++ b/backend/src/services/app-connection/github/github-connection-schemas.ts@@ -24,33 +24,22 @@ export const GitHubConnectionOAuthInputCredentialsSchema = z.union([})]);-export const GitHubConnectionAppInputCredentialsSchema = z- .union([- z.object({- code: z.string().trim().min(1, "GitHub App code required").optional(),- installationsToken: z.string().trim().min(1).optional(),- 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").optional(),- installationsToken: z.string().trim().min(1).optional(),- 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()- })- ])- .superRefine((credentials, ctx) => {- if (Boolean(credentials.code) === Boolean(credentials.installationsToken)) {- ctx.addIssue({- code: z.ZodIssueCode.custom,- message: "Exactly one of code or installationsToken must be provided"- });- }- });+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()+ })+]);export const GitHubConnectionPatInputCredentialsSchema = z.union([z.object({diff --git a/backend/src/services/github-app/github-app-service.ts b/backend/src/services/github-app/github-app-service.tsindex d1955bd316..053c318133 100644--- a/backend/src/services/github-app/github-app-service.ts+++ b/backend/src/services/github-app/github-app-service.ts@@ -1,5 +1,5 @@import { ForbiddenError } from "@casl/ability";-import { AxiosError, AxiosRequestConfig, AxiosResponse } from "axios";+import { AxiosError, AxiosRequestConfig } from "axios";import { ActionProjectType, OrganizationActionScope } from "@app/db/schemas";import { EventType, TAuditLogServiceFactory } from "@app/ee/services/audit-log/audit-log-types";@@ -30,18 +30,12 @@ import { safeRequest } from "@app/lib/validator/safe-request";import {assertPlatformGitHubHostAllowed,buildGitHubAppJwtHeaders,- exchangeGitHubOAuthCode,getGitHubGatewayConnectionDetails,getGitHubInstanceApiUrl,- GithubTokenRespData,- isGithubErrorResponse,- listGitHubUserInstallations,requestWithGitHubGateway,resolveGitHubAppCredentials,sanitizeGitHubAxiosError,- signGitHubAppInstallationsToken,- signGitHubAppJwt,- TGitHubUserInstallation+ signGitHubAppJwt} from "@app/services/app-connection/github/github-connection-fns";import { ActorAuthMethod, ActorType } from "@app/services/auth/auth-type";import { TKmsServiceFactory } from "@app/services/kms/kms-service";@@ -51,13 +45,11 @@ import { TUserDALFactory } from "@app/services/user/user-dal";import { TGitHubAppDALFactory } from "./github-app-dal";import {TDeleteGitHubAppDTO,- TGitHubAppInstallation,TGitHubAppManifestResponse,TGitHubManifestStatePayload,THandleManifestCallbackDTO,TInitiateGitHubManifestDTO,TListGitHubAppsDTO,- TResolveGitHubAppInstallationsDTO,TSanitizedGitHubApp} from "./github-app-types";@@ -134,9 +126,8 @@ export const gitHubAppServiceFactory = ({};// Validates that the actor may attach the given gateway and that it exists for the org.- // Mirrors the gateway checks in resolveUserInstallations so the manifest exchange can route- // through a gateway when the GitHub host (e.g. a private GitHub Enterprise Server) isn't- // directly reachable from the Infisical backend.+ // Lets the manifest exchange route through a gateway when the GitHub host (e.g. a private+ // GitHub Enterprise Server) isn't directly reachable from the Infisical backend.const assertGatewayUsable = async (gatewayId: string, orgPermission: OrgServiceActor) => {const plan = await licenseService.getPlan(orgPermission.orgId);if (!plan.gateway) {@@ -725,178 +716,10 @@ export const gitHubAppServiceFactory = ({return { redirectUrl: callbackUrl.toString() };};- const resolveUserInstallations = async ({- code,- gitHubAppId,- instanceType,- gatewayId,- gatewayPoolId,- projectId,- orgPermission- }: TResolveGitHubAppInstallationsDTO): Promise<{- installations: TGitHubAppInstallation[];- installationsToken: string;- }> => {- const { permission: orgScopedPermission } = await permissionService.getOrgPermission({- actor: orgPermission.type,- actorId: orgPermission.id,- orgId: orgPermission.orgId,- actorAuthMethod: orgPermission.authMethod,- actorOrgId: orgPermission.orgId,- scope: OrganizationActionScope.Any- });-- if (projectId) {- const { permission } = await permissionService.getProjectPermission({- actor: orgPermission.type,- actorId: orgPermission.id,- projectId,- actorAuthMethod: orgPermission.authMethod,- actorOrgId: orgPermission.orgId,- actionProjectType: ActionProjectType.Any- });-- ForbiddenError.from(permission).throwUnlessCan(- ProjectPermissionAppConnectionActions.Create,- ProjectPermissionSub.AppConnections- );-- if (gitHubAppId) {- const app = await gitHubAppDAL.findOne({ id: gitHubAppId, orgId: orgPermission.orgId });- if (app && !app.projectId) {- ForbiddenError.from(orgScopedPermission).throwUnlessCan(- OrgPermissionAppConnectionActions.Connect,- OrgPermissionSubjects.AppConnections- );- }- }- } else {- ForbiddenError.from(orgScopedPermission).throwUnlessCan(- OrgPermissionAppConnectionActions.Create,- OrgPermissionSubjects.AppConnections- );- }-- await assertGatewayConfigUsable({ gatewayId, gatewayPoolId }, orgPermission);-- const effectiveGatewayId = await gatewayPoolService.resolveEffectiveGatewayId({ gatewayId, gatewayPoolId });-- const { SITE_URL } = getConfig();- if (!SITE_URL) {- throw new BadRequestError({ message: "SITE_URL is not configured." });- }-- const {- appId,- clientId,- clientSecret,- host: appHost,- instanceType: appInstanceType- } = await resolveGitHubAppCredentials(- { gitHubAppId: gitHubAppId ?? null, orgId: orgPermission.orgId, projectId: projectId ?? null },- {- gitHubAppDAL,- kmsService- }- );-- // For the shared/instance-default app, appHost is always derived from the- // server-side INF_APP_CONNECTION_GITHUB_APP_HOST env var (null = github.com).- // Never trust the caller-supplied host for the shared app — the client secret- // would otherwise be sent to an attacker-controlled server.- const effectiveHost = appHost ?? undefined;- const effectiveInstanceType: "cloud" | "server" = gitHubAppId- ? (appInstanceType ?? "cloud")- : (instanceType ?? "cloud");-- assertPlatformGitHubHostAllowed(effectiveHost);-- const oauthHost = effectiveHost ?? "github.com";-- const sendGitHubRequest = async <T>(- requestConfig: AxiosRequestConfig & { url: string },- gatewayConnectionDetails?: Awaited<ReturnType<typeof getGitHubGatewayConnectionDetails>>- ): Promise<AxiosResponse<T>> =>- effectiveGatewayId- ? requestWithGitHubGateway<T>(- { gatewayId: effectiveGatewayId },- gatewayService,- gatewayV2Service,- requestConfig,- gatewayConnectionDetails- )- : safeRequest.request<T>(requestConfig);-- const oauthGatewayConnectionDetails = effectiveGatewayId- ? await getGitHubGatewayConnectionDetails(effectiveGatewayId, oauthHost, gatewayV2Service)- : undefined;-- let tokenData: GithubTokenRespData;- try {- const { data } = await exchangeGitHubOAuthCode({- host: oauthHost,- clientId,- clientSecret,- code,- requestFn: (requestConfig) =>- sendGitHubRequest<GithubTokenRespData>(requestConfig, oauthGatewayConnectionDetails)- });- tokenData = data;- } catch (err) {- logger.error(- sanitizeGitHubAxiosError(err),- `Failed to exchange GitHub OAuth code [gitHubAppId=${gitHubAppId ?? "shared"}]`- );- throw new BadRequestError({- message: "Unable to authorize with GitHub. The code may be expired or invalid. Please try again."- });- }-- if (isGithubErrorResponse(tokenData) || !tokenData.access_token) {- throw new BadRequestError({- message: "Unable to authorize with GitHub. The code may be expired or invalid. Please try again."- });- }-- const apiBaseUrl = await getGitHubInstanceApiUrl({- credentials: { host: effectiveHost, instanceType: effectiveInstanceType }- });-- const apiGatewayConnectionDetails = effectiveGatewayId- ? await getGitHubGatewayConnectionDetails(effectiveGatewayId, apiBaseUrl, gatewayV2Service)- : undefined;-- const installations = await listGitHubUserInstallations(apiBaseUrl, tokenData.access_token, (requestConfig) =>- sendGitHubRequest<{ installations: TGitHubUserInstallation[] }>(requestConfig, apiGatewayConnectionDetails)- );-- const appInstallations = installations.filter((installation) => String(installation.app_id) === appId);-- const installationsToken = signGitHubAppInstallationsToken({- jti: crypto.nativeCrypto.randomUUID(),- orgId: orgPermission.orgId,- actorId: orgPermission.id,- gitHubAppId: gitHubAppId ?? null,- host: effectiveHost ?? "",- instanceType: effectiveInstanceType,- installationIds: appInstallations.map((installation) => String(installation.id))- });-- return {- installations: appInstallations.map((installation) => ({- id: String(installation.id),- accountLogin: installation.account.login,- accountType: installation.account.type- })),- installationsToken- };- };-return {initiateManifestCreation,handleManifestCallback,listGitHubApps,- deleteGitHubApp,- resolveUserInstallations+ deleteGitHubApp};};diff --git a/backend/src/services/github-app/github-app-types.ts b/backend/src/services/github-app/github-app-types.tsindex de53b06b73..4e019f0dbc 100644--- a/backend/src/services/github-app/github-app-types.ts+++ b/backend/src/services/github-app/github-app-types.ts@@ -47,23 +47,6 @@ export type TDeleteGitHubAppDTO = {orgPermission: OrgServiceActor;};-export type TResolveGitHubAppInstallationsDTO = {- code: string;- gitHubAppId?: string;- host?: string;- instanceType?: "cloud" | "server";- gatewayId?: string | null;- gatewayPoolId?: string | null;- projectId?: string;- orgPermission: OrgServiceActor;-};--export type TGitHubAppInstallation = {- id: string;- accountLogin: string;- accountType: string;-};-export type TGitHubAppManifestResponse = {id: number;slug: string;diff --git a/frontend/src/hooks/api/appConnections/types/github-connection.ts b/frontend/src/hooks/api/appConnections/types/github-connection.tsindex a435eba556..d6c3a29261 100644--- a/frontend/src/hooks/api/appConnections/types/github-connection.ts+++ b/frontend/src/hooks/api/appConnections/types/github-connection.ts@@ -19,8 +19,7 @@ export type TGitHubConnection = TRootAppConnection & { app: AppConnection.GitHub| {method: GitHubConnectionMethod.App;credentials: {- code?: string;- installationsToken?: string;+ code: string;installationId: string;gitHubAppId?: string | null;instanceType?: "cloud" | "server";diff --git a/frontend/src/hooks/api/gitHubApps/index.ts b/frontend/src/hooks/api/gitHubApps/index.tsindex afd5240cb2..043f44f5fc 100644--- a/frontend/src/hooks/api/gitHubApps/index.ts+++ b/frontend/src/hooks/api/gitHubApps/index.ts@@ -1,3 +1,3 @@export { useDeleteGitHubApp } from "./mutations";-export { gitHubAppKeys, resolveGitHubAppInstallations, useListGitHubApps } from "./queries";-export type { TGitHubApp, TGitHubAppInstallation } from "./types";+export { gitHubAppKeys, useListGitHubApps } from "./queries";+export type { TGitHubApp } from "./types";diff --git a/frontend/src/hooks/api/gitHubApps/queries.tsx b/frontend/src/hooks/api/gitHubApps/queries.tsxindex b436a120dd..99b82e529a 100644--- a/frontend/src/hooks/api/gitHubApps/queries.tsx+++ b/frontend/src/hooks/api/gitHubApps/queries.tsx@@ -2,7 +2,7 @@ import { useQuery } from "@tanstack/react-query";import { apiRequest } from "@app/config/request";-import { TGitHubApp, TGitHubAppInstallation } from "./types";+import { TGitHubApp } from "./types";export const gitHubAppKeys = {all: ["github-apps"] as const,@@ -17,22 +17,6 @@ const fetchGitHubApps = async (projectId?: string) => {return data.gitHubApps;};-export const resolveGitHubAppInstallations = async (params: {- code: string;- gitHubAppId?: string;- host?: string;- instanceType?: "cloud" | "server";- gatewayId?: string;- gatewayPoolId?: string;- projectId?: string;-}) => {- const { data } = await apiRequest.post<{- installations: TGitHubAppInstallation[];- installationsToken: string;- }>("/api/v1/github-apps/resolve-installations", params);- return data;-};-export const useListGitHubApps = (orgId?: string, projectId?: string | null) =>useQuery({queryKey: gitHubAppKeys.list(orgId, projectId),diff --git a/frontend/src/hooks/api/gitHubApps/types.ts b/frontend/src/hooks/api/gitHubApps/types.tsindex 8bf5e734c0..a3bfba55d8 100644--- a/frontend/src/hooks/api/gitHubApps/types.ts+++ b/frontend/src/hooks/api/gitHubApps/types.ts@@ -13,9 +13,3 @@ export type TGitHubApp = {createdAt: string | null;updatedAt: string | null;};--export type TGitHubAppInstallation = {- id: string;- accountLogin: string;- accountType: string;-};diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/GitHubConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/GitHubConnectionForm.tsxindex 9b06072d5b..84d8e70137 100644--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/GitHubConnectionForm.tsx+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/GitHubConnectionForm.tsx@@ -352,13 +352,7 @@ export const GitHubConnectionForm = ({ appConnection, projectId, onSubmit }: ProstoreConnectionFormData(formData, installState, targetApp?.id ?? undefined, slug);- if (targetApp?.clientId) {- window.location.assign(- `${githubHost}/login/oauth/authorize?client_id=${targetApp.clientId}&state=${installState}&redirect_uri=${window.location.origin}/organization/app-connections/github/oauth/callback`- );- break;- }-+ // Always use GitHub's install flow: the user selects the account + repos on GitHub's own UI,window.location.assign(buildGitHubAppInstallUrl(slug ?? "",diff --git a/frontend/src/pages/organization/AppConnections/OauthCallbackPage/OauthCallbackPage.tsx b/frontend/src/pages/organization/AppConnections/OauthCallbackPage/OauthCallbackPage.tsxindex 8d719aaf0a..76a2614fc4 100644--- a/frontend/src/pages/organization/AppConnections/OauthCallbackPage/OauthCallbackPage.tsx+++ b/frontend/src/pages/organization/AppConnections/OauthCallbackPage/OauthCallbackPage.tsx@@ -2,23 +2,11 @@ import { useCallback, useEffect, useState } from "react";import { useNavigate, useParams, useSearch } from "@tanstack/react-router";import { createNotification } from "@app/components/notifications";-import { Button } from "@app/components/v3/generic/Button";-import {- Card,- CardContent,- CardDescription,- CardFooter,- CardHeader,- CardTitle-} from "@app/components/v3/generic/Card";import { PageLoader } from "@app/components/v3/platform/PageLoader";import { ROUTE_PATHS } from "@app/const/routes";import {APP_CONNECTION_MAP,- buildGitHubAppInstallUrl,consumeCsrfToken,- CSRF_TOKEN_STORAGE_KEY,- generateCsrfToken,getConnectionFlowReturnNavigateOptions,getIntegrationsListTab,GITHUB_CONNECTION_FORM_STORAGE_KEY,@@ -37,7 +25,6 @@ import {useUpdateAppConnection} from "@app/hooks/api/appConnections";import { AppConnection } from "@app/hooks/api/appConnections/enums";-import { resolveGitHubAppInstallations, TGitHubAppInstallation } from "@app/hooks/api/gitHubApps";import { FormDataMap } from "./OauthCallbackPage.types";@@ -52,19 +39,10 @@ const formDataStorageFieldMap: Partial<Record<AppConnection, string>> = {[AppConnection.Heroku]: "herokuConnectionFormData"};-type TGitHubInstallationPicker = {- installations: TGitHubAppInstallation[];- installationsToken: string;- formData: FormDataMap[AppConnection.GitHub];-};-export const OAuthCallbackPage = () => {const navigate = useNavigate();const [isReady, setIsReady] = useState(false);- const [gitHubPicker, setGitHubPicker] = useState<TGitHubInstallationPicker | null>(null);- const [pickedInstallationId, setPickedInstallationId] = useState<string | null>(null);-const search = useSearch({from: ROUTE_PATHS.Organization.AppConnections.OauthCallbackPage.id});@@ -443,27 +421,17 @@ export const OAuthCallbackPage = () => {const storedGitHubAppId = (credentials as { gitHubAppId?: string | null } | undefined)?.gitHubAppId;- if (!installationId && formData.method === GitHubConnectionMethod.App) {- try {- const result = await resolveGitHubAppInstallations({- code: code as string,- gitHubAppId: storedGitHubAppId ?? undefined,- ...(credentials?.instanceType && { instanceType: credentials.instanceType }),- ...(credentials?.host && { host: credentials.host }),- ...(gatewayId && { gatewayId }),- ...(gatewayPoolId && { gatewayPoolId }),- ...(projectId && { projectId })- });- setGitHubPicker({ ...result, formData });- } catch (err) {- createNotification({- type: "error",- text:- (err as { response?: { data?: { message?: string } } })?.response?.data?.message ??- "Failed to resolve GitHub App installations"- });- navigate(getConnectionFlowReturnNavigateOptions({ returnUrl, projectId }));- }+ const isAppMethod = formData.method === GitHubConnectionMethod.App;++ // App connections go through GitHub's install flow, which redirects back with the chosen+ // installation_id. If it's missing, the app wasn't installed — e.g. a non-admin org member+ // triggered a pending install request that an owner must approve — so there's nothing to connect.+ if (isAppMethod && !installationId) {+ createNotification({+ type: "error",+ text: "The GitHub App was not installed. If you requested it on an organization, an owner may need to approve the installation first. Please complete the installation and try again."+ });+ navigate(getConnectionFlowReturnNavigateOptions({ returnUrl, projectId }));return null;}@@ -471,11 +439,10 @@ export const OAuthCallbackPage = () => {try {const gitHubAppId = storedGitHubAppId;- const isAppMethod = Boolean(installationId);const appCredentials = {code: code as string,- ...(installationId && { installationId: installationId as string }),+ installationId: installationId as string,...(gitHubAppId !== undefined && { gitHubAppId }),...(credentials?.instanceType && { instanceType: credentials.instanceType }),...(credentials?.host && { host: credentials.host })@@ -536,107 +503,6 @@ export const OAuthCallbackPage = () => {};}, []);- const completeGitHubAppConnection = async (selectedInstallationId: string) => {- if (!gitHubPicker) return;-- const { installationsToken, formData } = gitHubPicker;- const {- connectionId,- name,- description,- returnUrl,- gatewayId,- gatewayPoolId,- credentials,- projectId- } = formData;- const gitHubAppId = (credentials as { gitHubAppId?: string | null } | undefined)?.gitHubAppId;-- setPickedInstallationId(selectedInstallationId);-- try {- const appCredentials = {- installationsToken,- installationId: selectedInstallationId,- ...(gitHubAppId !== undefined && { gitHubAppId }),- ...(credentials?.instanceType && { instanceType: credentials.instanceType }),- ...(credentials?.host && { host: credentials.host })- };-- let connection: TAppConnection;-- if (connectionId) {- connection = await updateAppConnection.mutateAsync({- app: AppConnection.GitHub,- connectionId,- credentials: appCredentials,- gatewayId,- gatewayPoolId- });- } else {- connection = await createAppConnection.mutateAsync({- app: AppConnection.GitHub,- name,- description,- projectId,- method: GitHubConnectionMethod.App,- credentials: appCredentials,- gatewayId,- gatewayPoolId- });- }-- await finalizeConnection({- connectionId,- returnUrl,- appConnectionName: formData.app,- projectId,- connection- });- } catch (err) {- createNotification({- type: "error",- text:- (err as { response?: { data?: { message?: string } } })?.response?.data?.message ??- `Failed to ${connectionId ? "update" : "create"} GitHub Connection`- });- navigate(getConnectionFlowReturnNavigateOptions({ returnUrl, projectId }));- }- };-- const redirectToGitHubInstall = () => {- if (!gitHubPicker) return;-- const { formData } = gitHubPicker;-- if (!formData.appSlug) {- createNotification({- type: "error",- text: "Unable to determine the GitHub App to install. Please restart the connection flow."- });- navigate(- getConnectionFlowReturnNavigateOptions({- returnUrl: formData.returnUrl,- projectId: formData.projectId- })- );- return;- }-- const newState = generateCsrfToken();- localStorage.setItem(CSRF_TOKEN_STORAGE_KEY, newState);- localStorage.setItem(GITHUB_CONNECTION_FORM_STORAGE_KEY, JSON.stringify(formData));-- window.location.assign(- buildGitHubAppInstallUrl(- formData.appSlug,- newState,- formData.credentials?.host,- formData.credentials?.instanceType- )- );- };-const handleGitHubRadar = useCallback(async () => {const formData = getFormData(AppConnection.GitHubRadar);if (formData === null) return null;@@ -791,54 +657,5 @@ export const OAuthCallbackPage = () => {})();}, [isReady]);- if (gitHubPicker) {- const hasInstallations = gitHubPicker.installations.length > 0;-- return (- <div className="flex h-full w-full items-center justify-center">- <Card className="w-full max-w-md gap-4">- <CardHeader>- <CardTitle>- {hasInstallations ? "Select a GitHub account" : "Install the GitHub App"}- </CardTitle>- <CardDescription>- {hasInstallations- ? "The GitHub App is already installed on the following accounts. Select the installation to connect, or install the app on another account."- : "The GitHub App is not installed on any account you have access to. Install it to continue."}- </CardDescription>- </CardHeader>- {hasInstallations && (- <CardContent className="flex flex-col gap-2">- {gitHubPicker.installations.map((installation) => (- <Button- key={installation.id}- isFullWidth- isDisabled={Boolean(pickedInstallationId)}- isPending={pickedInstallationId === installation.id}- onClick={() => completeGitHubAppConnection(installation.id)}- >- <div className="flex w-full items-center justify-between">- <span>{installation.accountLogin}</span>- <span className="text-xs text-accent">{installation.accountType}</span>- </div>- </Button>- ))}- </CardContent>- )}- <CardFooter>- <Button- variant={hasInstallations ? "ghost" : "outline"}- isFullWidth- isDisabled={Boolean(pickedInstallationId)}- onClick={redirectToGitHubInstall}- >- {hasInstallations ? "Install on another account" : "Install GitHub App"}- </Button>- </CardFooter>- </Card>- </div>- );- }-return <PageLoader />;};diff --git a/frontend/src/pages/organization/AppConnections/OauthCallbackPage/route.tsx b/frontend/src/pages/organization/AppConnections/OauthCallbackPage/route.tsxindex 558a92091d..3df799b20f 100644--- a/frontend/src/pages/organization/AppConnections/OauthCallbackPage/route.tsx+++ b/frontend/src/pages/organization/AppConnections/OauthCallbackPage/route.tsx@@ -7,7 +7,8 @@ import { OAuthCallbackPage } from "./OauthCallbackPage";const GitHubOAuthCallbackPageQueryParamsSchema = z.object({code: z.coerce.string().catch(""),state: z.string().catch(""),- installation_id: z.coerce.string().optional().catch("")+ installation_id: z.coerce.string().optional().catch(""),+ setup_action: z.string().optional().catch("")});export const Route = createFileRoute(@@ -16,6 +17,6 @@ export const Route = createFileRoute(component: OAuthCallbackPage,validateSearch: zodValidator(GitHubOAuthCallbackPageQueryParamsSchema),search: {- middlewares: [stripSearchParams({ state: "", installation_id: "" })]+ middlewares: [stripSearchParams({ state: "", installation_id: "", setup_action: "" })]}});