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 old gatewayV1
Carlos Monastyrski234f4d753bbf
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.tsindex 4ae15fd22a..053908a5c1 100644--- a/backend/src/server/routes/index.ts+++ b/backend/src/server/routes/index.ts@@ -2486,7 +2486,6 @@ export const registerRoutes = async (pkiSyncQueue,certificateRequestDAL,resourceMetadataDAL,- gatewayService,gatewayV2Service});@@ -2571,7 +2570,6 @@ export const registerRoutes = async (certificateRequestDAL,resourceMetadataDAL,pkiAlertV2Queue,- gatewayService,gatewayV2Service});diff --git a/backend/src/services/app-connection/app-connection-fns.ts b/backend/src/services/app-connection/app-connection-fns.tsindex fed3a26ba6..359f8d4608 100644--- a/backend/src/services/app-connection/app-connection-fns.ts+++ b/backend/src/services/app-connection/app-connection-fns.ts@@ -218,6 +218,7 @@ import {validateVenafiTppConnectionCredentials,VenafiTppConnectionMethod} from "./venafi-tpp";+import { TVenafiTppConnectionConfig } from "./venafi-tpp/venafi-tpp-connection-types";import { VercelConnectionMethod } from "./vercel";import { getVercelConnectionListItem, validateVercelConnectionCredentials } from "./vercel/vercel-connection-fns";import {@@ -462,7 +463,11 @@ export const validateAppConnectionCredentials = async ([AppConnection.CircleCI]: validateCircleCIConnectionCredentials as TAppConnectionCredentialsValidator,[AppConnection.AzureEntraId]: validateAzureEntraIdConnectionCredentials as TAppConnectionCredentialsValidator,[AppConnection.Venafi]: validateVenafiConnectionCredentials as TAppConnectionCredentialsValidator,- [AppConnection.VenafiTpp]: validateVenafiTppConnectionCredentials as TAppConnectionCredentialsValidator,+ [AppConnection.VenafiTpp]: ((config: TAppConnectionConfig) =>+ validateVenafiTppConnectionCredentials(+ config as TVenafiTppConnectionConfig,+ gatewayV2Service+ )) as TAppConnectionCredentialsValidator,[AppConnection.NetScaler]: validateNetScalerConnectionCredentials as TAppConnectionCredentialsValidator,[AppConnection.Ona]: validateOnaConnectionCredentials as TAppConnectionCredentialsValidator,[AppConnection.TravisCI]: validateTravisCIConnectionCredentials as TAppConnectionCredentialsValidator,diff --git a/backend/src/services/app-connection/venafi-tpp/venafi-tpp-connection-fns.ts b/backend/src/services/app-connection/venafi-tpp/venafi-tpp-connection-fns.tsindex bdb4d9946a..2ffdfef1b7 100644--- a/backend/src/services/app-connection/venafi-tpp/venafi-tpp-connection-fns.ts+++ b/backend/src/services/app-connection/venafi-tpp/venafi-tpp-connection-fns.ts@@ -3,11 +3,10 @@ import https from "https";import RE2 from "re2";import { verifyHostInputValidity } from "@app/ee/services/dynamic-secret/dynamic-secret-fns";-import { TGatewayServiceFactory } from "@app/ee/services/gateway/gateway-service";import { TGatewayV2ServiceFactory } from "@app/ee/services/gateway-v2/gateway-v2-service";import { request } from "@app/lib/config/request";import { BadRequestError } from "@app/lib/errors";-import { GatewayProxyProtocol, withGatewayProxy } from "@app/lib/gateway";+import { GatewayProxyProtocol } from "@app/lib/gateway";import { withGatewayV2Proxy } from "@app/lib/gateway-v2/gateway-v2";import { logger } from "@app/lib/logger";import { blockLocalAndPrivateIpAddresses } from "@app/lib/validator/validate-url";@@ -46,7 +45,6 @@ const normalizeTppUrl = (tppUrl: string): string => {*/export const requestWithVenafiTppGateway = async <T>(appConnection: { gatewayId?: string | null },- gatewayService: Pick<TGatewayServiceFactory, "fnGetGatewayClientTlsByGatewayId">,gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">,requestConfig: AxiosRequestConfig): Promise<AxiosResponse<T>> => {@@ -63,72 +61,35 @@ export const requestWithVenafiTppGateway = async <T>(// eslint-disable-next-line no-nested-ternaryconst targetPort = url.port ? Number(url.port) : url.protocol === "https:" ? 443 : 80;- const gatewayConnectionDetailsV2 = await gatewayV2Service.getPlatformConnectionDetailsByGatewayId({+ const gatewayConnectionDetails = await gatewayV2Service.getPlatformConnectionDetailsByGatewayId({gatewayId,targetHost,targetPort});- if (gatewayConnectionDetailsV2) {- return withGatewayV2Proxy(- async (proxyPort) => {- const isHttps = url.protocol === "https:";- url.host = `localhost:${proxyPort}`;-- const finalRequestConfig: AxiosRequestConfig = {- ...requestConfig,- url: url.toString(),- headers: {- ...requestConfig.headers,- Host: targetHost- },- ...(isHttps && {- httpsAgent: new https.Agent({- servername: targetHost- })- })- };-- try {- return await request.request(finalRequestConfig);- } catch (error) {- if (error instanceof AxiosError) {- logger.error(- { message: error.message, data: (error.response as undefined | { data: unknown })?.data },- "Error during Venafi TPP gateway request:"- );- }- throw error;- }- },- {- protocol: GatewayProxyProtocol.Tcp,- relayHost: gatewayConnectionDetailsV2.relayHost,- gateway: gatewayConnectionDetailsV2.gateway,- relay: gatewayConnectionDetailsV2.relay- }- );+ if (!gatewayConnectionDetails) {+ throw new BadRequestError({+ message: "Venafi TPP connections only support v2 gateways. Please attach a v2 gateway to this connection."+ });}- const gatewayConnectionDetailsV1 = await gatewayService.fnGetGatewayClientTlsByGatewayId(gatewayId);-- return withGatewayProxy(+ return withGatewayV2Proxy(async (proxyPort) => {- const httpsAgent = new https.Agent({- servername: targetHost- });-- url.protocol = "https:";+ const isHttps = url.protocol === "https:";url.host = `localhost:${proxyPort}`;const finalRequestConfig: AxiosRequestConfig = {...requestConfig,url: url.toString(),- httpsAgent,headers: {...requestConfig.headers,Host: targetHost- }+ },+ ...(isHttps && {+ httpsAgent: new https.Agent({+ servername: targetHost+ })+ })};try {@@ -144,10 +105,10 @@ export const requestWithVenafiTppGateway = async <T>(}},{- relayDetails: gatewayConnectionDetailsV1,protocol: GatewayProxyProtocol.Tcp,- targetHost,- targetPort+ relayHost: gatewayConnectionDetails.relayHost,+ gateway: gatewayConnectionDetails.gateway,+ relay: gatewayConnectionDetails.relay});};@@ -157,7 +118,6 @@ export const requestWithVenafiTppGateway = async <T>(*/export const authenticateVenafiTpp = async ({ credentials, ...appConnection }: { gatewayId?: string | null; credentials: TVenafiTppCredentials },- gatewayService: Pick<TGatewayServiceFactory, "fnGetGatewayClientTlsByGatewayId">,gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">): Promise<TVenafiTppOAuthResponse> => {const { tppUrl, clientId, username, password } = credentials;@@ -165,21 +125,16 @@ export const authenticateVenafiTpp = async (logger.info("Venafi TPP: Authenticating via OAuth token endpoint");- const { data } = await requestWithVenafiTppGateway<TVenafiTppOAuthResponse>(- appConnection,- gatewayService,- gatewayV2Service,- {- method: "POST",- url: `${baseUrl}/vedauth/authorize/oauth`,- data: {- client_id: clientId,- username,- password,- scope: "certificate:manage,discover,revoke;configuration"- }+ const { data } = await requestWithVenafiTppGateway<TVenafiTppOAuthResponse>(appConnection, gatewayV2Service, {+ method: "POST",+ url: `${baseUrl}/vedauth/authorize/oauth`,+ data: {+ client_id: clientId,+ username,+ password,+ scope: "certificate:manage,discover,revoke;configuration"}- );+ });logger.info("Venafi TPP: Successfully obtained access token");@@ -192,13 +147,12 @@ export const authenticateVenafiTpp = async (export const revokeVenafiTppToken = async ({ credentials, ...appConnection }: { gatewayId?: string | null; credentials: { tppUrl: string } },accessToken: string,- gatewayService: Pick<TGatewayServiceFactory, "fnGetGatewayClientTlsByGatewayId">,gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">): Promise<void> => {const baseUrl = normalizeTppUrl(credentials.tppUrl);try {- await requestWithVenafiTppGateway(appConnection, gatewayService, gatewayV2Service, {+ await requestWithVenafiTppGateway(appConnection, gatewayV2Service, {method: "GET",url: `${baseUrl}/vedauth/revoke/token`,headers: {@@ -226,7 +180,6 @@ export const getVenafiTppConnectionListItem = () => {export const validateVenafiTppConnectionCredentials = async (config: TVenafiTppConnectionConfig,- gatewayService: Pick<TGatewayServiceFactory, "fnGetGatewayClientTlsByGatewayId">,gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">) => {const credentials = config.credentials as TVenafiTppCredentials;@@ -236,11 +189,7 @@ export const validateVenafiTppConnectionCredentials = async (let accessToken: string | undefined;try {- const authResponse = await authenticateVenafiTpp(- { gatewayId: config.gatewayId, credentials },- gatewayService,- gatewayV2Service- );+ const authResponse = await authenticateVenafiTpp({ gatewayId: config.gatewayId, credentials }, gatewayV2Service);accessToken = authResponse.access_token;logger.info(@@ -276,12 +225,7 @@ export const validateVenafiTppConnectionCredentials = async (});} finally {if (accessToken) {- await revokeVenafiTppToken(- { gatewayId: config.gatewayId, credentials },- accessToken,- gatewayService,- gatewayV2Service- );+ await revokeVenafiTppToken({ gatewayId: config.gatewayId, credentials }, accessToken, gatewayV2Service);}}diff --git a/backend/src/services/certificate-authority/certificate-authority-service.ts b/backend/src/services/certificate-authority/certificate-authority-service.tsindex 037ad1a339..85e9f37495 100644--- a/backend/src/services/certificate-authority/certificate-authority-service.ts+++ b/backend/src/services/certificate-authority/certificate-authority-service.ts@@ -1,7 +1,6 @@import { ForbiddenError, subject } from "@casl/ability";import { ActionProjectType, TableName } from "@app/db/schemas";-import { TGatewayServiceFactory } from "@app/ee/services/gateway/gateway-service";import { TGatewayV2ServiceFactory } from "@app/ee/services/gateway-v2/gateway-v2-service";import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";import {@@ -124,7 +123,6 @@ type TCertificateAuthorityServiceFactoryDep = {"findById" | "updateById" | "updateStatus" | "attachCertificate">;resourceMetadataDAL: Pick<TResourceMetadataDALFactory, "find" | "insertMany">;- gatewayService: Pick<TGatewayServiceFactory, "fnGetGatewayClientTlsByGatewayId">;gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">;};@@ -148,7 +146,6 @@ export const certificateAuthorityServiceFactory = ({certificateProfileDAL,certificateRequestDAL,resourceMetadataDAL,- gatewayService,gatewayV2Service}: TCertificateAuthorityServiceFactoryDep) => {const acmeFns = AcmeCertificateAuthorityFns({@@ -194,7 +191,6 @@ export const certificateAuthorityServiceFactory = ({kmsService,projectDAL,certificateProfileDAL,- gatewayService,gatewayV2Service});diff --git a/backend/src/services/certificate-authority/certificate-issuance-queue.ts b/backend/src/services/certificate-authority/certificate-issuance-queue.tsindex 10175eb48a..cf873eb1f7 100644--- a/backend/src/services/certificate-authority/certificate-issuance-queue.ts+++ b/backend/src/services/certificate-authority/certificate-issuance-queue.ts@@ -1,7 +1,6 @@import acme from "acme-client";import { UnrecoverableError } from "bullmq";-import { TGatewayServiceFactory } from "@app/ee/services/gateway/gateway-service";import { TGatewayV2ServiceFactory } from "@app/ee/services/gateway-v2/gateway-v2-service";import { crypto } from "@app/lib/crypto/cryptography";import { NotFoundError } from "@app/lib/errors";@@ -123,7 +122,6 @@ type TCertificateIssuanceQueueFactoryDep = {certificateRequestDAL?: Pick<TCertificateRequestDALFactory, "updateById">;resourceMetadataDAL: Pick<TResourceMetadataDALFactory, "find" | "insertMany">;pkiAlertV2Queue?: Pick<TPkiAlertV2QueueServiceFactory, "queueCertificateEvent">;- gatewayService: Pick<TGatewayServiceFactory, "fnGetGatewayClientTlsByGatewayId">;gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">;};@@ -148,7 +146,6 @@ export const certificateIssuanceQueueFactory = ({certificateRequestDAL,resourceMetadataDAL,pkiAlertV2Queue,- gatewayService,gatewayV2Service}: TCertificateIssuanceQueueFactoryDep) => {const acmeFns = AcmeCertificateAuthorityFns({@@ -232,7 +229,6 @@ export const certificateIssuanceQueueFactory = ({kmsService,projectDAL,certificateProfileDAL,- gatewayService,gatewayV2Service});diff --git a/backend/src/services/certificate-authority/venafi-tpp/venafi-tpp-certificate-authority-fns.ts b/backend/src/services/certificate-authority/venafi-tpp/venafi-tpp-certificate-authority-fns.tsindex 413d4a0489..b8fabb7283 100644--- a/backend/src/services/certificate-authority/venafi-tpp/venafi-tpp-certificate-authority-fns.ts+++ b/backend/src/services/certificate-authority/venafi-tpp/venafi-tpp-certificate-authority-fns.ts@@ -4,7 +4,6 @@ import { AxiosError } from "axios";import RE2 from "re2";import { TableName } from "@app/db/schemas";-import { TGatewayServiceFactory } from "@app/ee/services/gateway/gateway-service";import { TGatewayV2ServiceFactory } from "@app/ee/services/gateway-v2/gateway-v2-service";import { crypto } from "@app/lib/crypto/cryptography";import { BadRequestError, NotFoundError } from "@app/lib/errors";@@ -162,7 +161,6 @@ const submitCertificateToTpp = async ({objectName,altNames,workToDoTimeout = 30,- gatewayService,gatewayV2Service}: {appConnection: { gatewayId?: string | null };@@ -173,7 +171,6 @@ const submitCertificateToTpp = async ({objectName: string;altNames?: Array<{ type: CertSubjectAlternativeNameType; value: string }>;workToDoTimeout?: number;- gatewayService: Pick<TGatewayServiceFactory, "fnGetGatewayClientTlsByGatewayId">;gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">;}): Promise<TVenafiTppRequestResponse> => {const requestBody: TVenafiTppCertificateRequest = {@@ -200,7 +197,6 @@ const submitCertificateToTpp = async ({const { data, status } = await requestWithVenafiTppGateway<TVenafiTppRequestResponse>(appConnection,- gatewayService,gatewayV2Service,{method: "POST",@@ -230,7 +226,6 @@ const retrieveCertificateFromTpp = async ({accessToken,certificateDN,includeChain = true,- gatewayService,gatewayV2Service}: {appConnection: { gatewayId?: string | null };@@ -238,14 +233,12 @@ const retrieveCertificateFromTpp = async ({accessToken: string;certificateDN: string;includeChain?: boolean;- gatewayService: Pick<TGatewayServiceFactory, "fnGetGatewayClientTlsByGatewayId">;gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">;}): Promise<{ certificate: string; chain: string }> => {logger.info({ certificateDN, includeChain }, "Venafi TPP: Retrieving certificate");const { data, status } = await requestWithVenafiTppGateway<TVenafiTppRetrieveResponse>(appConnection,- gatewayService,gatewayV2Service,{method: "POST",@@ -348,7 +341,6 @@ type TVenafiTppCertificateAuthorityFnsDeps = {kmsService: Pick<TKmsServiceFactory, "encryptWithKmsKey" | "generateKmsKey" | "createCipherPairWithDataKey">;projectDAL: Pick<TProjectDALFactory, "findById" | "findOne" | "updateById" | "transaction">;certificateProfileDAL?: Pick<TCertificateProfileDALFactory, "findById">;- gatewayService: Pick<TGatewayServiceFactory, "fnGetGatewayClientTlsByGatewayId">;gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">;};@@ -363,7 +355,6 @@ export const VenafiTppCertificateAuthorityFns = ({kmsService,projectDAL,certificateProfileDAL,- gatewayService,gatewayV2Service}: TVenafiTppCertificateAuthorityFnsDeps) => {const createCertificateAuthority = async ({@@ -698,7 +689,7 @@ export const VenafiTppCertificateAuthorityFns = ({let accessToken: string | undefined;try {- const authResponse = await authenticateVenafiTpp({ gatewayId, credentials }, gatewayService, gatewayV2Service);+ const authResponse = await authenticateVenafiTpp({ gatewayId, credentials }, gatewayV2Service);accessToken = authResponse.access_token;const requestResponse = await submitCertificateToTpp({@@ -710,7 +701,6 @@ export const VenafiTppCertificateAuthorityFns = ({objectName: commonName,altNames,workToDoTimeout: 60,- gatewayService,gatewayV2Service});@@ -743,7 +733,6 @@ export const VenafiTppCertificateAuthorityFns = ({accessToken,certificateDN: requestResponse.CertificateDN,includeChain: true,- gatewayService,gatewayV2Service});break;@@ -947,7 +936,7 @@ export const VenafiTppCertificateAuthorityFns = ({});} finally {if (accessToken) {- await revokeVenafiTppToken({ gatewayId, credentials }, accessToken, gatewayService, gatewayV2Service);+ await revokeVenafiTppToken({ gatewayId, credentials }, accessToken, gatewayV2Service);}}};