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
Address PR comments
Carlos Monastyrskia2cac916e8d7
diff --git a/backend/src/services/app-connection/app-connection-fns.ts b/backend/src/services/app-connection/app-connection-fns.tsindex d8edfc09a1..fed3a26ba6 100644--- a/backend/src/services/app-connection/app-connection-fns.ts+++ b/backend/src/services/app-connection/app-connection-fns.ts@@ -493,6 +493,7 @@ export const getAppConnectionMethodName = (method: TAppConnection["method"]) =>case AzureDevOpsConnectionMethod.OAuth:case HerokuConnectionMethod.OAuth:case GitLabConnectionMethod.OAuth:+ case VenafiTppConnectionMethod.OAuth:return "OAuth";case HerokuConnectionMethod.AuthToken:return "Auth Token";@@ -534,7 +535,6 @@ export const getAppConnectionMethodName = (method: TAppConnection["method"]) =>case AzureADCSConnectionMethod.UsernamePassword:case RedisConnectionMethod.UsernameAndPassword:case MongoDBConnectionMethod.UsernameAndPassword:- case VenafiTppConnectionMethod.UsernamePassword:return "Username & Password";case WindmillConnectionMethod.AccessToken:case HCVaultConnectionMethod.AccessToken:diff --git a/backend/src/services/app-connection/venafi-tpp/venafi-tpp-connection-enums.ts b/backend/src/services/app-connection/venafi-tpp/venafi-tpp-connection-enums.tsindex fe6a1ca246..5cdd3a1f04 100644--- a/backend/src/services/app-connection/venafi-tpp/venafi-tpp-connection-enums.ts+++ b/backend/src/services/app-connection/venafi-tpp/venafi-tpp-connection-enums.ts@@ -1,3 +1,3 @@export enum VenafiTppConnectionMethod {- UsernamePassword = "username-password"+ OAuth = "oauth"}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 e4360c08cb..bdeee09456 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@@ -86,7 +86,7 @@ export const getVenafiTppConnectionListItem = () => {return {name: "Venafi TPP" as const,app: AppConnection.VenafiTpp as const,- methods: Object.values(VenafiTppConnectionMethod) as [VenafiTppConnectionMethod.UsernamePassword]+ methods: Object.values(VenafiTppConnectionMethod) as [VenafiTppConnectionMethod.OAuth]};};diff --git a/backend/src/services/app-connection/venafi-tpp/venafi-tpp-connection-schemas.ts b/backend/src/services/app-connection/venafi-tpp/venafi-tpp-connection-schemas.tsindex 3cfe23779a..aff8c0d796 100644--- a/backend/src/services/app-connection/venafi-tpp/venafi-tpp-connection-schemas.ts+++ b/backend/src/services/app-connection/venafi-tpp/venafi-tpp-connection-schemas.ts@@ -11,7 +11,7 @@ import {import { APP_CONNECTION_NAME_MAP } from "../app-connection-maps";import { VenafiTppConnectionMethod } from "./venafi-tpp-connection-enums";-export const VenafiTppUsernamePasswordCredentialsSchema = z.object({+export const VenafiTppOAuthCredentialsSchema = z.object({tppUrl: z.string().trim()@@ -42,29 +42,25 @@ export const VenafiTppUsernamePasswordCredentialsSchema = z.object({const BaseVenafiTppConnectionSchema = BaseAppConnectionSchema.extend({ app: z.literal(AppConnection.VenafiTpp) });export const VenafiTppConnectionSchema = BaseVenafiTppConnectionSchema.extend({- method: z.literal(VenafiTppConnectionMethod.UsernamePassword),- credentials: VenafiTppUsernamePasswordCredentialsSchema+ method: z.literal(VenafiTppConnectionMethod.OAuth),+ credentials: VenafiTppOAuthCredentialsSchema});export const SanitizedVenafiTppConnectionSchema = z.discriminatedUnion("method", [BaseVenafiTppConnectionSchema.extend({- method: z.literal(VenafiTppConnectionMethod.UsernamePassword),- credentials: VenafiTppUsernamePasswordCredentialsSchema.pick({+ method: z.literal(VenafiTppConnectionMethod.OAuth),+ credentials: VenafiTppOAuthCredentialsSchema.pick({tppUrl: true,clientId: true,username: true})- }).describe(JSON.stringify({ title: `${APP_CONNECTION_NAME_MAP[AppConnection.VenafiTpp]} (Username and Password)` }))+ }).describe(JSON.stringify({ title: `${APP_CONNECTION_NAME_MAP[AppConnection.VenafiTpp]} (OAuth)` }))]);export const ValidateVenafiTppConnectionCredentialsSchema = z.discriminatedUnion("method", [z.object({- method: z- .literal(VenafiTppConnectionMethod.UsernamePassword)- .describe(AppConnections.CREATE(AppConnection.VenafiTpp).method),- credentials: VenafiTppUsernamePasswordCredentialsSchema.describe(- AppConnections.CREATE(AppConnection.VenafiTpp).credentials- )+ method: z.literal(VenafiTppConnectionMethod.OAuth).describe(AppConnections.CREATE(AppConnection.VenafiTpp).method),+ credentials: VenafiTppOAuthCredentialsSchema.describe(AppConnections.CREATE(AppConnection.VenafiTpp).credentials)})]);@@ -74,7 +70,7 @@ export const CreateVenafiTppConnectionSchema = ValidateVenafiTppConnectionCredenexport const UpdateVenafiTppConnectionSchema = z.object({- credentials: VenafiTppUsernamePasswordCredentialsSchema.optional().describe(+ credentials: VenafiTppOAuthCredentialsSchema.optional().describe(AppConnections.UPDATE(AppConnection.VenafiTpp).credentials)})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 344292f5df..925b86c1a7 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@@ -29,6 +29,7 @@ import {CertStatus,TAltNameType} from "@app/services/certificate/certificate-types";+import { calculateRenewalThreshold, parseTtlToDays } from "@app/services/certificate-common/certificate-issuance-utils";import { TCertificateProfileDALFactory } from "@app/services/certificate-profile/certificate-profile-dal";import { TKmsServiceFactory } from "@app/services/kms/kms-service";import { TProjectDALFactory } from "@app/services/project/project-dal";@@ -50,6 +51,54 @@ const VENAFI_SAN_TYPE_IP = 7;const VENAFI_SAN_TYPE_EMAIL = 1;const VENAFI_SAN_TYPE_URI = 6;+const IPV4_DOTTED_QUAD_REGEX = new RE2("^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$");++type TNormalizedSanType = "dns" | "ip" | "email" | "uri";++const parseSanEntry = (san: string): { type: TNormalizedSanType; value: string } => {+ const colonIdx = san.indexOf(":");+ if (colonIdx > 0) {+ const prefix = san.substring(0, colonIdx).toLowerCase();+ const value = san.substring(colonIdx + 1);+ switch (prefix) {+ case "dns":+ case "dns_name":+ return { type: "dns", value };+ case "ip":+ case "ip_address":+ return { type: "ip", value };+ case "email":+ return { type: "email", value };+ case "uri":+ return { type: "uri", value };+ default:+ throw new BadRequestError({+ message: `Unsupported Subject Alternative Name type prefix '${prefix}'. Supported prefixes: dns, dns_name, ip, ip_address, email, uri.`+ });+ }+ }++ if (IPV4_DOTTED_QUAD_REGEX.test(san)) {+ return { type: "ip", value: san };+ }++ return { type: "dns", value: san };+};++const VENAFI_SAN_TYPE_BY_NORMALIZED: Record<TNormalizedSanType, number> = {+ dns: VENAFI_SAN_TYPE_DNS,+ ip: VENAFI_SAN_TYPE_IP,+ email: VENAFI_SAN_TYPE_EMAIL,+ uri: VENAFI_SAN_TYPE_URI+};++const X509_ALT_NAME_TYPE_BY_NORMALIZED: Record<TNormalizedSanType, TAltNameType> = {+ dns: "dns" as TAltNameType,+ ip: "ip" as TAltNameType,+ email: "email" as TAltNameType,+ uri: "url" as TAltNameType+};+type TVenafiTppCertificateRequest = {PolicyDN: string;PKCS10: string;@@ -75,46 +124,20 @@ type TVenafiTppRetrieveResponse = {Format: string;};-const parseTtlToDays = (ttl: string): number => {- const match = ttl.match(new RE2("^(\\d+)([dhm])$"));- if (!match) {- throw new BadRequestError({- message: `Invalid TTL format: ${ttl}. Expected format like '365d', '24h', or '60m'.`- });- }- const value = parseInt(match[1], 10);- const unit = match[2];- switch (unit) {- case "d":- return value;- case "h":- return Math.max(1, Math.ceil(value / 24));- case "m":- return Math.max(1, Math.ceil(value / (24 * 60)));- default:- return value;- }-};-const calculateFinalRenewBeforeDays = (profile: { apiConfig?: { autoRenew?: boolean; renewBeforeDays?: number } } | undefined,ttl: string): number | undefined => {- const hasAutoRenewEnabled = profile?.apiConfig?.autoRenew === true;- if (!hasAutoRenewEnabled) {+ if (!profile?.apiConfig?.autoRenew) {return undefined;}- const profileRenewBeforeDays = profile?.apiConfig?.renewBeforeDays;- if (profileRenewBeforeDays !== undefined) {- const certificateTtlInDays = parseTtlToDays(ttl);- if (profileRenewBeforeDays >= certificateTtlInDays) {- return Math.max(1, certificateTtlInDays - 1);- }- return profileRenewBeforeDays;+ const profileRenewBeforeDays = profile.apiConfig.renewBeforeDays;+ if (profileRenewBeforeDays === undefined) {+ return undefined;}- return undefined;+ return calculateRenewalThreshold(profileRenewBeforeDays, parseTtlToDays(ttl));};const normalizeTppUrl = (tppUrl: string): string => {@@ -124,32 +147,9 @@ const normalizeTppUrl = (tppUrl: string): string => {/*** Parses a SAN string (e.g., "dns:example.com" or just "example.com") into Venafi TPP SAN format.*/-const parseSanToVenafiFormat = (san: string): { Type: number; Name: string } | null => {- const colonIdx = san.indexOf(":");- if (colonIdx > 0) {- const prefix = san.substring(0, colonIdx).toLowerCase();- const value = san.substring(colonIdx + 1);- switch (prefix) {- case "dns":- case "dns_name":- return { Type: VENAFI_SAN_TYPE_DNS, Name: value };- case "ip":- case "ip_address":- return { Type: VENAFI_SAN_TYPE_IP, Name: value };- case "email":- return { Type: VENAFI_SAN_TYPE_EMAIL, Name: value };- case "uri":- return { Type: VENAFI_SAN_TYPE_URI, Name: value };- default:- return { Type: VENAFI_SAN_TYPE_DNS, Name: san };- }- }-- if (san.match(new RE2("^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$"))) {- return { Type: VENAFI_SAN_TYPE_IP, Name: san };- }-- return { Type: VENAFI_SAN_TYPE_DNS, Name: san };+const parseSanToVenafiFormat = (san: string): { Type: number; Name: string } => {+ const { type, value } = parseSanEntry(san);+ return { Type: VENAFI_SAN_TYPE_BY_NORMALIZED[type], Name: value };};const getVenafiTppConnectionCredentials = async (@@ -220,13 +220,7 @@ const submitCertificateToTpp = async ({};if (altNames && altNames.length > 0) {- const venafiSans = altNames.map((san) => parseSanToVenafiFormat(san)).filter(Boolean) as Array<{- Type: number;- Name: string;- }>;- if (venafiSans.length > 0) {- requestBody.SubjectAltNames = venafiSans;- }+ requestBody.SubjectAltNames = altNames.map((san) => parseSanToVenafiFormat(san));}logger.info(@@ -698,30 +692,9 @@ export const VenafiTppCertificateAuthorityFns = ({const sanExtensions: x509.SubjectAlternativeNameExtension[] = [];if (altNames.length > 0) {- const sanEntries: Array<{ type: TAltNameType; value: string }> = altNames.map((name) => {- const colonIdx = name.indexOf(":");- if (colonIdx > 0) {- const prefix = name.substring(0, colonIdx).toLowerCase();- const value = name.substring(colonIdx + 1);- switch (prefix) {- case "ip":- case "ip_address":- return { type: "ip" as TAltNameType, value };- case "email":- return { type: "email" as TAltNameType, value };- case "uri":- return { type: "url" as TAltNameType, value };- case "dns":- case "dns_name":- return { type: "dns" as TAltNameType, value };- default:- return { type: "dns" as TAltNameType, value: name };- }- }- if (name.match(new RE2("^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$"))) {- return { type: "ip" as TAltNameType, value: name };- }- return { type: "dns" as TAltNameType, value: name };+ const sanEntries = altNames.map((name) => {+ const { type, value } = parseSanEntry(name);+ return { type: X509_ALT_NAME_TYPE_BY_NORMALIZED[type], value };});sanExtensions.push(new x509.SubjectAlternativeNameExtension(sanEntries, false));diff --git a/docs/integrations/app-connections/venafi-tpp.mdx b/docs/integrations/app-connections/venafi-tpp.mdxindex b1c1655b09..8acc5560e7 100644--- a/docs/integrations/app-connections/venafi-tpp.mdx+++ b/docs/integrations/app-connections/venafi-tpp.mdx@@ -32,7 +32,7 @@ Connect Infisical to a self-hosted Venafi Trust Protection Platform (TPP) instanConfigure the following fields:- **Name**: A friendly name for this connection (e.g., "Production TPP")- - **Method**: The authentication method. Currently only **Username & Password** is supported.+ - **Method**: The authentication method. Currently only **OAuth** is supported.- **Gateway** *(optional)*: Select an Infisical Gateway if your TPP instance is in an airgapped network without direct internet access.- **TPP URL**: The HTTPS URL of your Venafi TPP instance (e.g., `https://tpp.example.com`). Must use HTTPS.- **Client ID**: The OAuth Client ID from your TPP API Integration.diff --git a/frontend/src/helpers/appConnections.ts b/frontend/src/helpers/appConnections.tsindex 9b6518eef9..4d5fdbc2ec 100644--- a/frontend/src/helpers/appConnections.ts+++ b/frontend/src/helpers/appConnections.ts@@ -189,6 +189,7 @@ export const getAppConnectionMethodDetails = (method: TAppConnection["method"])case GitHubConnectionMethod.OAuth:case HerokuConnectionMethod.OAuth:case GitLabConnectionMethod.OAuth:+ case VenafiTppConnectionMethod.OAuth:return { name: "OAuth", icon: faPassport };case AwsConnectionMethod.AccessKey:case OCIConnectionMethod.AccessKey:@@ -224,7 +225,6 @@ export const getAppConnectionMethodDetails = (method: TAppConnection["method"])case MySqlConnectionMethod.UsernameAndPassword:case OracleDBConnectionMethod.UsernameAndPassword:case AzureADCSConnectionMethod.UsernamePassword:- case VenafiTppConnectionMethod.UsernamePassword:case RedisConnectionMethod.UsernameAndPassword:case MongoDBConnectionMethod.UsernameAndPassword:return { name: "Username & Password", icon: faLock };diff --git a/frontend/src/hooks/api/appConnections/types/venafi-tpp-connection.ts b/frontend/src/hooks/api/appConnections/types/venafi-tpp-connection.tsindex 0c3dd901cf..f8c20d27ac 100644--- a/frontend/src/hooks/api/appConnections/types/venafi-tpp-connection.ts+++ b/frontend/src/hooks/api/appConnections/types/venafi-tpp-connection.ts@@ -2,12 +2,12 @@ import { AppConnection } from "../enums";import { TRootAppConnection } from "./root-connection";export enum VenafiTppConnectionMethod {- UsernamePassword = "username-password"+ OAuth = "oauth"}export type TVenafiTppConnection = TRootAppConnection & {app: AppConnection.VenafiTpp;- method: VenafiTppConnectionMethod.UsernamePassword;+ method: VenafiTppConnectionMethod.OAuth;credentials: {tppUrl: string;clientId: string;diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/VenafiTppConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/VenafiTppConnectionForm.tsxindex 52efb3cf6a..1dc0556290 100644--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/VenafiTppConnectionForm.tsx+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/VenafiTppConnectionForm.tsx@@ -40,7 +40,7 @@ const rootSchema = genericAppConnectionFieldsSchema.extend({const formSchema = z.discriminatedUnion("method", [rootSchema.extend({- method: z.literal(VenafiTppConnectionMethod.UsernamePassword),+ method: z.literal(VenafiTppConnectionMethod.OAuth),credentials: z.object({tppUrl: z.string()@@ -63,7 +63,7 @@ export const VenafiTppConnectionForm = ({ appConnection, onSubmit }: Props) => {resolver: zodResolver(formSchema),defaultValues: appConnection ?? {app: AppConnection.VenafiTpp,- method: VenafiTppConnectionMethod.UsernamePassword,+ method: VenafiTppConnectionMethod.OAuth,name: "",description: "",gatewayId: null,