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
Add F5 Big IP pki sync
Carlos Monastyrski88134d2ace67
diff --git a/backend/src/server/routes/v1/app-connection-routers/app-connection-router.ts b/backend/src/server/routes/v1/app-connection-routers/app-connection-router.tsindex f98a37c821..0f539170c0 100644--- a/backend/src/server/routes/v1/app-connection-routers/app-connection-router.ts+++ b/backend/src/server/routes/v1/app-connection-routers/app-connection-router.ts@@ -99,6 +99,10 @@ import {ExternalInfisicalConnectionListItemSchema,SanitizedExternalInfisicalConnectionSchema} from "@app/services/app-connection/external-infisical";+import {+ F5BigIpConnectionListItemSchema,+ SanitizedF5BigIpConnectionSchema+} from "@app/services/app-connection/f5-big-ip";import { FlyioConnectionListItemSchema, SanitizedFlyioConnectionSchema } from "@app/services/app-connection/flyio";import { GcpConnectionListItemSchema, SanitizedGcpConnectionSchema } from "@app/services/app-connection/gcp";import { GitHubConnectionListItemSchema, SanitizedGitHubConnectionSchema } from "@app/services/app-connection/github";@@ -269,7 +273,8 @@ const SanitizedAppConnectionSchema = z.union([...SanitizedTravisCIConnectionSchema.options,...SanitizedSalesforceConnectionSchema.options,...SanitizedSnowflakeConnectionSchema.options,- ...SanitizedDatadogConnectionSchema.options+ ...SanitizedDatadogConnectionSchema.options,+ ...SanitizedF5BigIpConnectionSchema.options]);const AppConnectionOptionsSchema = z.discriminatedUnion("app", [@@ -338,7 +343,8 @@ const AppConnectionOptionsSchema = z.discriminatedUnion("app", [TravisCIConnectionListItemSchema,SalesforceConnectionListItemSchema,SnowflakeConnectionListItemSchema,- DatadogConnectionListItemSchema+ DatadogConnectionListItemSchema,+ F5BigIpConnectionListItemSchema]);export const registerAppConnectionRouter = async (server: FastifyZodProvider) => {diff --git a/backend/src/server/routes/v1/app-connection-routers/f5-big-ip-connection-router.ts b/backend/src/server/routes/v1/app-connection-routers/f5-big-ip-connection-router.tsnew file mode 100644index 0000000000..5d70defe3e--- /dev/null+++ b/backend/src/server/routes/v1/app-connection-routers/f5-big-ip-connection-router.ts@@ -0,0 +1,18 @@+import { AppConnection } from "@app/services/app-connection/app-connection-enums";+import {+ CreateF5BigIpConnectionSchema,+ SanitizedF5BigIpConnectionSchema,+ UpdateF5BigIpConnectionSchema+} from "@app/services/app-connection/f5-big-ip";++import { registerAppConnectionEndpoints } from "./app-connection-endpoints";++export const registerF5BigIpConnectionRouter = async (server: FastifyZodProvider) => {+ registerAppConnectionEndpoints({+ app: AppConnection.F5BigIp,+ server,+ sanitizedResponseSchema: SanitizedF5BigIpConnectionSchema,+ createSchema: CreateF5BigIpConnectionSchema,+ updateSchema: UpdateF5BigIpConnectionSchema+ });+};diff --git a/backend/src/server/routes/v1/app-connection-routers/index.ts b/backend/src/server/routes/v1/app-connection-routers/index.tsindex f0c5105efc..ddf189d2f1 100644--- a/backend/src/server/routes/v1/app-connection-routers/index.ts+++ b/backend/src/server/routes/v1/app-connection-routers/index.ts@@ -28,6 +28,7 @@ import { registerDigitalOceanConnectionRouter } from "./digital-ocean-connectionimport { registerDNSMadeEasyConnectionRouter } from "./dns-made-easy-connection-router";import { registerDopplerConnectionRouter } from "./doppler-connection-router";import { registerExternalInfisicalConnectionRouter } from "./external-infisical-connection-router";+import { registerF5BigIpConnectionRouter } from "./f5-big-ip-connection-router";import { registerFlyioConnectionRouter } from "./flyio-connection-router";import { registerGcpConnectionRouter } from "./gcp-connection-router";import { registerGitHubConnectionRouter } from "./github-connection-router";@@ -136,5 +137,6 @@ export const APP_CONNECTION_REGISTER_ROUTER_MAP: Record<AppConnection, (server:[AppConnection.TravisCI]: registerTravisCIConnectionRouter,[AppConnection.Salesforce]: registerSalesforceConnectionRouter,[AppConnection.Snowflake]: registerSnowflakeConnectionRouter,- [AppConnection.Datadog]: registerDatadogConnectionRouter+ [AppConnection.Datadog]: registerDatadogConnectionRouter,+ [AppConnection.F5BigIp]: registerF5BigIpConnectionRouter};diff --git a/backend/src/server/routes/v1/pki-sync-routers/f5-big-ip-pki-sync-router.ts b/backend/src/server/routes/v1/pki-sync-routers/f5-big-ip-pki-sync-router.tsnew file mode 100644index 0000000000..ee14e0c1fa--- /dev/null+++ b/backend/src/server/routes/v1/pki-sync-routers/f5-big-ip-pki-sync-router.ts@@ -0,0 +1,23 @@+import {+ CreateF5BigIpPkiSyncSchema,+ F5_BIG_IP_PKI_SYNC_LIST_OPTION,+ F5BigIpPkiSyncSchema,+ UpdateF5BigIpPkiSyncSchema+} from "@app/services/pki-sync/f5-big-ip";+import { PkiSync } from "@app/services/pki-sync/pki-sync-enums";++import { registerSyncPkiEndpoints } from "./pki-sync-endpoints";++export const registerF5BigIpPkiSyncRouter = async (server: FastifyZodProvider, enableOperationId: boolean = true) =>+ registerSyncPkiEndpoints({+ destination: PkiSync.F5BigIp,+ server,+ responseSchema: F5BigIpPkiSyncSchema,+ createSchema: CreateF5BigIpPkiSyncSchema,+ updateSchema: UpdateF5BigIpPkiSyncSchema,+ syncOptions: {+ canImportCertificates: F5_BIG_IP_PKI_SYNC_LIST_OPTION.canImportCertificates,+ canRemoveCertificates: F5_BIG_IP_PKI_SYNC_LIST_OPTION.canRemoveCertificates+ },+ enableOperationId+ });diff --git a/backend/src/server/routes/v1/pki-sync-routers/index.ts b/backend/src/server/routes/v1/pki-sync-routers/index.tsindex 901452c468..dda3a31445 100644--- a/backend/src/server/routes/v1/pki-sync-routers/index.ts+++ b/backend/src/server/routes/v1/pki-sync-routers/index.ts@@ -6,6 +6,7 @@ import { registerAwsSecretsManagerPkiSyncRouter } from "./aws-secrets-manager-pkimport { registerAzureKeyVaultPkiSyncRouter } from "./azure-key-vault-pki-sync-router";import { registerChefPkiSyncRouter } from "./chef-pki-sync-router";import { registerCloudflareCustomCertificatePkiSyncRouter } from "./cloudflare-custom-certificate-pki-sync-router";+import { registerF5BigIpPkiSyncRouter } from "./f5-big-ip-pki-sync-router";import { registerNetScalerPkiSyncRouter } from "./netscaler-pki-sync-router";export * from "./pki-sync-router";@@ -20,5 +21,6 @@ export const PKI_SYNC_REGISTER_ROUTER_MAP: Record<[PkiSync.AwsElasticLoadBalancer]: registerAwsElasticLoadBalancerPkiSyncRouter,[PkiSync.Chef]: registerChefPkiSyncRouter,[PkiSync.CloudflareCustomCertificate]: registerCloudflareCustomCertificatePkiSyncRouter,- [PkiSync.NetScaler]: registerNetScalerPkiSyncRouter+ [PkiSync.NetScaler]: registerNetScalerPkiSyncRouter,+ [PkiSync.F5BigIp]: registerF5BigIpPkiSyncRouter};diff --git a/backend/src/services/app-connection/app-connection-enums.ts b/backend/src/services/app-connection/app-connection-enums.tsindex 783a04e8e5..4cea726f58 100644--- a/backend/src/services/app-connection/app-connection-enums.ts+++ b/backend/src/services/app-connection/app-connection-enums.ts@@ -64,7 +64,8 @@ export enum AppConnection {TravisCI = "travis-ci",Salesforce = "salesforce",Snowflake = "snowflake",- Datadog = "datadog"+ Datadog = "datadog",+ F5BigIp = "f5-big-ip"}export enum AWSRegion {diff --git a/backend/src/services/app-connection/app-connection-fns.ts b/backend/src/services/app-connection/app-connection-fns.tsindex 16676710ec..0f217877c0 100644--- a/backend/src/services/app-connection/app-connection-fns.ts+++ b/backend/src/services/app-connection/app-connection-fns.ts@@ -134,6 +134,11 @@ import {TExternalInfisicalConnectionConfig,validateExternalInfisicalConnectionCredentials} from "./external-infisical";+import {+ F5BigIpConnectionMethod,+ getF5BigIpConnectionListItem,+ validateF5BigIpConnectionCredentials+} from "./f5-big-ip";import { FlyioConnectionMethod, getFlyioConnectionListItem, validateFlyioConnectionCredentials } from "./flyio";import { GcpConnectionMethod, getGcpConnectionListItem, validateGcpConnectionCredentials } from "./gcp";import { getGitHubConnectionListItem, GitHubConnectionMethod, validateGitHubConnectionCredentials } from "./github";@@ -267,7 +272,8 @@ const PKI_APP_CONNECTIONS = [AppConnection.Venafi,AppConnection.VenafiTpp,AppConnection.NetScaler,- AppConnection.DigiCert+ AppConnection.DigiCert,+ AppConnection.F5BigIp];export const listAppConnectionOptions = (projectType?: ProjectType) => {@@ -337,7 +343,8 @@ export const listAppConnectionOptions = (projectType?: ProjectType) => {getTravisCIConnectionListItem(),getSalesforceConnectionListItem(),getSnowflakeConnectionListItem(),- getDatadogConnectionListItem()+ getDatadogConnectionListItem(),+ getF5BigIpConnectionListItem()].filter((option) => {switch (projectType) {@@ -564,7 +571,8 @@ export const validateAppConnectionCredentials = async ([AppConnection.OVH]: validateOvhConnectionCredentials as TAppConnectionCredentialsValidator,[AppConnection.DigiCert]: validateDigiCertConnectionCredentials as TAppConnectionCredentialsValidator,[AppConnection.Snowflake]: validateSnowflakeConnectionCredentials as TAppConnectionCredentialsValidator,- [AppConnection.Datadog]: validateDatadogConnectionCredentials as TAppConnectionCredentialsValidator+ [AppConnection.Datadog]: validateDatadogConnectionCredentials as TAppConnectionCredentialsValidator,+ [AppConnection.F5BigIp]: validateF5BigIpConnectionCredentials as TAppConnectionCredentialsValidator};return VALIDATE_APP_CONNECTION_CREDENTIALS_MAP[appConnection.app](appConnection, gatewayService, gatewayV2Service);@@ -665,6 +673,8 @@ export const getAppConnectionMethodName = (method: TAppConnection["method"]) =>return "Access Token";case NetScalerConnectionMethod.BasicAuth:return "Basic Auth";+ case F5BigIpConnectionMethod.BasicAuth:+ return "Basic Auth";case ExternalInfisicalConnectionMethod.MachineIdentityUniversalAuth:return "Machine Identity - Universal Auth";case DopplerConnectionMethod.ApiToken:@@ -798,7 +808,8 @@ export const TRANSITION_CONNECTION_CREDENTIALS_TO_PLATFORM: Record<[AppConnection.TravisCI]: platformManagedCredentialsNotSupported,[AppConnection.Salesforce]: platformManagedCredentialsNotSupported,[AppConnection.Snowflake]: platformManagedCredentialsNotSupported,- [AppConnection.Datadog]: platformManagedCredentialsNotSupported+ [AppConnection.Datadog]: platformManagedCredentialsNotSupported,+ [AppConnection.F5BigIp]: platformManagedCredentialsNotSupported};export const enterpriseAppCheck = async (diff --git a/backend/src/services/app-connection/app-connection-maps.ts b/backend/src/services/app-connection/app-connection-maps.tsindex cb5e2cbc02..79add7b402 100644--- a/backend/src/services/app-connection/app-connection-maps.ts+++ b/backend/src/services/app-connection/app-connection-maps.ts@@ -66,7 +66,8 @@ export const APP_CONNECTION_NAME_MAP: Record<AppConnection, string> = {[AppConnection.TravisCI]: "Travis CI",[AppConnection.Salesforce]: "Salesforce",[AppConnection.Snowflake]: "Snowflake",- [AppConnection.Datadog]: "Datadog"+ [AppConnection.Datadog]: "Datadog",+ [AppConnection.F5BigIp]: "F5 BIG-IP"};export const APP_CONNECTION_PLAN_MAP: Record<AppConnection, AppConnectionPlanType> = {@@ -135,5 +136,6 @@ export const APP_CONNECTION_PLAN_MAP: Record<AppConnection, AppConnectionPlanTyp[AppConnection.TravisCI]: AppConnectionPlanType.Regular,[AppConnection.Salesforce]: AppConnectionPlanType.Regular,[AppConnection.Snowflake]: AppConnectionPlanType.Regular,- [AppConnection.Datadog]: AppConnectionPlanType.Regular+ [AppConnection.Datadog]: AppConnectionPlanType.Regular,+ [AppConnection.F5BigIp]: AppConnectionPlanType.Regular};diff --git a/backend/src/services/app-connection/app-connection-service.ts b/backend/src/services/app-connection/app-connection-service.tsindex 0f3ca91fe3..5703da6991 100644--- a/backend/src/services/app-connection/app-connection-service.ts+++ b/backend/src/services/app-connection/app-connection-service.ts@@ -101,6 +101,7 @@ import { ValidateDopplerConnectionCredentialsSchema } from "./doppler/doppler-coimport { dopplerConnectionService } from "./doppler/doppler-connection-service";import { ValidateExternalInfisicalConnectionCredentialsSchema } from "./external-infisical";import { externalInfisicalConnectionService } from "./external-infisical/external-infisical-connection-service";+import { ValidateF5BigIpConnectionCredentialsSchema } from "./f5-big-ip";import { ValidateFlyioConnectionCredentialsSchema } from "./flyio";import { flyioConnectionService } from "./flyio/flyio-connection-service";import { ValidateGcpConnectionCredentialsSchema } from "./gcp";@@ -252,7 +253,8 @@ const VALIDATE_APP_CONNECTION_CREDENTIALS_MAP: Record<AppConnection, TValidateAp[AppConnection.TravisCI]: ValidateTravisCIConnectionCredentialsSchema,[AppConnection.Salesforce]: ValidateSalesforceConnectionCredentialsSchema,[AppConnection.Snowflake]: ValidateSnowflakeConnectionCredentialsSchema,- [AppConnection.Datadog]: ValidateDatadogConnectionCredentialsSchema+ [AppConnection.Datadog]: ValidateDatadogConnectionCredentialsSchema,+ [AppConnection.F5BigIp]: ValidateF5BigIpConnectionCredentialsSchema};export const appConnectionServiceFactory = ({diff --git a/backend/src/services/app-connection/app-connection-types.ts b/backend/src/services/app-connection/app-connection-types.tsindex 324f4dd383..93361d97c4 100644--- a/backend/src/services/app-connection/app-connection-types.ts+++ b/backend/src/services/app-connection/app-connection-types.ts@@ -172,6 +172,12 @@ import {TExternalInfisicalConnectionInput,TValidateExternalInfisicalConnectionCredentialsSchema} from "./external-infisical";+import {+ TF5BigIpConnection,+ TF5BigIpConnectionConfig,+ TF5BigIpConnectionInput,+ TValidateF5BigIpConnectionCredentialsSchema+} from "./f5-big-ip";import {TFlyioConnection,TFlyioConnectionConfig,@@ -459,6 +465,7 @@ export type TAppConnection = { id: string; configuration?: TAppConnectionConfigu| TSalesforceConnection| TSnowflakeConnection| TDatadogConnection+ | TF5BigIpConnection);export type TAppConnectionRaw = NonNullable<Awaited<ReturnType<TAppConnectionDALFactory["findById"]>>>;@@ -536,6 +543,7 @@ export type TAppConnectionInput = { id: string } & (| TSalesforceConnectionInput| TSnowflakeConnectionInput| TDatadogConnectionInput+ | TF5BigIpConnectionInput);export type TSqlConnectionInput =@@ -644,7 +652,8 @@ export type TAppConnectionConfig =| TTravisCIConnectionConfig| TSalesforceConnectionConfig| TSnowflakeConnectionConfig- | TDatadogConnectionConfig;+ | TDatadogConnectionConfig+ | TF5BigIpConnectionConfig;export type TValidateAppConnectionCredentialsSchema =| TValidateAwsConnectionCredentialsSchema@@ -712,7 +721,8 @@ export type TValidateAppConnectionCredentialsSchema =| TValidateTravisCIConnectionCredentialsSchema| TValidateSalesforceConnectionCredentialsSchema| TValidateSnowflakeConnectionCredentialsSchema- | TValidateDatadogConnectionCredentialsSchema;+ | TValidateDatadogConnectionCredentialsSchema+ | TValidateF5BigIpConnectionCredentialsSchema;export type TListAwsConnectionKmsKeys = {connectionId: string;diff --git a/backend/src/services/app-connection/f5-big-ip/f5-big-ip-connection-enums.ts b/backend/src/services/app-connection/f5-big-ip/f5-big-ip-connection-enums.tsnew file mode 100644index 0000000000..27dd581392--- /dev/null+++ b/backend/src/services/app-connection/f5-big-ip/f5-big-ip-connection-enums.ts@@ -0,0 +1,3 @@+export enum F5BigIpConnectionMethod {+ BasicAuth = "basic-auth"+}diff --git a/backend/src/services/app-connection/f5-big-ip/f5-big-ip-connection-fns.ts b/backend/src/services/app-connection/f5-big-ip/f5-big-ip-connection-fns.tsnew file mode 100644index 0000000000..f0ac32cdec--- /dev/null+++ b/backend/src/services/app-connection/f5-big-ip/f5-big-ip-connection-fns.ts@@ -0,0 +1,246 @@+import { AxiosRequestConfig } from "axios";+import https from "https";++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 } from "@app/lib/gateway";+import { withGatewayV2Proxy } from "@app/lib/gateway-v2/gateway-v2";+import { blockLocalAndPrivateIpAddresses } from "@app/lib/validator";+import { AppConnection } from "@app/services/app-connection/app-connection-enums";++import { F5BigIpConnectionMethod } from "./f5-big-ip-connection-enums";+import { TF5BigIpConnectionConfig } from "./f5-big-ip-connection-types";++export const F5_BIG_IP_DEFAULT_PORT = 443;+export const F5_BIG_IP_LOGIN_PROVIDER = "tmos";++export const createF5BigIpHttpsAgent = (credentials: {+ sslRejectUnauthorized?: boolean;+ sslCertificate?: string;+}): https.Agent => {+ return new https.Agent({+ rejectUnauthorized: credentials.sslRejectUnauthorized,+ ca: credentials.sslCertificate ? [credentials.sslCertificate] : undefined+ });+};++export const getF5BigIpConnectionListItem = () => {+ return {+ name: "F5 BIG-IP" as const,+ app: AppConnection.F5BigIp as const,+ methods: Object.values(F5BigIpConnectionMethod) as [F5BigIpConnectionMethod.BasicAuth]+ };+};++const requestWithF5BigIpGateway = async <T>(+ config: TF5BigIpConnectionConfig,+ gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">,+ requestConfig: AxiosRequestConfig+): Promise<T> => {+ const { gatewayId, credentials } = config;+ const { hostname, port: credPort } = credentials;+ const port = credPort ?? F5_BIG_IP_DEFAULT_PORT;++ if (gatewayId && gatewayV2Service) {+ await blockLocalAndPrivateIpAddresses(`https://${hostname}`, true);++ const platformConnectionDetails = await gatewayV2Service.getPlatformConnectionDetailsByGatewayId({+ gatewayId,+ targetHost: hostname,+ targetPort: port+ });++ if (!platformConnectionDetails) {+ throw new BadRequestError({ message: "Unable to connect to gateway, no platform connection details found" });+ }++ return withGatewayV2Proxy(+ async (proxyPort) => {+ const httpsAgent = new https.Agent({+ servername: hostname,+ rejectUnauthorized: credentials.sslRejectUnauthorized,+ ca: credentials.sslCertificate ? [credentials.sslCertificate] : undefined+ });++ const proxyUrl = `https://localhost:${proxyPort}`;+ const finalRequestConfig: AxiosRequestConfig = {+ ...requestConfig,+ url: requestConfig.url?.replace(`https://${hostname}:${port}`, proxyUrl),+ headers: {+ ...requestConfig.headers,+ Host: hostname+ },+ httpsAgent+ };++ const resp = await request.request<T>(finalRequestConfig);+ return resp.data;+ },+ {+ protocol: GatewayProxyProtocol.Tcp,+ relayHost: platformConnectionDetails.relayHost,+ gateway: platformConnectionDetails.gateway,+ relay: platformConnectionDetails.relay+ }+ );+ }++ await blockLocalAndPrivateIpAddresses(`https://${hostname}`, false);++ const httpsAgent = createF5BigIpHttpsAgent(credentials);+ const resp = await request.request<T>({+ ...requestConfig,+ httpsAgent+ });+ return resp.data;+};++type TF5BigIpLoginResponse = {+ token?: {+ token?: string;+ name?: string;+ };+};++export const validateF5BigIpConnectionCredentials = async (+ config: TF5BigIpConnectionConfig,+ _gatewayService: Pick<TGatewayServiceFactory, "fnGetGatewayClientTlsByGatewayId">,+ gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">+) => {+ const { hostname, port, username, password } = config.credentials;++ const baseUrl = `https://${hostname}:${port ?? F5_BIG_IP_DEFAULT_PORT}`;++ let authToken: string | undefined;++ try {+ const loginData = await requestWithF5BigIpGateway<TF5BigIpLoginResponse>(config, gatewayV2Service, {+ method: "POST",+ url: `${baseUrl}/mgmt/shared/authn/login`,+ data: {+ username,+ password,+ loginProviderName: F5_BIG_IP_LOGIN_PROVIDER+ },+ headers: { "Content-Type": "application/json" }+ });++ authToken = loginData?.token?.token;++ if (!authToken) {+ throw new BadRequestError({+ message: "Unable to validate connection: login did not return an auth token"+ });+ }++ await requestWithF5BigIpGateway(config, gatewayV2Service, {+ method: "GET",+ url: `${baseUrl}/mgmt/tm/sys/version`,+ headers: {+ "Content-Type": "application/json",+ "X-F5-Auth-Token": authToken+ }+ });+ } catch (error: unknown) {+ if (error instanceof BadRequestError) {+ throw error;+ }+ throw new BadRequestError({+ message: `Unable to validate connection: ${error instanceof Error ? error.message : "verify credentials and that the F5 BIG-IP is reachable"}`+ });+ } finally {+ if (authToken) {+ try {+ await requestWithF5BigIpGateway(config, gatewayV2Service, {+ method: "DELETE",+ url: `${baseUrl}/mgmt/shared/authz/tokens/${encodeURIComponent(authToken)}`,+ headers: {+ "Content-Type": "application/json",+ "X-F5-Auth-Token": authToken+ }+ });+ } catch {+ // Ignore logout errors+ }+ }+ }++ return config.credentials;+};++export const executeF5BigIpOperationWithGateway = async <T>(+ config: {+ gatewayId?: string | null;+ credentials: TF5BigIpConnectionConfig["credentials"];+ },+ gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId"> | undefined,+ operation: (makeRequest: <R>(requestCfg: AxiosRequestConfig) => Promise<R>) => Promise<T>+): Promise<T> => {+ const { gatewayId, credentials } = config;+ const { hostname, port: credPort } = credentials;+ const port = credPort ?? F5_BIG_IP_DEFAULT_PORT;++ if (gatewayId && gatewayV2Service) {+ await blockLocalAndPrivateIpAddresses(`https://${hostname}`, true);++ const platformConnectionDetails = await gatewayV2Service.getPlatformConnectionDetailsByGatewayId({+ gatewayId,+ targetHost: hostname,+ targetPort: port+ });++ if (!platformConnectionDetails) {+ throw new BadRequestError({ message: "Unable to connect to gateway, no platform connection details found" });+ }++ return withGatewayV2Proxy(+ async (proxyPort) => {+ const httpsAgent = new https.Agent({+ servername: hostname,+ rejectUnauthorized: credentials.sslRejectUnauthorized,+ ca: credentials.sslCertificate ? [credentials.sslCertificate] : undefined+ });++ const proxyBaseUrl = `https://localhost:${proxyPort}`;+ const targetBaseUrl = `https://${hostname}:${port}`;++ const makeRequest = async <R>(requestCfg: AxiosRequestConfig): Promise<R> => {+ const resp = await request.request<R>({+ ...requestCfg,+ url: requestCfg.url?.replace(targetBaseUrl, proxyBaseUrl),+ headers: {+ ...requestCfg.headers,+ Host: hostname+ },+ httpsAgent+ });+ return resp.data;+ };++ return operation(makeRequest);+ },+ {+ protocol: GatewayProxyProtocol.Tcp,+ relayHost: platformConnectionDetails.relayHost,+ gateway: platformConnectionDetails.gateway,+ relay: platformConnectionDetails.relay+ }+ );+ }++ await blockLocalAndPrivateIpAddresses(`https://${hostname}`, false);++ const httpsAgent = createF5BigIpHttpsAgent(credentials);++ const makeRequest = async <R>(requestCfg: AxiosRequestConfig): Promise<R> => {+ const resp = await request.request<R>({+ ...requestCfg,+ httpsAgent+ });+ return resp.data;+ };++ return operation(makeRequest);+};diff --git a/backend/src/services/app-connection/f5-big-ip/f5-big-ip-connection-schemas.ts b/backend/src/services/app-connection/f5-big-ip/f5-big-ip-connection-schemas.tsnew file mode 100644index 0000000000..14d3ac47e0--- /dev/null+++ b/backend/src/services/app-connection/f5-big-ip/f5-big-ip-connection-schemas.ts@@ -0,0 +1,89 @@+import z from "zod";++import { AppConnections } from "@app/lib/api-docs";+import { AppConnection } from "@app/services/app-connection/app-connection-enums";+import {+ BaseAppConnectionSchema,+ GenericCreateAppConnectionFieldsSchema,+ GenericUpdateAppConnectionFieldsSchema+} from "@app/services/app-connection/app-connection-schemas";++import { APP_CONNECTION_NAME_MAP } from "../app-connection-maps";+import { F5BigIpConnectionMethod } from "./f5-big-ip-connection-enums";++export const F5BigIpConnectionBasicAuthCredentialsSchema = z.object({+ hostname: z+ .string()+ .trim()+ .min(1, "Hostname is required")+ .max(512, "Hostname cannot exceed 512 characters")+ .refine((val) => !val.includes("/") && !val.includes("@") && !val.includes("?"), {+ message: "Hostname must not contain /, @, or ? characters"+ }),+ port: z.number().int().min(1).max(65535).optional(),+ username: z.string().trim().min(1, "Username is required").max(256, "Username cannot exceed 256 characters"),+ password: z.string().trim().min(1, "Password is required").max(512, "Password cannot exceed 512 characters"),+ sslRejectUnauthorized: z.boolean().optional(),+ sslCertificate: z+ .string()+ .trim()+ .transform((value) => value || undefined)+ .optional()+});++const BaseF5BigIpConnectionSchema = BaseAppConnectionSchema.extend({ app: z.literal(AppConnection.F5BigIp) });++export const F5BigIpConnectionSchema = BaseF5BigIpConnectionSchema.extend({+ method: z.literal(F5BigIpConnectionMethod.BasicAuth),+ credentials: F5BigIpConnectionBasicAuthCredentialsSchema+});++export const SanitizedF5BigIpConnectionSchema = z.discriminatedUnion("method", [+ BaseF5BigIpConnectionSchema.extend({+ method: z.literal(F5BigIpConnectionMethod.BasicAuth),+ credentials: F5BigIpConnectionBasicAuthCredentialsSchema.pick({+ hostname: true,+ port: true,+ username: true,+ sslRejectUnauthorized: true,+ sslCertificate: true+ })+ }).describe(JSON.stringify({ title: `${APP_CONNECTION_NAME_MAP[AppConnection.F5BigIp]} (Basic Auth)` }))+]);++export const ValidateF5BigIpConnectionCredentialsSchema = z.discriminatedUnion("method", [+ z.object({+ method: z+ .literal(F5BigIpConnectionMethod.BasicAuth)+ .describe(AppConnections.CREATE(AppConnection.F5BigIp).method),+ credentials: F5BigIpConnectionBasicAuthCredentialsSchema.describe(+ AppConnections.CREATE(AppConnection.F5BigIp).credentials+ )+ })+]);++export const CreateF5BigIpConnectionSchema = ValidateF5BigIpConnectionCredentialsSchema.and(+ GenericCreateAppConnectionFieldsSchema(AppConnection.F5BigIp, {+ supportsGateways: true+ })+);++export const UpdateF5BigIpConnectionSchema = z+ .object({+ credentials: F5BigIpConnectionBasicAuthCredentialsSchema.optional().describe(+ AppConnections.UPDATE(AppConnection.F5BigIp).credentials+ )+ })+ .and(+ GenericUpdateAppConnectionFieldsSchema(AppConnection.F5BigIp, {+ supportsGateways: true+ })+ );++export const F5BigIpConnectionListItemSchema = z+ .object({+ name: z.literal("F5 BIG-IP"),+ app: z.literal(AppConnection.F5BigIp),+ methods: z.nativeEnum(F5BigIpConnectionMethod).array()+ })+ .describe(JSON.stringify({ title: APP_CONNECTION_NAME_MAP[AppConnection.F5BigIp] }));diff --git a/backend/src/services/app-connection/f5-big-ip/f5-big-ip-connection-types.ts b/backend/src/services/app-connection/f5-big-ip/f5-big-ip-connection-types.tsnew file mode 100644index 0000000000..f86acbbcee--- /dev/null+++ b/backend/src/services/app-connection/f5-big-ip/f5-big-ip-connection-types.ts@@ -0,0 +1,25 @@+import z from "zod";++import { DiscriminativePick } from "@app/lib/types";++import { AppConnection } from "../app-connection-enums";+import {+ CreateF5BigIpConnectionSchema,+ F5BigIpConnectionSchema,+ ValidateF5BigIpConnectionCredentialsSchema+} from "./f5-big-ip-connection-schemas";++export type TF5BigIpConnection = z.infer<typeof F5BigIpConnectionSchema>;++export type TF5BigIpConnectionInput = z.infer<typeof CreateF5BigIpConnectionSchema> & {+ app: AppConnection.F5BigIp;+};++export type TValidateF5BigIpConnectionCredentialsSchema = typeof ValidateF5BigIpConnectionCredentialsSchema;++export type TF5BigIpConnectionConfig = DiscriminativePick<+ TF5BigIpConnectionInput,+ "method" | "app" | "credentials" | "gatewayId" | "gatewayPoolId"+> & {+ orgId: string;+};diff --git a/backend/src/services/app-connection/f5-big-ip/index.ts b/backend/src/services/app-connection/f5-big-ip/index.tsnew file mode 100644index 0000000000..153d616cc2--- /dev/null+++ b/backend/src/services/app-connection/f5-big-ip/index.ts@@ -0,0 +1,15 @@+export { F5BigIpConnectionMethod } from "./f5-big-ip-connection-enums";+export { getF5BigIpConnectionListItem, validateF5BigIpConnectionCredentials } from "./f5-big-ip-connection-fns";+export {+ CreateF5BigIpConnectionSchema,+ F5BigIpConnectionListItemSchema,+ SanitizedF5BigIpConnectionSchema,+ UpdateF5BigIpConnectionSchema,+ ValidateF5BigIpConnectionCredentialsSchema+} from "./f5-big-ip-connection-schemas";+export type {+ TF5BigIpConnection,+ TF5BigIpConnectionConfig,+ TF5BigIpConnectionInput,+ TValidateF5BigIpConnectionCredentialsSchema+} from "./f5-big-ip-connection-types";diff --git a/backend/src/services/pki-sync/f5-big-ip/f5-big-ip-pki-sync-constants.ts b/backend/src/services/pki-sync/f5-big-ip/f5-big-ip-pki-sync-constants.tsnew file mode 100644index 0000000000..e49d43f8b2--- /dev/null+++ b/backend/src/services/pki-sync/f5-big-ip/f5-big-ip-pki-sync-constants.ts@@ -0,0 +1,38 @@+import RE2 from "re2";++import { AppConnection } from "@app/services/app-connection/app-connection-enums";+import { PkiSync } from "@app/services/pki-sync/pki-sync-enums";++export enum F5BigIpProfileType {+ None = "none",+ ClientSsl = "client-ssl",+ ServerSsl = "server-ssl"+}++/**+ * F5 BIG-IP certificate naming constraints.+ * F5 BIG-IP TMOS object names accept alphanumeric characters, hyphens, underscores, and periods.+ * Names are limited to 255 characters and may not contain spaces or shell-sensitive characters.+ */+export const F5_BIG_IP_NAMING = {+ NAME_PATTERN: new RE2("^[a-zA-Z0-9._-]{1,255}$"),+ FORBIDDEN_CHARACTERS: "!@#$%^&*()+=[]{}|\\:;\"'<>,?/~` ",+ MAX_NAME_LENGTH: 255,+ MIN_NAME_LENGTH: 1,+ ALLOWED_CHARACTER_PATTERN: "^[a-zA-Z0-9._-]{1,255}$"+} as const;++export const F5_BIG_IP_DEFAULT_PARTITION = "Common";++export const F5_BIG_IP_PKI_SYNC_LIST_OPTION = {+ name: "F5 BIG-IP" as const,+ connection: AppConnection.F5BigIp,+ destination: PkiSync.F5BigIp,+ canImportCertificates: false,+ canRemoveCertificates: true,+ defaultCertificateNameSchema: "Infisical-{{certificateId}}",+ forbiddenCharacters: F5_BIG_IP_NAMING.FORBIDDEN_CHARACTERS,+ allowedCharacterPattern: F5_BIG_IP_NAMING.ALLOWED_CHARACTER_PATTERN,+ maxCertificateNameLength: F5_BIG_IP_NAMING.MAX_NAME_LENGTH,+ minCertificateNameLength: F5_BIG_IP_NAMING.MIN_NAME_LENGTH+} as const;diff --git a/backend/src/services/pki-sync/f5-big-ip/f5-big-ip-pki-sync-fns.ts b/backend/src/services/pki-sync/f5-big-ip/f5-big-ip-pki-sync-fns.tsnew file mode 100644index 0000000000..469187004f--- /dev/null+++ b/backend/src/services/pki-sync/f5-big-ip/f5-big-ip-pki-sync-fns.ts@@ -0,0 +1,1160 @@+/* eslint-disable no-await-in-loop */+import { AxiosError, AxiosRequestConfig } from "axios";+import handlebars from "handlebars";+import RE2 from "re2";++import { TCertificateSyncs } from "@app/db/schemas";+import { TGatewayPoolServiceFactory } from "@app/ee/services/gateway-pool/gateway-pool-service";+import { TGatewayV2ServiceFactory } from "@app/ee/services/gateway-v2/gateway-v2-service";+import { logger } from "@app/lib/logger";+import {+ executeF5BigIpOperationWithGateway,+ F5_BIG_IP_DEFAULT_PORT,+ F5_BIG_IP_LOGIN_PROVIDER+} from "@app/services/app-connection/f5-big-ip/f5-big-ip-connection-fns";+import { TF5BigIpConnection } from "@app/services/app-connection/f5-big-ip/f5-big-ip-connection-types";+import { TCertificateDALFactory } from "@app/services/certificate/certificate-dal";+import { TCertificateSyncDALFactory } from "@app/services/certificate-sync/certificate-sync-dal";+import { CertificateSyncStatus } from "@app/services/certificate-sync/certificate-sync-enums";+import { TCertificateMap } from "@app/services/pki-sync/pki-sync-types";++import { PkiSyncError } from "../pki-sync-errors";+import { TPkiSyncWithCredentials } from "../pki-sync-types";+import { F5_BIG_IP_DEFAULT_PARTITION, F5BigIpProfileType } from "./f5-big-ip-pki-sync-constants";+import { TF5BigIpPkiSyncConfig } from "./f5-big-ip-pki-sync-types";++type TF5BigIpCredentials = TF5BigIpConnection["credentials"];++type TRequestFn = <R>(requestCfg: AxiosRequestConfig) => Promise<R>;++type TF5BigIpSession = {+ baseUrl: string;+ authToken: string;+ headers: Record<string, string>;+ makeRequest: TRequestFn;+};++type TF5BigIpPkiSyncFactoryDeps = {+ certificateSyncDAL: Pick<+ TCertificateSyncDALFactory,+ | "removeCertificates"+ | "addCertificates"+ | "findByPkiSyncAndCertificate"+ | "updateById"+ | "findByPkiSyncId"+ | "updateSyncStatus"+ >;+ certificateDAL: Pick<TCertificateDALFactory, "findById">;+ gatewayV2Service?: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">;+ gatewayPoolService?: Pick<TGatewayPoolServiceFactory, "resolveEffectiveGatewayId">;+};++/**+ * A Client SSL profile entry. The fields below are the ones F5 documents on the+ * `cert-key-chain` array of `ltm profile client-ssl`. Note: `crl` is NOT a valid+ * per-entry property; F5's CRL config lives on the profile itself (`crlFile`).+ */+type TCertKeyChainEntry = {+ name?: string;+ cert?: string;+ key?: string;+ chain?: string;+ serverName?: string;+ passphrase?: string;+ ocsp?: string;+};++const PRESERVED_CERT_KEY_CHAIN_FIELDS = ["serverName", "ocsp"] as const;++type TServerSslProfileBinding = {+ cert?: string;+ key?: string;+ chain?: string;+};++const F5_DEFAULT_CLIENT_SSL_PARENT = "/Common/clientssl";+const F5_DEFAULT_SERVER_SSL_PARENT = "/Common/serverssl";++const F5_BIG_IP_DEFAULT_CERT_NAME_PREFIX = "Infisical-";+const F5_BIG_IP_CHAIN_SUFFIX = "-chain";++const certFileName = (name: string) => `${name}.crt`;+const keyFileName = (name: string) => `${name}.key`;++const chainObjectName = (certName: string) => `${certName}${F5_BIG_IP_CHAIN_SUFFIX}`;++const buildPartitionedPath = (partition: string, name: string) => `/${partition}/${name}`;++const buildEncodedObjectId = (partition: string, name: string) => encodeURIComponent(`~${partition}~${name}`);++const escapeRegex = (s: string) => s.replace(new RE2("[\\\\^$.*+?()\\[\\]{}|/]", "g"), "\\$&");++const buildManagedCertNamePattern = (certificateNameSchema: string | undefined): RE2 => {+ if (!certificateNameSchema) {+ return new RE2(`^${F5_BIG_IP_DEFAULT_CERT_NAME_PREFIX}[0-9a-f]{32}(-[a-zA-Z0-9]*)?$`);+ }++ const CERT_ID_TOKEN = "__INFISICAL_CERT_ID_PLACEHOLDER__";+ const ENV_TOKEN = "__INFISICAL_ENV_PLACEHOLDER__";++ const tokenized = certificateNameSchema+ .replace(new RE2("\\{\\{certificateId\\}\\}", "g"), CERT_ID_TOKEN)+ .replace(new RE2("\\{\\{environment\\}\\}", "g"), ENV_TOKEN);++ const pattern = escapeRegex(tokenized)+ .replace(new RE2(CERT_ID_TOKEN, "g"), "[0-9a-f]{32}")+ .replace(new RE2(ENV_TOKEN, "g"), "global");++ return new RE2(`^${pattern}$`);+};++const resolveParentProfile = (profileType: F5BigIpProfileType, parentProfile?: string): string => {+ if (parentProfile) {+ return parentProfile.startsWith("/") ? parentProfile : `/Common/${parentProfile}`;+ }+ return profileType === F5BigIpProfileType.ServerSsl ? F5_DEFAULT_SERVER_SSL_PARENT : F5_DEFAULT_CLIENT_SSL_PARENT;+};++const getF5BigIpCredentials = (pkiSync: TPkiSyncWithCredentials): TF5BigIpCredentials => {+ const credentials = pkiSync.connection.credentials as TF5BigIpCredentials;+ if (!credentials?.hostname || !credentials?.username || !credentials?.password) {+ throw new PkiSyncError({+ message: "F5 BIG-IP credentials (hostname, username, password) not found in connection credentials"+ });+ }+ return credentials;+};++const F5_BIG_IP_MAX_TOKEN_TIMEOUT_SECONDS = 36000;++const createF5BigIpSession = async (+ credentials: TF5BigIpCredentials,+ makeRequest: TRequestFn+): Promise<TF5BigIpSession> => {+ const { hostname, port, username, password } = credentials;++ const baseUrl = `https://${hostname}:${port ?? F5_BIG_IP_DEFAULT_PORT}`;++ const loginData = await makeRequest<{ token?: { token?: string } }>({+ method: "POST",+ url: `${baseUrl}/mgmt/shared/authn/login`,+ data: {+ username,+ password,+ loginProviderName: F5_BIG_IP_LOGIN_PROVIDER+ },+ headers: { "Content-Type": "application/json" }+ });++ const authToken = loginData?.token?.token;+ if (!authToken) {+ throw new PkiSyncError({+ message: "Failed to login to F5 BIG-IP: no auth token returned",+ shouldRetry: true+ });+ }++ const sessionHeaders = {+ "Content-Type": "application/json",+ "X-F5-Auth-Token": authToken+ };++ try {+ await makeRequest({+ method: "PATCH",+ url: `${baseUrl}/mgmt/shared/authz/tokens/${encodeURIComponent(authToken)}`,+ data: { timeout: F5_BIG_IP_MAX_TOKEN_TIMEOUT_SECONDS },+ headers: sessionHeaders+ });+ } catch (error: unknown) {+ logger.warn(+ { error },+ `F5 BIG-IP session: unable to extend auth token TTL for ${hostname} — falling back to default lifetime`+ );+ }++ return {+ baseUrl,+ authToken,+ headers: sessionHeaders,+ makeRequest+ };+};++const logoutF5BigIpSession = async (session: TF5BigIpSession): Promise<void> => {+ try {+ await session.makeRequest({+ method: "DELETE",+ url: `${session.baseUrl}/mgmt/shared/authz/tokens/${encodeURIComponent(session.authToken)}`,+ headers: session.headers+ });+ } catch {+ // Ignore logout errors+ }+};++const saveF5BigIpConfig = async (session: TF5BigIpSession): Promise<void> => {+ await session.makeRequest({+ method: "POST",+ url: `${session.baseUrl}/mgmt/tm/sys/config`,+ data: { command: "save" },+ headers: session.headers+ });+};++const F5_BIG_IP_UPLOAD_CHUNK_SIZE_BYTES = 512 * 1024;++const uploadFileToF5BigIp = async (session: TF5BigIpSession, filename: string, fileContent: string): Promise<void> => {+ const buffer = Buffer.from(fileContent, "utf-8");+ const size = buffer.length;++ if (size === 0) {+ throw new PkiSyncError({+ message: `Failed to upload "${filename}" to F5 BIG-IP: file is empty`+ });+ }++ const uploadUrl = `${session.baseUrl}/mgmt/shared/file-transfer/uploads/${encodeURIComponent(filename)}`;++ let start = 0;+ while (start < size) {+ const end = Math.min(start + F5_BIG_IP_UPLOAD_CHUNK_SIZE_BYTES, size);+ const chunk = buffer.subarray(start, end);++ await session.makeRequest({+ method: "POST",+ url: uploadUrl,+ data: chunk,+ headers: {+ ...session.headers,+ "Content-Type": "application/octet-stream",+ "Content-Length": String(chunk.length),+ "Content-Range": `${start}-${end - 1}/${size}`+ }+ });++ start = end;+ }+};++const installSslCertObject = async (+ session: TF5BigIpSession,+ partition: string,+ name: string,+ uploadedFilename: string+): Promise<void> => {+ const sourcePath = `file:/var/config/rest/downloads/${uploadedFilename}`;+ const objectId = buildEncodedObjectId(partition, name);++ try {+ // Try to update an existing ssl-cert object first+ await session.makeRequest({+ method: "PATCH",+ url: `${session.baseUrl}/mgmt/tm/sys/file/ssl-cert/${objectId}`,+ data: { sourcePath },+ headers: session.headers+ });+ } catch (error: unknown) {+ if (error instanceof AxiosError && error.response?.status === 404) {+ await session.makeRequest({+ method: "POST",+ url: `${session.baseUrl}/mgmt/tm/sys/file/ssl-cert`,+ data: { name, partition, sourcePath },+ headers: session.headers+ });+ return;+ }+ throw error;+ }+};++const installSslKeyObject = async (+ session: TF5BigIpSession,+ partition: string,+ name: string,+ uploadedFilename: string+): Promise<void> => {+ const sourcePath = `file:/var/config/rest/downloads/${uploadedFilename}`;+ const objectId = buildEncodedObjectId(partition, name);++ try {+ await session.makeRequest({+ method: "PATCH",+ url: `${session.baseUrl}/mgmt/tm/sys/file/ssl-key/${objectId}`,+ data: { sourcePath },+ headers: session.headers+ });+ } catch (error: unknown) {+ if (error instanceof AxiosError && error.response?.status === 404) {+ await session.makeRequest({+ method: "POST",+ url: `${session.baseUrl}/mgmt/tm/sys/file/ssl-key`,+ data: { name, partition, sourcePath },+ headers: session.headers+ });+ return;+ }+ throw error;+ }+};++const deleteSslCertObject = async (session: TF5BigIpSession, partition: string, name: string): Promise<void> => {+ try {+ await session.makeRequest({+ method: "DELETE",+ url: `${session.baseUrl}/mgmt/tm/sys/file/ssl-cert/${buildEncodedObjectId(partition, name)}`,+ headers: session.headers+ });+ } catch (error: unknown) {+ if (error instanceof AxiosError && error.response?.status === 404) {+ return;+ }+ throw error;+ }+};++const deleteSslKeyObject = async (session: TF5BigIpSession, partition: string, name: string): Promise<void> => {+ try {+ await session.makeRequest({+ method: "DELETE",+ url: `${session.baseUrl}/mgmt/tm/sys/file/ssl-key/${buildEncodedObjectId(partition, name)}`,+ headers: session.headers+ });+ } catch (error: unknown) {+ if (error instanceof AxiosError && error.response?.status === 404) {+ return;+ }+ throw error;+ }+};++const listSslCertNamesByPartition = async (session: TF5BigIpSession, partition: string): Promise<Set<string>> => {+ const certNames = new Set<string>();++ try {+ const data = await session.makeRequest<{+ items?: Array<{ name: string; partition: string }>;+ }>({+ method: "GET",+ url: `${session.baseUrl}/mgmt/tm/sys/file/ssl-cert?$select=name,partition`,+ headers: session.headers+ });++ if (data?.items) {+ for (const item of data.items) {+ if (item.partition === partition) {+ certNames.add(item.name);+ }+ }+ }+ } catch (error: unknown) {+ if (error instanceof AxiosError && error.response?.status === 404) {+ return certNames;+ }+ throw error;+ }++ return certNames;+};++const CLIENT_SSL_PROFILE_ENDPOINT = "/mgmt/tm/ltm/profile/client-ssl";+const SERVER_SSL_PROFILE_ENDPOINT = "/mgmt/tm/ltm/profile/server-ssl";++const F5_NONE_REFERENCE = "none";++const bindCertToClientSslProfile = async (+ session: TF5BigIpSession,+ partition: string,+ profileName: string,+ certName: string,+ keyName: string,+ chainName: string | null,+ options: { createIfMissing?: boolean; parentProfile?: string } = {}+): Promise<void> => {+ const profileObjectId = buildEncodedObjectId(partition, profileName);+ const certPath = buildPartitionedPath(partition, certName);+ const keyPath = buildPartitionedPath(partition, keyName);+ const chainPath = chainName ? buildPartitionedPath(partition, chainName) : null;++ let existingChain: TCertKeyChainEntry[] = [];+ let profileExists = true;+ try {+ const profile = await session.makeRequest<{ certKeyChain?: TCertKeyChainEntry[] }>({+ method: "GET",+ url: `${session.baseUrl}${CLIENT_SSL_PROFILE_ENDPOINT}/${profileObjectId}`,+ headers: session.headers+ });+ if (profile?.certKeyChain && Array.isArray(profile.certKeyChain)) {+ existingChain = profile.certKeyChain;+ }+ } catch (error: unknown) {+ if (error instanceof AxiosError && error.response?.status === 404) {+ profileExists = false;+ } else {+ throw error;+ }+ }++ const existingEntry = existingChain.find((entry) => entry.name === certName || entry.cert === certPath);++ const preservedFields: Partial<TCertKeyChainEntry> = {};+ if (existingEntry) {+ for (const field of PRESERVED_CERT_KEY_CHAIN_FIELDS) {+ if (existingEntry[field] !== undefined) {+ preservedFields[field] = existingEntry[field];+ }+ }+ }++ const updatedEntry: TCertKeyChainEntry = {+ ...preservedFields,+ name: certName,+ cert: certPath,+ key: keyPath,+ chain: chainPath ?? undefined+ };++ if (!profileExists) {+ if (!options.createIfMissing) {+ throw new PkiSyncError({+ message: `F5 BIG-IP profile "${profileName}" not found in partition "${partition}". Enable "Create profile if missing" or create the profile before binding a certificate.`,+ shouldRetry: false+ });+ }++ await session.makeRequest({+ method: "POST",+ url: `${session.baseUrl}${CLIENT_SSL_PROFILE_ENDPOINT}`,+ data: {+ name: profileName,+ partition,+ defaultsFrom: resolveParentProfile(F5BigIpProfileType.ClientSsl, options.parentProfile),+ inheritCertkeychain: false,+ certKeyChain: [updatedEntry]+ },+ headers: session.headers+ });+ return;+ }++ const otherEntries = existingChain.filter(+ (entry) => entry !== existingEntry && entry.name !== certName && entry.cert !== certPath+ );+ const certKeyChain = [updatedEntry, ...otherEntries];++ await session.makeRequest({+ method: "PATCH",+ url: `${session.baseUrl}${CLIENT_SSL_PROFILE_ENDPOINT}/${profileObjectId}`,+ data: { certKeyChain },+ headers: session.headers+ });+};++const bindCertToServerSslProfile = async (+ session: TF5BigIpSession,+ partition: string,+ profileName: string,+ certName: string,+ keyName: string,+ chainName: string | null,+ options: { createIfMissing?: boolean; parentProfile?: string } = {}+): Promise<void> => {+ const profileObjectId = buildEncodedObjectId(partition, profileName);+ const certPath = buildPartitionedPath(partition, certName);+ const keyPath = buildPartitionedPath(partition, keyName);+ const chainPath = chainName ? buildPartitionedPath(partition, chainName) : null;++ const bindingFields = {+ cert: certPath,+ key: keyPath,+ chain: chainPath ?? F5_NONE_REFERENCE+ };++ let profileExists = true;+ try {+ await session.makeRequest({+ method: "GET",+ url: `${session.baseUrl}${SERVER_SSL_PROFILE_ENDPOINT}/${profileObjectId}`,+ headers: session.headers+ });+ } catch (error: unknown) {+ if (error instanceof AxiosError && error.response?.status === 404) {+ profileExists = false;+ } else {+ throw error;+ }+ }++ if (!profileExists) {+ if (!options.createIfMissing) {+ throw new PkiSyncError({+ message: `F5 BIG-IP profile "${profileName}" not found in partition "${partition}". Enable "Create profile if missing" or create the profile before binding a certificate.`,+ shouldRetry: false+ });+ }++ await session.makeRequest({+ method: "POST",+ url: `${session.baseUrl}${SERVER_SSL_PROFILE_ENDPOINT}`,+ data: {+ name: profileName,+ partition,+ defaultsFrom: resolveParentProfile(F5BigIpProfileType.ServerSsl, options.parentProfile),+ ...bindingFields+ },+ headers: session.headers+ });+ return;+ }++ await session.makeRequest({+ method: "PATCH",+ url: `${session.baseUrl}${SERVER_SSL_PROFILE_ENDPOINT}/${profileObjectId}`,+ data: bindingFields,+ headers: session.headers+ });+};++const bindCertToProfile = async (+ session: TF5BigIpSession,+ partition: string,+ profileType: F5BigIpProfileType,+ profileName: string,+ certName: string,+ keyName: string,+ chainName: string | null,+ options: { createIfMissing?: boolean; parentProfile?: string } = {}+): Promise<void> => {+ if (profileType === F5BigIpProfileType.ClientSsl) {+ await bindCertToClientSslProfile(session, partition, profileName, certName, keyName, chainName, options);+ return;+ }+ if (profileType === F5BigIpProfileType.ServerSsl) {+ await bindCertToServerSslProfile(session, partition, profileName, certName, keyName, chainName, options);+ }+};++const unbindFromClientSslProfile = async (+ session: TF5BigIpSession,+ partition: string,+ profileName: string,+ certPaths: string[]+): Promise<void> => {+ const profileObjectId = buildEncodedObjectId(partition, profileName);+ const pathSet = new Set(certPaths);++ let existingChain: TCertKeyChainEntry[] = [];+ try {+ const profile = await session.makeRequest<{ certKeyChain?: TCertKeyChainEntry[] }>({+ method: "GET",+ url: `${session.baseUrl}${CLIENT_SSL_PROFILE_ENDPOINT}/${profileObjectId}`,+ headers: session.headers+ });+ if (profile?.certKeyChain && Array.isArray(profile.certKeyChain)) {+ existingChain = profile.certKeyChain;+ }+ } catch (error: unknown) {+ if (error instanceof AxiosError && error.response?.status === 404) {+ return;+ }+ throw error;+ }++ const remainingEntries = existingChain.filter(+ (entry) =>+ (entry.cert === undefined || !pathSet.has(entry.cert)) && (entry.chain === undefined || !pathSet.has(entry.chain))+ );++ if (remainingEntries.length === existingChain.length) {+ return;+ }++ await session.makeRequest({+ method: "PATCH",+ url: `${session.baseUrl}${CLIENT_SSL_PROFILE_ENDPOINT}/${profileObjectId}`,+ data: { certKeyChain: remainingEntries },+ headers: session.headers+ });+};++const unbindFromServerSslProfile = async (+ session: TF5BigIpSession,+ partition: string,+ profileName: string+): Promise<void> => {+ await session.makeRequest({+ method: "PATCH",+ url: `${session.baseUrl}${SERVER_SSL_PROFILE_ENDPOINT}/${buildEncodedObjectId(partition, profileName)}`,+ data: { cert: F5_NONE_REFERENCE, key: F5_NONE_REFERENCE, chain: F5_NONE_REFERENCE },+ headers: session.headers+ });+};++const unbindCertPathsFromAllProfiles = async (+ session: TF5BigIpSession,+ partition: string,+ certPaths: string[]+): Promise<void> => {+ if (certPaths.length === 0) return;+ const pathSet = new Set(certPaths);++ try {+ const data = await session.makeRequest<{+ items?: Array<{ name: string; partition: string; certKeyChain?: TCertKeyChainEntry[] }>;+ }>({+ method: "GET",+ url: `${session.baseUrl}${CLIENT_SSL_PROFILE_ENDPOINT}?$select=name,partition,certKeyChain`,+ headers: session.headers+ });++ if (data?.items) {+ for (const profile of data.items) {+ if (profile.partition !== partition) continue;+ const refsCert = profile.certKeyChain?.some(+ (entry) =>+ (entry.cert !== undefined && pathSet.has(entry.cert)) ||+ (entry.chain !== undefined && pathSet.has(entry.chain))+ );+ if (refsCert) {+ await unbindFromClientSslProfile(session, partition, profile.name, certPaths);+ }+ }+ }+ } catch (error: unknown) {+ logger.warn(+ { error },+ `F5 BIG-IP PKI sync: unable to enumerate Client SSL profiles in partition "${partition}" while preparing to unbind certificates`+ );+ }++ try {+ const data = await session.makeRequest<{+ items?: Array<{ name: string; partition: string } & TServerSslProfileBinding>;+ }>({+ method: "GET",+ url: `${session.baseUrl}${SERVER_SSL_PROFILE_ENDPOINT}?$select=name,partition,cert,key,chain`,+ headers: session.headers+ });++ if (data?.items) {+ for (const profile of data.items) {+ if (profile.partition !== partition) continue;+ const refsCert =+ (profile.cert !== undefined && pathSet.has(profile.cert)) ||+ (profile.chain !== undefined && pathSet.has(profile.chain));+ if (refsCert) {+ await unbindFromServerSslProfile(session, partition, profile.name);+ }+ }+ }+ } catch (error: unknown) {+ logger.warn(+ { error },+ `F5 BIG-IP PKI sync: unable to enumerate Server SSL profiles in partition "${partition}" while preparing to unbind certificates`+ );+ }+};++const removeF5BigIpCertificate = async (+ session: TF5BigIpSession,+ certKeyName: string,+ config: TF5BigIpPkiSyncConfig,+ options: { hadChain?: boolean } = {}+): Promise<void> => {+ const partition = config.partition ?? F5_BIG_IP_DEFAULT_PARTITION;+ const certPath = buildPartitionedPath(partition, certKeyName);+ const chainName = options.hadChain ? chainObjectName(certKeyName) : null;+ const chainPath = chainName ? buildPartitionedPath(partition, chainName) : null;++ const pathsToUnbind = chainPath ? [certPath, chainPath] : [certPath];+ await unbindCertPathsFromAllProfiles(session, partition, pathsToUnbind);++ await deleteSslKeyObject(session, partition, certKeyName);+ await deleteSslCertObject(session, partition, certKeyName);++ if (chainName) {+ await deleteSslCertObject(session, partition, chainName);+ }+};++export const f5BigIpPkiSyncFactory = ({+ certificateSyncDAL,+ certificateDAL,+ gatewayV2Service,+ gatewayPoolService+}: TF5BigIpPkiSyncFactoryDeps) => {+ const resolveGateway = async (pkiSync: TPkiSyncWithCredentials) => {+ return gatewayPoolService+ ? gatewayPoolService.resolveEffectiveGatewayId({+ gatewayId: pkiSync.connection.gatewayId,+ gatewayPoolId: pkiSync.connection.gatewayPoolId+ })+ : (pkiSync.connection.gatewayId ?? null);+ };++ const syncCertificates = async (+ pkiSync: TPkiSyncWithCredentials,+ certificateMap: TCertificateMap+ ): Promise<{+ uploaded: number;+ removed?: number;+ failedRemovals?: number;+ skipped: number;+ details?: {+ failedUploads?: Array<{ name: string; error: string }>;+ failedRemovals?: Array<{ name: string; error: string }>;+ skippedCertificates?: Array<{ name: string; reason: string }>;+ };+ }> => {+ const credentials = getF5BigIpCredentials(pkiSync);+ const config = pkiSync.destinationConfig as TF5BigIpPkiSyncConfig;+ const partition = config.partition ?? F5_BIG_IP_DEFAULT_PARTITION;+ const profileType = config.profileType ?? F5BigIpProfileType.None;+ const profileName = config.profileName;+ const syncOptions = pkiSync.syncOptions as+ | { certificateNameSchema?: string; canRemoveCertificates?: boolean; preserveItemOnRenewal?: boolean }+ | undefined;+ const canRemoveCertificates = syncOptions?.canRemoveCertificates ?? true;+ const preserveItemOnRenewal = syncOptions?.preserveItemOnRenewal ?? true;+ const certificateNameSchema = syncOptions?.certificateNameSchema;++ const effectiveGatewayId = await resolveGateway(pkiSync);++ return executeF5BigIpOperationWithGateway(+ { gatewayId: effectiveGatewayId, credentials },+ gatewayV2Service,+ async (makeRequest) => {+ let uploaded = 0;+ let removed = 0;+ const failedUploads: Array<{ name: string; error: string }> = [];+ const failedRemovals: Array<{ name: string; error: string }> = [];+ const skippedCertificates: Array<{ name: string; reason: string }> = [];++ const session = await createF5BigIpSession(credentials, makeRequest);++ try {+ const existingCertNames = await listSslCertNamesByPartition(session, partition);++ const existingSyncRecords = await certificateSyncDAL.findByPkiSyncId(pkiSync.id);+ const syncRecordsByCertId = new Map<string, TCertificateSyncs>();+ existingSyncRecords.forEach((record: TCertificateSyncs) => {+ if (record.certificateId) {+ syncRecordsByCertId.set(record.certificateId, record);+ }+ });++ const activeExternalIdentifiers = new Set<string>();++ if (!preserveItemOnRenewal) {+ for (const syncRecord of existingSyncRecords) {+ if (syncRecord.certificateId && syncRecord.externalIdentifier) {+ const cert = await certificateDAL.findById(syncRecord.certificateId);+ if (cert?.renewedByCertificateId && existingCertNames.has(syncRecord.externalIdentifier)) {+ activeExternalIdentifiers.add(syncRecord.externalIdentifier);+ }+ }+ }+ }++ const certificatesToUpload: Array<{+ targetName: string;+ cert: string;+ privateKey: string;+ certificateChain?: string;+ certificateId?: string;+ isUpdate: boolean;+ oldCertificateIdToRemove?: string;+ }> = [];++ for (const [certName, certData] of Object.entries(certificateMap)) {+ const { cert, privateKey, certificateChain, certificateId } = certData;++ if (!cert || !privateKey) {+ skippedCertificates.push({+ name: certName,+ reason: "Missing certificate or private key data"+ });+ // eslint-disable-next-line no-continue+ continue;+ }++ let certificate: Awaited<ReturnType<typeof certificateDAL.findById>> | undefined;+ if (typeof certificateId === "string") {+ certificate = await certificateDAL.findById(certificateId);+ if (certificate?.renewedByCertificateId) {+ skippedCertificates.push({+ name: certName,+ reason: "Certificate has been renewed and replaced by a newer certificate"+ });+ // eslint-disable-next-line no-continue+ continue;+ }+ }++ let targetName = certName;+ let isUpdate = false;+ let oldCertificateIdToRemove: string | undefined;++ if (typeof certificateId === "string") {+ const syncRecordLookupId = certificate?.renewedFromCertificateId || certificateId;+ const existingSyncRecord = syncRecordsByCertId.get(syncRecordLookupId);++ if (+ certificate?.renewedFromCertificateId &&+ preserveItemOnRenewal &&+ existingSyncRecord?.externalIdentifier+ ) {+ targetName = existingSyncRecord.externalIdentifier;+ isUpdate = true;+ oldCertificateIdToRemove = certificate.renewedFromCertificateId;+ activeExternalIdentifiers.add(targetName);+ } else if (certificate?.renewedFromCertificateId && !preserveItemOnRenewal) {+ const certIdClean = certificateId.replace(new RE2("-", "g"), "");+ if (certificateNameSchema) {+ targetName = handlebars.compile(certificateNameSchema)({+ certificateId: certIdClean,+ environment: "global"+ });+ } else {+ targetName = `${F5_BIG_IP_DEFAULT_CERT_NAME_PREFIX}${certIdClean}`;+ }++ if (existingSyncRecord?.externalIdentifier) {+ activeExternalIdentifiers.add(existingSyncRecord.externalIdentifier);+ }+ } else {+ const directSyncRecord = syncRecordsByCertId.get(certificateId);+ if (+ directSyncRecord?.externalIdentifier &&+ existingCertNames.has(directSyncRecord.externalIdentifier)+ ) {+ targetName = directSyncRecord.externalIdentifier;+ activeExternalIdentifiers.add(targetName);+ isUpdate = true;+ }+ }+ }++ certificatesToUpload.push({+ targetName,+ cert,+ privateKey,+ certificateChain,+ certificateId,+ isUpdate,+ oldCertificateIdToRemove+ });+ }++ for (const {+ targetName,+ cert,+ privateKey,+ certificateChain,+ certificateId,+ isUpdate,+ oldCertificateIdToRemove+ } of certificatesToUpload) {+ try {+ const chainName = certificateChain ? chainObjectName(targetName) : null;++ await uploadFileToF5BigIp(session, certFileName(targetName), cert);+ await uploadFileToF5BigIp(session, keyFileName(targetName), privateKey);+ if (certificateChain && chainName) {+ await uploadFileToF5BigIp(session, certFileName(chainName), certificateChain);+ }++ await installSslCertObject(session, partition, targetName, certFileName(targetName));+ await installSslKeyObject(session, partition, targetName, keyFileName(targetName));+ if (certificateChain && chainName) {+ await installSslCertObject(session, partition, chainName, certFileName(chainName));+ }++ if (profileType !== F5BigIpProfileType.None && profileName) {+ await bindCertToProfile(+ session,+ partition,+ profileType,+ profileName,+ targetName,+ targetName,+ chainName,+ {+ createIfMissing: config.createProfileIfMissing,+ parentProfile: config.parentProfile+ }+ );+ }++ activeExternalIdentifiers.add(targetName);++ if (certificateId) {+ const existingCertSync = await certificateSyncDAL.findByPkiSyncAndCertificate(+ pkiSync.id,+ certificateId+ );++ if (existingCertSync) {+ await certificateSyncDAL.updateById(existingCertSync.id, {+ externalIdentifier: targetName,+ syncStatus: CertificateSyncStatus.Succeeded,+ lastSyncMessage: isUpdate+ ? `Updated certificate on F5 BIG-IP as "${targetName}" in partition "${partition}"`+ : `Synced certificate to F5 BIG-IP as "${targetName}" in partition "${partition}"`,+ lastSyncedAt: new Date()+ });+ } else {+ await certificateSyncDAL.addCertificates(pkiSync.id, [+ {+ certificateId,+ externalIdentifier: targetName+ }+ ]);+ }++ if (oldCertificateIdToRemove) {+ await certificateSyncDAL.removeCertificates(pkiSync.id, [oldCertificateIdToRemove]);+ }+ }++ uploaded += 1;++ logger.info(+ `F5 BIG-IP PKI sync [syncId=${pkiSync.id}]: ${isUpdate ? "updated" : "uploaded"} certificate "${targetName}" on ${credentials.hostname}`+ );+ } catch (error: unknown) {+ let errorMessage = "Unknown error";+ if (error instanceof AxiosError) {+ errorMessage = String((error.response?.data as { message?: string })?.message || error.message);+ } else if (error instanceof Error) {+ errorMessage = error.message;+ }++ failedUploads.push({ name: targetName, error: errorMessage });++ if (certificateId) {+ const syncRecord = await certificateSyncDAL.findByPkiSyncAndCertificate(pkiSync.id, certificateId);++ if (syncRecord) {+ await certificateSyncDAL.updateById(syncRecord.id, {+ syncStatus: CertificateSyncStatus.Failed,+ lastSyncMessage: `Failed to sync to F5 BIG-IP: ${String(errorMessage)}`.slice(0, 4096)+ });+ }+ }++ logger.error(+ { error },+ `F5 BIG-IP PKI sync [syncId=${pkiSync.id}]: failed to upload certificate "${targetName}"`+ );+ }+ }++ if (canRemoveCertificates) {+ const certNamesToRemove = new Set<string>();++ for (const syncRecord of existingSyncRecords) {+ if (+ syncRecord.externalIdentifier &&+ !activeExternalIdentifiers.has(syncRecord.externalIdentifier) &&+ existingCertNames.has(syncRecord.externalIdentifier)+ ) {+ certNamesToRemove.add(syncRecord.externalIdentifier);+ }+ }++ const managedCertNamePattern = buildManagedCertNamePattern(certificateNameSchema);++ for (const certName of existingCertNames) {+ if (+ managedCertNamePattern.test(certName) &&+ !activeExternalIdentifiers.has(certName) &&+ !certName.endsWith(F5_BIG_IP_CHAIN_SUFFIX)+ ) {+ certNamesToRemove.add(certName);+ }+ }++ const chainNamesToRemove = new Set<string>();+ for (const certName of existingCertNames) {+ if (!certName.endsWith(F5_BIG_IP_CHAIN_SUFFIX)) continue;+ const leafName = certName.slice(0, -F5_BIG_IP_CHAIN_SUFFIX.length);+ if (existingCertNames.has(leafName)) continue;+ if (activeExternalIdentifiers.has(certName)) continue;+ if (!managedCertNamePattern.test(certName) && !managedCertNamePattern.test(leafName)) continue;+ chainNamesToRemove.add(certName);+ }++ for (const certName of certNamesToRemove) {+ try {+ const hadChain = existingCertNames.has(chainObjectName(certName));+ await removeF5BigIpCertificate(session, certName, config, { hadChain });++ removed += 1;++ logger.info(+ `F5 BIG-IP PKI sync [syncId=${pkiSync.id}]: removed orphaned certificate "${certName}" from ${credentials.hostname}`+ );+ } catch (error: unknown) {+ let errorMessage = "Unknown error";+ if (error instanceof AxiosError) {+ errorMessage = String((error.response?.data as { message?: string })?.message || error.message);+ } else if (error instanceof Error) {+ errorMessage = error.message;+ }+ failedRemovals.push({ name: certName, error: errorMessage });++ logger.error(+ { error },+ `F5 BIG-IP PKI sync [syncId=${pkiSync.id}]: failed to remove certificate "${certName}" — ${errorMessage}`+ );+ }+ }++ for (const chainName of chainNamesToRemove) {+ try {+ await unbindCertPathsFromAllProfiles(session, partition, [+ buildPartitionedPath(partition, chainName)+ ]);+ await deleteSslCertObject(session, partition, chainName);++ removed += 1;++ logger.info(+ `F5 BIG-IP PKI sync [syncId=${pkiSync.id}]: removed orphaned chain "${chainName}" from ${credentials.hostname}`+ );+ } catch (error: unknown) {+ let errorMessage = "Unknown error";+ if (error instanceof AxiosError) {+ errorMessage = String((error.response?.data as { message?: string })?.message || error.message);+ } else if (error instanceof Error) {+ errorMessage = error.message;+ }+ failedRemovals.push({ name: chainName, error: errorMessage });++ logger.error(+ { error },+ `F5 BIG-IP PKI sync [syncId=${pkiSync.id}]: failed to remove orphaned chain "${chainName}" — ${errorMessage}`+ );+ }+ }+ }++ await saveF5BigIpConfig(session);+ } finally {+ await logoutF5BigIpSession(session);+ }++ return {+ uploaded,+ removed: removed > 0 ? removed : undefined,+ failedRemovals: failedRemovals.length > 0 ? failedRemovals.length : undefined,+ skipped: skippedCertificates.length,+ details: {+ failedUploads: failedUploads.length > 0 ? failedUploads : undefined,+ failedRemovals: failedRemovals.length > 0 ? failedRemovals : undefined,+ skippedCertificates: skippedCertificates.length > 0 ? skippedCertificates : undefined+ }+ };+ }+ );+ };++ const removeCertificates = async (+ pkiSync: TPkiSyncWithCredentials,+ certificateNames: string[],+ deps?: {+ certificateSyncDAL?: Pick<TCertificateSyncDALFactory, "findByPkiSyncId">;+ certificateMap?: TCertificateMap;+ }+ ): Promise<void> => {+ if (certificateNames.length === 0) return;++ const credentials = getF5BigIpCredentials(pkiSync);+ const config = pkiSync.destinationConfig as TF5BigIpPkiSyncConfig;+ const partition = config.partition ?? F5_BIG_IP_DEFAULT_PARTITION;++ const existingSyncRecords = await certificateSyncDAL.findByPkiSyncId(pkiSync.id);+ const certNamesToRemove: string[] = [];+ const certificateIdsToClean: string[] = [];++ for (const certName of certificateNames) {+ if (deps?.certificateMap?.[certName]?.certificateId) {+ const { certificateId } = deps.certificateMap[certName];++ const syncRecord = existingSyncRecords.find((record) => record.certificateId === certificateId);++ if (syncRecord?.externalIdentifier && typeof certificateId === "string") {+ certNamesToRemove.push(syncRecord.externalIdentifier);+ certificateIdsToClean.push(certificateId);+ }+ }+ }++ if (certNamesToRemove.length === 0) {+ return;+ }++ const effectiveGatewayId = await resolveGateway(pkiSync);++ await executeF5BigIpOperationWithGateway(+ { gatewayId: effectiveGatewayId, credentials },+ gatewayV2Service,+ async (makeRequest) => {+ const session = await createF5BigIpSession(credentials, makeRequest);++ try {+ const existingCertNames = await listSslCertNamesByPartition(session, partition);++ for (const certName of certNamesToRemove) {+ try {+ const hadChain = existingCertNames.has(chainObjectName(certName));+ await removeF5BigIpCertificate(session, certName, config, { hadChain });++ logger.info(+ `F5 BIG-IP PKI sync [syncId=${pkiSync.id}]: removed certificate "${certName}" from ${credentials.hostname}`+ );+ } catch (error: unknown) {+ if (error instanceof AxiosError && error.response?.status === 404) {+ logger.info(+ `F5 BIG-IP PKI sync [syncId=${pkiSync.id}]: certificate "${certName}" already removed from ${credentials.hostname}`+ );+ // eslint-disable-next-line no-continue+ continue;+ }++ let errorMessage = "Unknown error";+ if (error instanceof AxiosError) {+ errorMessage = String((error.response?.data as { message?: string })?.message || error.message);+ } else if (error instanceof Error) {+ errorMessage = error.message;+ }++ logger.error(+ { error },+ `F5 BIG-IP PKI sync [syncId=${pkiSync.id}]: failed to remove certificate "${certName}" — ${errorMessage}`+ );+ throw new PkiSyncError({+ message: `Failed to remove certificate "${certName}" from F5 BIG-IP: ${errorMessage}`,+ shouldRetry: true+ });+ }+ }++ await saveF5BigIpConfig(session);+ } finally {+ await logoutF5BigIpSession(session);+ }+ }+ );++ if (certificateIdsToClean.length > 0) {+ await certificateSyncDAL.removeCertificates(pkiSync.id, certificateIdsToClean);+ }+ };++ return {+ syncCertificates,+ removeCertificates+ };+};diff --git a/backend/src/services/pki-sync/f5-big-ip/f5-big-ip-pki-sync-schemas.ts b/backend/src/services/pki-sync/f5-big-ip/f5-big-ip-pki-sync-schemas.tsnew file mode 100644index 0000000000..ab2f1770a5--- /dev/null+++ b/backend/src/services/pki-sync/f5-big-ip/f5-big-ip-pki-sync-schemas.ts@@ -0,0 +1,130 @@+import RE2 from "re2";+import { z } from "zod";++import { openApiHidden } from "@app/server/lib/schemas";+import { AppConnection } from "@app/services/app-connection/app-connection-enums";+import { PkiSync } from "@app/services/pki-sync/pki-sync-enums";+import { PkiSyncSchema } from "@app/services/pki-sync/pki-sync-schemas";++import { F5_BIG_IP_NAMING, F5BigIpProfileType } from "./f5-big-ip-pki-sync-constants";++const hasProfileBinding = (profileType: F5BigIpProfileType | undefined) =>+ profileType !== undefined && profileType !== F5BigIpProfileType.None;++export const F5BigIpPkiSyncConfigSchema = z+ .object({+ partition: z+ .string()+ .trim()+ .min(1, "Partition cannot be empty")+ .max(255, "Partition cannot exceed 255 characters")+ .regex(+ F5_BIG_IP_NAMING.NAME_PATTERN,+ "Partition must contain only alphanumeric characters, hyphens, underscores, and periods"+ )+ .optional(),+ profileType: z.nativeEnum(F5BigIpProfileType).optional(),+ profileName: z+ .string()+ .trim()+ .min(1, "Profile name cannot be empty")+ .max(255, "Profile name cannot exceed 255 characters")+ .regex(+ F5_BIG_IP_NAMING.NAME_PATTERN,+ "Profile name must contain only alphanumeric characters, hyphens, underscores, and periods"+ )+ .optional(),+ createProfileIfMissing: z.boolean().optional(),+ parentProfile: z+ .string()+ .trim()+ .min(1, "Parent profile cannot be empty")+ .max(511, "Parent profile cannot exceed 511 characters")+ .optional()+ })+ .refine((value) => !hasProfileBinding(value.profileType) || Boolean(value.profileName), {+ message: "Profile name is required when a profile type is selected",+ path: ["profileName"]+ })+ .refine((value) => hasProfileBinding(value.profileType) || !value.createProfileIfMissing, {+ message:+ "Auto-create profile can only be enabled when binding to a Client SSL or Server SSL profile",+ path: ["createProfileIfMissing"]+ })+ .refine((value) => hasProfileBinding(value.profileType) || !value.parentProfile, {+ message: "Parent profile can only be set when binding to a Client SSL or Server SSL profile",+ path: ["parentProfile"]+ })+ .refine((value) => Boolean(value.createProfileIfMissing) || !value.parentProfile, {+ message: "Parent profile can only be set when 'Create profile if missing' is enabled",+ path: ["parentProfile"]+ });++export const F5BigIpPkiSyncOptionsSchema = z.object({+ canRemoveCertificates: z.boolean().default(true),+ includeRootCa: z.boolean().default(false),+ preserveItemOnRenewal: z.boolean().default(true),+ certificateNameSchema: z+ .string()+ .optional()+ .refine(+ (schema) => {+ if (!schema) return true;++ if (!schema.includes("{{certificateId}}")) {+ return false;+ }++ const testName = schema+ .replace(new RE2("\\{\\{certificateId\\}\\}", "g"), "test-cert-id")+ .replace(new RE2("\\{\\{environment\\}\\}", "g"), "test-env");++ const hasForbiddenChars = F5_BIG_IP_NAMING.FORBIDDEN_CHARACTERS.split("").some((char) =>+ testName.includes(char)+ );++ return F5_BIG_IP_NAMING.NAME_PATTERN.test(testName) && !hasForbiddenChars;+ },+ {+ message:+ "Certificate name schema must include the {{certificateId}} placeholder and result in names that contain only alphanumeric characters, hyphens (-), underscores (_), and periods (.) and be 1-255 characters long for F5 BIG-IP"+ }+ )+});++export const F5BigIpPkiSyncSchema = PkiSyncSchema.extend({+ destination: z.literal(PkiSync.F5BigIp),+ destinationConfig: F5BigIpPkiSyncConfigSchema,+ syncOptions: F5BigIpPkiSyncOptionsSchema+});++export const CreateF5BigIpPkiSyncSchema = z.object({+ name: z.string().trim().min(1).max(256),+ description: z.string().optional(),+ isAutoSyncEnabled: z.boolean().default(true),+ destinationConfig: F5BigIpPkiSyncConfigSchema,+ syncOptions: F5BigIpPkiSyncOptionsSchema.optional().default({}),+ subscriberId: z.string().nullish(),+ connectionId: z.string(),+ projectId: z.string().trim().min(1).optional().describe(openApiHidden()),+ applicationId: z.string().uuid().optional(),+ certificateIds: z.array(z.string().uuid()).optional()+});++export const UpdateF5BigIpPkiSyncSchema = z.object({+ name: z.string().trim().min(1).max(256).optional(),+ description: z.string().optional(),+ isAutoSyncEnabled: z.boolean().optional(),+ destinationConfig: F5BigIpPkiSyncConfigSchema.optional(),+ syncOptions: F5BigIpPkiSyncOptionsSchema.optional(),+ subscriberId: z.string().nullish(),+ connectionId: z.string().optional()+});++export const F5BigIpPkiSyncListItemSchema = z.object({+ name: z.literal("F5 BIG-IP"),+ connection: z.literal(AppConnection.F5BigIp),+ destination: z.literal(PkiSync.F5BigIp),+ canImportCertificates: z.literal(false),+ canRemoveCertificates: z.literal(true)+});diff --git a/backend/src/services/pki-sync/f5-big-ip/f5-big-ip-pki-sync-types.ts b/backend/src/services/pki-sync/f5-big-ip/f5-big-ip-pki-sync-types.tsnew file mode 100644index 0000000000..c905a5d4ea--- /dev/null+++ b/backend/src/services/pki-sync/f5-big-ip/f5-big-ip-pki-sync-types.ts@@ -0,0 +1,22 @@+import { z } from "zod";++import { TF5BigIpConnection } from "@app/services/app-connection/f5-big-ip/f5-big-ip-connection-types";++import {+ CreateF5BigIpPkiSyncSchema,+ F5BigIpPkiSyncConfigSchema,+ F5BigIpPkiSyncSchema,+ UpdateF5BigIpPkiSyncSchema+} from "./f5-big-ip-pki-sync-schemas";++export type TF5BigIpPkiSyncConfig = z.infer<typeof F5BigIpPkiSyncConfigSchema>;++export type TF5BigIpPkiSync = z.infer<typeof F5BigIpPkiSyncSchema>;++export type TF5BigIpPkiSyncInput = z.infer<typeof CreateF5BigIpPkiSyncSchema>;++export type TF5BigIpPkiSyncUpdate = z.infer<typeof UpdateF5BigIpPkiSyncSchema>;++export type TF5BigIpPkiSyncWithCredentials = TF5BigIpPkiSync & {+ connection: TF5BigIpConnection;+};diff --git a/backend/src/services/pki-sync/f5-big-ip/index.ts b/backend/src/services/pki-sync/f5-big-ip/index.tsnew file mode 100644index 0000000000..dbda9023df--- /dev/null+++ b/backend/src/services/pki-sync/f5-big-ip/index.ts@@ -0,0 +1,4 @@+export * from "./f5-big-ip-pki-sync-constants";+export * from "./f5-big-ip-pki-sync-fns";+export * from "./f5-big-ip-pki-sync-schemas";+export * from "./f5-big-ip-pki-sync-types";diff --git a/backend/src/services/pki-sync/pki-sync-enums.ts b/backend/src/services/pki-sync/pki-sync-enums.tsindex 1d5e9b23f9..3f1c25d332 100644--- a/backend/src/services/pki-sync/pki-sync-enums.ts+++ b/backend/src/services/pki-sync/pki-sync-enums.ts@@ -5,7 +5,8 @@ export enum PkiSync {AwsElasticLoadBalancer = "aws-elastic-load-balancer",Chef = "chef",CloudflareCustomCertificate = "cloudflare-custom-certificate",- NetScaler = "netscaler"+ NetScaler = "netscaler",+ F5BigIp = "f5-big-ip"}export enum PkiSyncStatus {diff --git a/backend/src/services/pki-sync/pki-sync-fns.ts b/backend/src/services/pki-sync/pki-sync-fns.tsindex e527197227..2895865108 100644--- a/backend/src/services/pki-sync/pki-sync-fns.ts+++ b/backend/src/services/pki-sync/pki-sync-fns.ts@@ -22,6 +22,8 @@ import { chefPkiSyncFactory } from "./chef/chef-pki-sync-fns";import { CHEF_PKI_SYNC_LIST_OPTION } from "./chef/chef-pki-sync-list-constants";import { CLOUDFLARE_CUSTOM_CERTIFICATE_PKI_SYNC_LIST_OPTION } from "./cloudflare-custom-certificate/cloudflare-custom-certificate-pki-sync-constants";import { cloudflareCustomCertificatePkiSyncFactory } from "./cloudflare-custom-certificate/cloudflare-custom-certificate-pki-sync-fns";+import { F5_BIG_IP_PKI_SYNC_LIST_OPTION } from "./f5-big-ip/f5-big-ip-pki-sync-constants";+import { f5BigIpPkiSyncFactory } from "./f5-big-ip/f5-big-ip-pki-sync-fns";import { NETSCALER_PKI_SYNC_LIST_OPTION } from "./netscaler/netscaler-pki-sync-constants";import { netScalerPkiSyncFactory } from "./netscaler/netscaler-pki-sync-fns";import { PkiSync } from "./pki-sync-enums";@@ -36,7 +38,8 @@ const PKI_SYNC_LIST_OPTIONS = {[PkiSync.AwsElasticLoadBalancer]: AWS_ELASTIC_LOAD_BALANCER_PKI_SYNC_LIST_OPTION,[PkiSync.Chef]: CHEF_PKI_SYNC_LIST_OPTION,[PkiSync.CloudflareCustomCertificate]: CLOUDFLARE_CUSTOM_CERTIFICATE_PKI_SYNC_LIST_OPTION,- [PkiSync.NetScaler]: NETSCALER_PKI_SYNC_LIST_OPTION+ [PkiSync.NetScaler]: NETSCALER_PKI_SYNC_LIST_OPTION,+ [PkiSync.F5BigIp]: F5_BIG_IP_PKI_SYNC_LIST_OPTION};export const enterprisePkiSyncCheck = async (@@ -217,6 +220,9 @@ export const PkiSyncFns = {"NetScaler does not support importing certificates into Infisical (private keys cannot be extracted)");}+ case PkiSync.F5BigIp: {+ throw new Error("F5 BIG-IP does not support importing certificates into Infisical");+ }default:throw new Error(`Unsupported PKI sync destination: ${String(pkiSync.destination)}`);}@@ -310,6 +316,16 @@ export const PkiSyncFns = {});return netScalerPkiSync.syncCertificates(pkiSync, certificateMap);}+ case PkiSync.F5BigIp: {+ checkPkiSyncDestination(pkiSync, PkiSync.F5BigIp as PkiSync);+ const f5BigIpPkiSync = f5BigIpPkiSyncFactory({+ certificateDAL: dependencies.certificateDAL,+ certificateSyncDAL: dependencies.certificateSyncDAL,+ gatewayV2Service: dependencies.gatewayV2Service,+ gatewayPoolService: dependencies.gatewayPoolService+ });+ return f5BigIpPkiSync.syncCertificates(pkiSync, certificateMap);+ }default:throw new Error(`Unsupported PKI sync destination: ${String(pkiSync.destination)}`);}@@ -418,6 +434,20 @@ export const PkiSyncFns = {});break;}+ case PkiSync.F5BigIp: {+ checkPkiSyncDestination(pkiSync, PkiSync.F5BigIp as PkiSync);+ const f5BigIpPkiSync = f5BigIpPkiSyncFactory({+ certificateDAL: dependencies.certificateDAL,+ certificateSyncDAL: dependencies.certificateSyncDAL,+ gatewayV2Service: dependencies.gatewayV2Service,+ gatewayPoolService: dependencies.gatewayPoolService+ });+ await f5BigIpPkiSync.removeCertificates(pkiSync, certificateNames, {+ certificateSyncDAL: dependencies.certificateSyncDAL,+ certificateMap: dependencies.certificateMap+ });+ break;+ }default:throw new Error(`Unsupported PKI sync destination: ${String(pkiSync.destination)}`);}diff --git a/backend/src/services/pki-sync/pki-sync-maps.ts b/backend/src/services/pki-sync/pki-sync-maps.tsindex f7150b8a6c..d822b2553f 100644--- a/backend/src/services/pki-sync/pki-sync-maps.ts+++ b/backend/src/services/pki-sync/pki-sync-maps.ts@@ -9,7 +9,8 @@ export const PKI_SYNC_NAME_MAP: Record<PkiSync, string> = {[PkiSync.AwsElasticLoadBalancer]: "AWS Elastic Load Balancer",[PkiSync.Chef]: "Chef",[PkiSync.CloudflareCustomCertificate]: "Cloudflare Custom SSL Certificate",- [PkiSync.NetScaler]: "NetScaler"+ [PkiSync.NetScaler]: "NetScaler",+ [PkiSync.F5BigIp]: "F5 BIG-IP"};export const PKI_SYNC_CONNECTION_MAP: Record<PkiSync, AppConnection> = {@@ -19,5 +20,6 @@ export const PKI_SYNC_CONNECTION_MAP: Record<PkiSync, AppConnection> = {[PkiSync.AwsElasticLoadBalancer]: AppConnection.AWS,[PkiSync.Chef]: AppConnection.Chef,[PkiSync.CloudflareCustomCertificate]: AppConnection.Cloudflare,- [PkiSync.NetScaler]: AppConnection.NetScaler+ [PkiSync.NetScaler]: AppConnection.NetScaler,+ [PkiSync.F5BigIp]: AppConnection.F5BigIp};diff --git a/docs/api-reference/endpoints/app-connections/f5-big-ip/available.mdx b/docs/api-reference/endpoints/app-connections/f5-big-ip/available.mdxnew file mode 100644index 0000000000..cb5446a90a--- /dev/null+++ b/docs/api-reference/endpoints/app-connections/f5-big-ip/available.mdx@@ -0,0 +1,4 @@+---+title: "Available"+openapi: "GET /api/v1/app-connections/f5-big-ip/available"+---diff --git a/docs/api-reference/endpoints/app-connections/f5-big-ip/create.mdx b/docs/api-reference/endpoints/app-connections/f5-big-ip/create.mdxnew file mode 100644index 0000000000..689440c7ba--- /dev/null+++ b/docs/api-reference/endpoints/app-connections/f5-big-ip/create.mdx@@ -0,0 +1,10 @@+---+title: "Create"+openapi: "POST /api/v1/app-connections/f5-big-ip"+---++<Note>+ Check out the configuration docs for [F5 BIG-IP+ Connections](/integrations/app-connections/f5-big-ip) to learn how to obtain the+ required credentials.+</Note>diff --git a/docs/api-reference/endpoints/app-connections/f5-big-ip/delete.mdx b/docs/api-reference/endpoints/app-connections/f5-big-ip/delete.mdxnew file mode 100644index 0000000000..2dd20bc46a--- /dev/null+++ b/docs/api-reference/endpoints/app-connections/f5-big-ip/delete.mdx@@ -0,0 +1,4 @@+---+title: "Delete"+openapi: "DELETE /api/v1/app-connections/f5-big-ip/{connectionId}"+---diff --git a/docs/api-reference/endpoints/app-connections/f5-big-ip/get-by-id.mdx b/docs/api-reference/endpoints/app-connections/f5-big-ip/get-by-id.mdxnew file mode 100644index 0000000000..4dd2e15ca1--- /dev/null+++ b/docs/api-reference/endpoints/app-connections/f5-big-ip/get-by-id.mdx@@ -0,0 +1,4 @@+---+title: "Get by ID"+openapi: "GET /api/v1/app-connections/f5-big-ip/{connectionId}"+---diff --git a/docs/api-reference/endpoints/app-connections/f5-big-ip/get-by-name.mdx b/docs/api-reference/endpoints/app-connections/f5-big-ip/get-by-name.mdxnew file mode 100644index 0000000000..40edfe32b6--- /dev/null+++ b/docs/api-reference/endpoints/app-connections/f5-big-ip/get-by-name.mdx@@ -0,0 +1,4 @@+---+title: "Get by Name"+openapi: "GET /api/v1/app-connections/f5-big-ip/connection-name/{connectionName}"+---diff --git a/docs/api-reference/endpoints/app-connections/f5-big-ip/list.mdx b/docs/api-reference/endpoints/app-connections/f5-big-ip/list.mdxnew file mode 100644index 0000000000..43039d81a6--- /dev/null+++ b/docs/api-reference/endpoints/app-connections/f5-big-ip/list.mdx@@ -0,0 +1,4 @@+---+title: "List"+openapi: "GET /api/v1/app-connections/f5-big-ip"+---diff --git a/docs/api-reference/endpoints/app-connections/f5-big-ip/update.mdx b/docs/api-reference/endpoints/app-connections/f5-big-ip/update.mdxnew file mode 100644index 0000000000..873b640d87--- /dev/null+++ b/docs/api-reference/endpoints/app-connections/f5-big-ip/update.mdx@@ -0,0 +1,10 @@+---+title: "Update"+openapi: "PATCH /api/v1/app-connections/f5-big-ip/{connectionId}"+---++<Note>+ Check out the configuration docs for [F5 BIG-IP+ Connections](/integrations/app-connections/f5-big-ip) to learn how to obtain the+ required credentials.+</Note>diff --git a/docs/api-reference/endpoints/pki/syncs/f5-big-ip/create.mdx b/docs/api-reference/endpoints/pki/syncs/f5-big-ip/create.mdxnew file mode 100644index 0000000000..0d61d579f8--- /dev/null+++ b/docs/api-reference/endpoints/pki/syncs/f5-big-ip/create.mdx@@ -0,0 +1,4 @@+---+title: "Create F5 BIG-IP PKI Sync"+openapi: "POST /api/v1/cert-manager/syncs/f5-big-ip"+---diff --git a/docs/api-reference/endpoints/pki/syncs/f5-big-ip/delete.mdx b/docs/api-reference/endpoints/pki/syncs/f5-big-ip/delete.mdxnew file mode 100644index 0000000000..fe0220ca80--- /dev/null+++ b/docs/api-reference/endpoints/pki/syncs/f5-big-ip/delete.mdx@@ -0,0 +1,4 @@+---+title: "Delete F5 BIG-IP PKI Sync"+openapi: "DELETE /api/v1/cert-manager/syncs/f5-big-ip/{pkiSyncId}"+---diff --git a/docs/api-reference/endpoints/pki/syncs/f5-big-ip/get-by-id.mdx b/docs/api-reference/endpoints/pki/syncs/f5-big-ip/get-by-id.mdxnew file mode 100644index 0000000000..9eef0820ea--- /dev/null+++ b/docs/api-reference/endpoints/pki/syncs/f5-big-ip/get-by-id.mdx@@ -0,0 +1,4 @@+---+title: "Get F5 BIG-IP PKI Sync by ID"+openapi: "GET /api/v1/cert-manager/syncs/f5-big-ip/{pkiSyncId}"+---diff --git a/docs/api-reference/endpoints/pki/syncs/f5-big-ip/list.mdx b/docs/api-reference/endpoints/pki/syncs/f5-big-ip/list.mdxnew file mode 100644index 0000000000..793c2c32b6--- /dev/null+++ b/docs/api-reference/endpoints/pki/syncs/f5-big-ip/list.mdx@@ -0,0 +1,4 @@+---+title: "List F5 BIG-IP PKI Syncs"+openapi: "GET /api/v1/cert-manager/syncs/f5-big-ip"+---diff --git a/docs/api-reference/endpoints/pki/syncs/f5-big-ip/remove-certificates.mdx b/docs/api-reference/endpoints/pki/syncs/f5-big-ip/remove-certificates.mdxnew file mode 100644index 0000000000..476e994f5f--- /dev/null+++ b/docs/api-reference/endpoints/pki/syncs/f5-big-ip/remove-certificates.mdx@@ -0,0 +1,4 @@+---+title: "Remove Certificates from F5 BIG-IP"+openapi: "POST /api/v1/cert-manager/syncs/f5-big-ip/{pkiSyncId}/remove-certificates"+---diff --git a/docs/api-reference/endpoints/pki/syncs/f5-big-ip/sync-certificates.mdx b/docs/api-reference/endpoints/pki/syncs/f5-big-ip/sync-certificates.mdxnew file mode 100644index 0000000000..289f7c17a3--- /dev/null+++ b/docs/api-reference/endpoints/pki/syncs/f5-big-ip/sync-certificates.mdx@@ -0,0 +1,4 @@+---+title: "Sync Certificates to F5 BIG-IP"+openapi: "POST /api/v1/cert-manager/syncs/f5-big-ip/{pkiSyncId}/sync"+---diff --git a/docs/api-reference/endpoints/pki/syncs/f5-big-ip/update.mdx b/docs/api-reference/endpoints/pki/syncs/f5-big-ip/update.mdxnew file mode 100644index 0000000000..66a473eee3--- /dev/null+++ b/docs/api-reference/endpoints/pki/syncs/f5-big-ip/update.mdx@@ -0,0 +1,4 @@+---+title: "Update F5 BIG-IP PKI Sync"+openapi: "PATCH /api/v1/cert-manager/syncs/f5-big-ip/{pkiSyncId}"+---diff --git a/docs/docs.json b/docs/docs.jsonindex 46d332a5e3..9a72869548 100644--- a/docs/docs.json+++ b/docs/docs.json@@ -130,6 +130,7 @@"integrations/app-connections/digital-ocean","integrations/app-connections/doppler","integrations/app-connections/dns-made-easy",+ "integrations/app-connections/f5-big-ip","integrations/app-connections/flyio","integrations/app-connections/gcp","integrations/app-connections/github",@@ -830,6 +831,7 @@"documentation/platform/pki/applications/certificate-syncs/azure-key-vault","documentation/platform/pki/applications/certificate-syncs/chef","documentation/platform/pki/applications/certificate-syncs/cloudflare-custom-certificate",+ "documentation/platform/pki/applications/certificate-syncs/f5-big-ip","documentation/platform/pki/applications/certificate-syncs/netscaler"]}@@ -1571,6 +1573,18 @@"api-reference/endpoints/app-connections/doppler/delete"]},+ {+ "group": "F5 BIG-IP",+ "pages": [+ "api-reference/endpoints/app-connections/f5-big-ip/list",+ "api-reference/endpoints/app-connections/f5-big-ip/available",+ "api-reference/endpoints/app-connections/f5-big-ip/get-by-id",+ "api-reference/endpoints/app-connections/f5-big-ip/get-by-name",+ "api-reference/endpoints/app-connections/f5-big-ip/create",+ "api-reference/endpoints/app-connections/f5-big-ip/update",+ "api-reference/endpoints/app-connections/f5-big-ip/delete"+ ]+ },{"group": "Fly.io","pages": [@@ -3175,6 +3189,18 @@"api-reference/endpoints/pki/syncs/cloudflare-custom-certificate/remove-certificates"]},+ {+ "group": "F5 BIG-IP",+ "pages": [+ "api-reference/endpoints/pki/syncs/f5-big-ip/list",+ "api-reference/endpoints/pki/syncs/f5-big-ip/get-by-id",+ "api-reference/endpoints/pki/syncs/f5-big-ip/create",+ "api-reference/endpoints/pki/syncs/f5-big-ip/update",+ "api-reference/endpoints/pki/syncs/f5-big-ip/delete",+ "api-reference/endpoints/pki/syncs/f5-big-ip/sync-certificates",+ "api-reference/endpoints/pki/syncs/f5-big-ip/remove-certificates"+ ]+ },{"group": "NetScaler","pages": [diff --git a/docs/documentation/platform/pki/applications/certificate-syncs/f5-big-ip.mdx b/docs/documentation/platform/pki/applications/certificate-syncs/f5-big-ip.mdxnew file mode 100644index 0000000000..5535540dc7--- /dev/null+++ b/docs/documentation/platform/pki/applications/certificate-syncs/f5-big-ip.mdx@@ -0,0 +1,203 @@+---+title: "F5 BIG-IP"+sidebarTitle: "F5 BIG-IP"+description: "Deploy certificates to F5 BIG-IP appliances."+---++Deploy certificates to F5 BIG-IP appliances. Certificates can be automatically attached to Client SSL or Server SSL profiles, so the BIG-IP starts serving them right after each sync.++<Info>+ Certificate Syncs are configured per Application. First select which certificates to sync, then configure the F5 BIG-IP destination.+</Info>++## Prerequisites++- An [F5 BIG-IP Connection](/integrations/app-connections/f5-big-ip) with access to your BIG-IP appliance+- The BIG-IP must be reachable over HTTPS from Infisical (directly or via an [Infisical Gateway](/documentation/platform/gateways/overview))+- User account with permissions to manage certificates in the target partition, and to update SSL profiles when profile binding is used++## Create an F5 BIG-IP Sync++<Tabs>+ <Tab title="Infisical UI">+ 1. In your Application, go to the **Certificate Syncs** tab and click **Create Sync**.++ 2. Select the **F5 BIG-IP** option.++ 3. Configure the **Destination**:+ - **F5 BIG-IP Connection**: The F5 BIG-IP Connection to authenticate with.+ - **Partition** (Optional): The F5 partition where certificates will be stored. Defaults to `Common`.+ - **Profile Binding** (Optional): Attach each certificate to a Client SSL or Server SSL profile so the BIG-IP starts using it right away. Choose **None** to just upload certificates without attaching them.+ - **Profile Name** (Conditional): Required when **Profile Binding** is set. The name of the SSL profile inside the partition.+ - **Create profile if missing** (Optional): Create the SSL profile on the BIG-IP if it doesn't exist yet.+ - **Parent Profile** (Optional): The existing F5 profile to copy settings from when creating the new one. Defaults to `/Common/clientssl` (Client SSL) or `/Common/serverssl` (Server SSL).++ 4. Configure the **Sync Options**:+ - **Enable Removal of Expired/Revoked Certificates**: Remove certificates from the BIG-IP when they're no longer active in Infisical.+ - **Include Root CA in Certificate Chain**: Include the root CA in the chain uploaded to the BIG-IP. Most setups don't need the root, since clients already trust it.+ - **Preserve Certificate on Renewal**: When on, renewed certificates keep the same name on the BIG-IP, so any profile or virtual server using them keeps working without changes. When off, the renewed certificate is uploaded with a new name and the original stays on the BIG-IP.+ - **Certificate Name Schema** (Optional): Customize the name used on the BIG-IP. Must include `{{certificateId}}`. Defaults to `Infisical-{{certificateId}}`. The certificate chain follows the same name with `-chain` added.+ - **Auto-Sync Enabled**: Automatically sync certificates when changes occur (including auto-renewals).++ 5. Configure the **Details**:+ - **Name**: The name of your sync.+ - **Description**: Optional description.++ 6. Select which certificates should be synced.++ 7. Review and click **Create Sync**.+ </Tab>+ <Tab title="API">+ To create an **F5 BIG-IP Certificate Sync**, make an API request to the [Create F5 BIG-IP PKI Sync](/api-reference/endpoints/pki/syncs/f5-big-ip/create) endpoint.++ ### Sample request++ <Note>+ You can optionally specify `certificateIds` during sync creation to immediately add certificates to the sync.+ If not provided, you can add certificates later using the certificate management endpoints.+ </Note>++ ```bash Request+ curl --request POST \+ --url https://app.infisical.com/api/v1/cert-manager/syncs/f5-big-ip \+ --header 'Authorization: Bearer <access-token>' \+ --header 'Content-Type: application/json' \+ --data '{+ "name": "my-f5-big-ip-cert-sync",+ "applicationId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",+ "description": "an example certificate sync",+ "connectionId": "550e8400-e29b-41d4-a716-446655440000",+ "destination": "f5-big-ip",+ "isAutoSyncEnabled": true,+ "certificateIds": [+ "550e8400-e29b-41d4-a716-446655440000"+ ],+ "syncOptions": {+ "canRemoveCertificates": true,+ "includeRootCa": false,+ "preserveItemOnRenewal": true,+ "certificateNameSchema": "myapp-{{certificateId}}"+ },+ "destinationConfig": {+ "partition": "Common",+ "profileType": "client-ssl",+ "profileName": "clientssl-prod",+ "createProfileIfMissing": true,+ "parentProfile": "/Common/clientssl"+ }+ }'+ ```++ ### Sample response++ ```json Response+ {+ "pkiSync": {+ "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",+ "name": "my-f5-big-ip-cert-sync",+ "description": "an example certificate sync",+ "destination": "f5-big-ip",+ "isAutoSyncEnabled": true,+ "destinationConfig": {+ "partition": "Common",+ "profileType": "client-ssl",+ "profileName": "clientssl-prod",+ "createProfileIfMissing": true,+ "parentProfile": "/Common/clientssl"+ },+ "syncOptions": {+ "canRemoveCertificates": true,+ "includeRootCa": false,+ "preserveItemOnRenewal": true,+ "certificateNameSchema": "myapp-{{certificateId}}"+ },+ "applicationId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",+ "connectionId": "550e8400-e29b-41d4-a716-446655440000",+ "createdAt": "2026-05-01T00:00:00.000Z",+ "updatedAt": "2026-05-01T00:00:00.000Z"+ }+ }+ ```+ </Tab>+</Tabs>++## Certificate Management++The F5 BIG-IP Certificate Sync provides:++- **Automatic Deployment**: Deploy certificates from Infisical PKI to the BIG-IP.+- **In-Place Renewals**: Renewed certificates keep the same name on the BIG-IP, so any profile or virtual server using them keeps working without changes.+- **Profile Binding**: Attach each certificate to a Client SSL or Server SSL profile. Each certificate gets its own slot on the profile.+- **Profile Auto-Creation**: Create the SSL profile on first sync if it doesn't exist yet.+- **Expiration Handling**: Remove expired or revoked certificates from the BIG-IP when they're no longer active in Infisical.+- **Configuration Persistence**: Automatically save the running configuration after each sync, so changes survive reboots.++<Note>+ F5 BIG-IP Certificate Syncs support both automatic and manual synchronization+ modes. When auto-sync is enabled, certificates are automatically deployed as+ they're issued or renewed.+</Note>++## Certificate Renewal Behavior++When a certificate is renewed in Infisical, the behavior depends on the **Preserve Certificate on Renewal** option:++- **Preserve enabled**: The renewed certificate keeps the same name on the BIG-IP. Any profile or virtual server already using that certificate keeps working without any change.+- **Preserve disabled**: The renewed certificate is uploaded with a new name and the original stays on the BIG-IP. Both certificates coexist until the original is revoked or removed.++## Manual Certificate Sync++You can manually trigger a sync to F5 BIG-IP. This is useful for:++- Initial setup when you have existing certificates to deploy+- One-time sync of specific certificates+- Testing certificate sync configurations+- Force sync after making changes++To manually sync, use the [Sync Certificates](/api-reference/endpoints/pki/syncs/f5-big-ip/sync-certificates) API endpoint or the manual sync option in the Infisical UI.++## FAQ++<Accordion title="Does the SSL profile have to exist on the BIG-IP already?">+ By default, yes. Either create the profile on the BIG-IP first, or turn on+ **Create profile if missing** and Infisical will create it for you using the+ **Parent Profile** as the template.+</Accordion>++<Accordion title="Can I attach more than one certificate to the same SSL profile?">+ **Client SSL profiles**: F5 only accepts one certificate per algorithm type+ on a profile. So a single Client SSL profile can hold at most one RSA, one+ ECDSA, and one DSA certificate at a time. Trying to attach a second RSA+ certificate to the same profile will fail. If you+ need multiple certificates of the same type (for example two RSA+ certificates for different hostnames), put each one on a separate Client SSL+ profile and attach the profiles to your virtual server.++ **Server SSL profiles**: only one certificate at a time. Adding a second+ certificate replaces the first one on the profile.+</Accordion>++<Accordion title="Will Infisical overwrite other certificates already attached to the profile?">+ On Client SSL profiles, no, as long as the new and existing certificates are+ different algorithm types (RSA / ECDSA / DSA). Each type gets its own slot,+ and certificates added by other tools or by hand stay untouched. On Server+ SSL profiles, the profile holds a single certificate, so syncing a new one+ replaces what was there.+</Accordion>++## What's Next?++<CardGroup cols={2}>+ <Card title="NetScaler" icon="server" href="/documentation/platform/pki/applications/certificate-syncs/netscaler">+ Deploy certificates to Citrix NetScaler ADC appliances.+ </Card>+ <Card title="Auto-Renewal" icon="arrows-spin" href="/documentation/platform/pki/applications/certificates#server-driven-renewal">+ Enable automatic certificate renewal and syncing.+ </Card>+ <Card title="Alerting" icon="bell" href="/documentation/platform/pki/applications/alerting/overview">+ Get notified about certificate lifecycle events.+ </Card>+ <Card title="Other Sync Destinations" icon="arrows-rotate" href="/documentation/platform/pki/applications/certificate-syncs/overview">+ View all supported sync destinations.+ </Card>+</CardGroup>diff --git a/docs/integrations/app-connections/f5-big-ip.mdx b/docs/integrations/app-connections/f5-big-ip.mdxnew file mode 100644index 0000000000..31acc46b6c--- /dev/null+++ b/docs/integrations/app-connections/f5-big-ip.mdx@@ -0,0 +1,101 @@+---+title: "F5 BIG-IP Connection"+description: "Learn how to configure an F5 BIG-IP Connection for Infisical."+---++Infisical supports connecting to F5 BIG-IP LTM appliances via the iControl REST API for managing SSL certificates and binding them to Client SSL or Server SSL profiles.++## Setup++<Tabs>+ <Tab title="Infisical UI">+ <Steps>+ <Step title="Gather F5 BIG-IP Credentials">+ You will need the following from your F5 BIG-IP appliance:++ - **Hostname**: The management IP address or FQDN of your BIG-IP appliance (e.g. `10.10.10.10` or `bigip.example.com`).+ - **Port**: The HTTPS management port (default: `443`).+ - **Username**: A user with administrative access to manage SSL certificates and profiles.+ - **Password**: The password for the user account.++ <Note>+ The user account must be assigned a role with permissions to:+ - Upload files via the iControl REST file-transfer endpoint.+ - Create, update, and delete `sys file ssl-cert` and `sys file ssl-key` objects.+ - Update `ltm profile client-ssl` or `ltm profile server-ssl` objects (only required if profile binding is used).+ - Save the running configuration.++ The built-in **Certificate Manager** role meets these requirements when paired with the relevant administrative partition. For broader scopes, **Resource Administrator** or **Administrator** can be used.+ </Note>+ </Step>+ <Step title="Navigate to App Connections">+ In the Infisical dashboard, navigate to **Organization Settings** > **App Connections** and click **Add Connection**.+ </Step>+ <Step title="Select F5 BIG-IP">+ Select the **F5 BIG-IP** option from the list of available connections.+ </Step>+ <Step title="Fill in Connection Details">+ Fill in the **Configuration** tab:++ - **Hostname**: The management IP or FQDN of the BIG-IP appliance.+ - **Username**: The BIG-IP management username.+ - **Password**: The password for the management user.+ - **Port** (Optional): HTTPS port for the management interface (default: `443`).++ Configure the **SSL** tab:++ - **SSL Certificate** (Optional): A CA certificate in PEM format to verify the BIG-IP management interface's TLS certificate.+ - **Reject Unauthorized**: When enabled, Infisical will only connect if the BIG-IP has a valid, trusted TLS certificate. Disable for self-signed certificates or provide a CA certificate.++ Optionally select a **Gateway** to route the connection through an [Infisical Gateway](/documentation/platform/gateways/overview) when the BIG-IP is hosted in an air-gapped or private network.++ Click **Connect to F5 BIG-IP** to validate and save your connection.+ </Step>+ <Step title="Connection Created">+ Your F5 BIG-IP Connection is now available for use with certificate syncs.+ </Step>+ </Steps>+ </Tab>+ <Tab title="API">+ To create an F5 BIG-IP Connection, make an API request to the [Create App Connection](/api-reference/endpoints/app-connections/f5-big-ip/create) endpoint.++ ### Sample request++ ```bash Request+ curl --request POST \+ --url https://app.infisical.com/api/v1/app-connections/f5-big-ip \+ --header 'Authorization: Bearer <access-token>' \+ --header 'Content-Type: application/json' \+ --data '{+ "name": "my-f5-big-ip-connection",+ "method": "basic-auth",+ "credentials": {+ "hostname": "bigip.example.com",+ "port": 443,+ "username": "admin",+ "password": "your-password",+ "sslRejectUnauthorized": false+ }+ }'+ ```++ ### Sample response++ ```json Response+ {+ "appConnection": {+ "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",+ "name": "my-f5-big-ip-connection",+ "app": "f5-big-ip",+ "method": "basic-auth",+ "credentials": {+ "hostname": "bigip.example.com",+ "port": 443,+ "username": "admin",+ "sslRejectUnauthorized": false+ }+ }+ }+ ```+ </Tab>+</Tabs>diff --git a/frontend/public/images/integrations/F5 BIG-IP.png b/frontend/public/images/integrations/F5 BIG-IP.pngnew file mode 100644index 0000000000..1e7a2fd2adBinary files /dev/null and b/frontend/public/images/integrations/F5 BIG-IP.png differdiff --git a/frontend/src/components/pki-syncs/forms/F5BigIpPkiSyncFields.tsx b/frontend/src/components/pki-syncs/forms/F5BigIpPkiSyncFields.tsxnew file mode 100644index 0000000000..061641d6fe--- /dev/null+++ b/frontend/src/components/pki-syncs/forms/F5BigIpPkiSyncFields.tsx@@ -0,0 +1,150 @@+import { Controller, useFormContext } from "react-hook-form";+import { faQuestionCircle } from "@fortawesome/free-solid-svg-icons";+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";++import { FormControl, Input, Select, SelectItem, Switch, Tooltip } from "@app/components/v2";+import { PkiSync } from "@app/hooks/api/pkiSyncs";+import { F5BigIpProfileType } from "@app/hooks/api/pkiSyncs/types/f5-big-ip-sync";++import { TPkiSyncForm } from "./schemas/pki-sync-schema";+import { PkiSyncConnectionField } from "./PkiSyncConnectionField";++const PROFILE_TYPE_OPTIONS: { value: F5BigIpProfileType; label: string }[] = [+ { value: F5BigIpProfileType.None, label: "None" },+ { value: F5BigIpProfileType.ClientSsl, label: "Client SSL Profile" },+ { value: F5BigIpProfileType.ServerSsl, label: "Server SSL Profile" }+];++export const F5BigIpPkiSyncFields = () => {+ const { control, watch } = useFormContext<TPkiSyncForm & { destination: PkiSync.F5BigIp }>();+ const profileType = watch("destinationConfig.profileType");+ const createProfileIfMissing = watch("destinationConfig.createProfileIfMissing");+ const requiresProfile = profileType !== undefined && profileType !== F5BigIpProfileType.None;++ return (+ <>+ <PkiSyncConnectionField />+ <Controller+ name="destinationConfig.partition"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl+ isError={Boolean(error)}+ errorText={error?.message}+ label="Partition"+ isOptional+ tooltipText="The F5 partition where certificates will be stored. Defaults to Common."+ >+ <Input value={value ?? ""} onChange={onChange} placeholder="Common" />+ </FormControl>+ )}+ />+ <Controller+ name="destinationConfig.profileType"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl+ isError={Boolean(error)}+ errorText={error?.message}+ label="Profile Binding"+ tooltipText="Attach each synced certificate to a Client SSL or Server SSL profile so the BIG-IP starts using it right away. F5 only allows one certificate per algorithm type (RSA, ECDSA, DSA) per profile, so use separate profiles if you have multiple certificates of the same type. Choose None to just upload certificates without attaching them."+ >+ <Select+ value={value ?? F5BigIpProfileType.None}+ onValueChange={(v) => onChange(v as F5BigIpProfileType)}+ className="w-full border border-mineshaft-500"+ dropdownContainerClassName="max-w-none"+ position="popper"+ >+ {PROFILE_TYPE_OPTIONS.map((option) => (+ <SelectItem value={option.value} key={option.value}>+ {option.label}+ </SelectItem>+ ))}+ </Select>+ </FormControl>+ )}+ />+ {requiresProfile && (+ <>+ <Controller+ name="destinationConfig.profileName"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl+ isError={Boolean(error)}+ errorText={error?.message}+ label={+ profileType === F5BigIpProfileType.ServerSsl+ ? "Server SSL Profile Name"+ : "Client SSL Profile Name"+ }+ tooltipText="The name of the SSL profile inside the partition. Infisical will add each synced certificate to it."+ >+ <Input+ value={value ?? ""}+ onChange={onChange}+ placeholder={+ profileType === F5BigIpProfileType.ServerSsl+ ? "e.g. backend-ssl"+ : "e.g. clientssl-prod"+ }+ />+ </FormControl>+ )}+ />+ <Controller+ name="destinationConfig.createProfileIfMissing"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl isError={Boolean(error)} errorText={error?.message}>+ <Switch+ className="bg-mineshaft-400/80 shadow-inner data-[state=checked]:bg-green/80"+ id="f5-create-profile-if-missing"+ thumbClassName="bg-mineshaft-800"+ isChecked={value ?? false}+ onCheckedChange={onChange}+ >+ <p>+ Create profile if missing{" "}+ <Tooltip+ className="max-w-md"+ content="Create the SSL profile on the BIG-IP if it doesn't exist yet. Off by default, since production profiles are usually managed by F5 administrators."+ >+ <FontAwesomeIcon icon={faQuestionCircle} size="sm" className="ml-1" />+ </Tooltip>+ </p>+ </Switch>+ </FormControl>+ )}+ />+ {createProfileIfMissing && (+ <Controller+ name="destinationConfig.parentProfile"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl+ isError={Boolean(error)}+ errorText={error?.message}+ label="Parent Profile"+ isOptional+ tooltipText={`The existing F5 profile we'll copy settings from when creating the new one. Defaults to /Common/${profileType === F5BigIpProfileType.ServerSsl ? "serverssl" : "clientssl"}. Enter just a name (looked up in /Common) or a full path like /MyPartition/my-parent.`}+ >+ <Input+ value={value ?? ""}+ onChange={onChange}+ placeholder={+ profileType === F5BigIpProfileType.ServerSsl+ ? "/Common/serverssl"+ : "/Common/clientssl"+ }+ />+ </FormControl>+ )}+ />+ )}+ </>+ )}+ </>+ );+};diff --git a/frontend/src/components/pki-syncs/forms/PkiSyncDestinationFields.tsx b/frontend/src/components/pki-syncs/forms/PkiSyncDestinationFields.tsxindex f9e5469469..9e75d052f1 100644--- a/frontend/src/components/pki-syncs/forms/PkiSyncDestinationFields.tsx+++ b/frontend/src/components/pki-syncs/forms/PkiSyncDestinationFields.tsx@@ -9,6 +9,7 @@ import { AwsSecretsManagerPkiSyncFields } from "./AwsSecretsManagerPkiSyncFieldsimport { AzureKeyVaultPkiSyncFields } from "./AzureKeyVaultPkiSyncFields";import { ChefPkiSyncFields } from "./ChefPkiSyncFields";import { CloudflareCustomCertificatePkiSyncFields } from "./CloudflareCustomCertificatePkiSyncFields";+import { F5BigIpPkiSyncFields } from "./F5BigIpPkiSyncFields";import { NetScalerPkiSyncFields } from "./NetScalerPkiSyncFields";export const PkiSyncDestinationFields = () => {@@ -31,6 +32,8 @@ export const PkiSyncDestinationFields = () => {return <CloudflareCustomCertificatePkiSyncFields />;case PkiSync.NetScaler:return <NetScalerPkiSyncFields />;+ case PkiSync.F5BigIp:+ return <F5BigIpPkiSyncFields />;default:return (<div className="flex items-center justify-center rounded-md border border-red-500 bg-red-100 p-4 text-red-700">diff --git a/frontend/src/components/pki-syncs/forms/PkiSyncOptionsFields/PkiSyncOptionsFields.tsx b/frontend/src/components/pki-syncs/forms/PkiSyncOptionsFields/PkiSyncOptionsFields.tsxindex 880d4f9c2a..cb30849330 100644--- a/frontend/src/components/pki-syncs/forms/PkiSyncOptionsFields/PkiSyncOptionsFields.tsx+++ b/frontend/src/components/pki-syncs/forms/PkiSyncOptionsFields/PkiSyncOptionsFields.tsx@@ -372,6 +372,49 @@ export const PkiSyncOptionsFields = ({ destination }: Props) => {/>)}+ {currentDestination === PkiSync.F5BigIp && (+ <Controller+ control={control}+ name="syncOptions.preserveItemOnRenewal"+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl isError={Boolean(error)} errorText={error?.message}>+ <Switch+ className="bg-mineshaft-400/80 shadow-inner data-[state=checked]:bg-green/80"+ id="preserve-item-on-renewal"+ thumbClassName="bg-mineshaft-800"+ onCheckedChange={onChange}+ isChecked={value}+ >+ <p>+ Preserve Certificate on Renewal{" "}+ <Tooltip+ className="max-w-md"+ content={+ <>+ <p>+ <strong>Only applies to certificate renewals:</strong> controls what+ happens on the BIG-IP when Infisical renews a certificate.+ </p>+ <p className="mt-4">+ When on, the renewed certificate replaces the existing one under the same+ name, so any profile that uses it keeps working without any extra setup.+ </p>+ <p className="mt-4">+ When off, the renewed certificate is uploaded with a new name and the+ original stays on the BIG-IP.+ </p>+ </>+ }+ >+ <FontAwesomeIcon icon={faQuestionCircle} size="sm" className="ml-1" />+ </Tooltip>+ </p>+ </Switch>+ </FormControl>+ )}+ />+ )}+<Controllercontrol={control}name="syncOptions.certificateNameSchema"diff --git a/frontend/src/components/pki-syncs/forms/schemas/f5-big-ip-pki-sync-destination-schema.ts b/frontend/src/components/pki-syncs/forms/schemas/f5-big-ip-pki-sync-destination-schema.tsnew file mode 100644index 0000000000..4f6699e7cb--- /dev/null+++ b/frontend/src/components/pki-syncs/forms/schemas/f5-big-ip-pki-sync-destination-schema.ts@@ -0,0 +1,124 @@+import { z } from "zod";++import { PkiSync } from "@app/hooks/api/pkiSyncs";+import { F5BigIpProfileType } from "@app/hooks/api/pkiSyncs/types/f5-big-ip-sync";++import { BasePkiSyncSchema } from "./base-pki-sync-schema";++const F5_BIG_IP_OBJECT_NAME_REGEX = /^[a-zA-Z0-9._-]{1,255}$/;++const F5BigIpSyncOptionsSchema = z.object({+ canRemoveCertificates: z.boolean().default(true),+ includeRootCa: z.boolean().default(false),+ preserveItemOnRenewal: z.boolean().default(true),+ certificateNameSchema: z+ .string()+ .optional()+ .refine(+ (val) => {+ if (!val) return true;++ const allowedOptionalPlaceholders = ["{{environment}}"];++ const allowedPlaceholdersRegexPart = ["{{certificateId}}", ...allowedOptionalPlaceholders]+ .map((p) => p.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"))+ .join("|");++ const allowedContentRegex = new RegExp(+ `^([a-zA-Z0-9_\\-.]|${allowedPlaceholdersRegexPart})*$`+ );+ const contentIsValid = allowedContentRegex.test(val);++ if (val.trim()) {+ const certificateIdRegex = /\{\{certificateId\}\}/;+ const certificateIdIsPresent = certificateIdRegex.test(val);+ return contentIsValid && certificateIdIsPresent;+ }++ return contentIsValid;+ },+ {+ message:+ "Certificate name schema must include exactly one {{certificateId}} placeholder. It can also include {{environment}} placeholders. Only alphanumeric characters (a-z, A-Z, 0-9), dashes (-), underscores (_), and periods (.) are allowed besides the placeholders."+ }+ )+});++const hasProfileBinding = (profileType: F5BigIpProfileType | undefined) =>+ profileType !== undefined && profileType !== F5BigIpProfileType.None;++const F5BigIpDestinationConfigSchema = z+ .object({+ partition: z+ .string()+ .trim()+ .min(1, "Partition cannot be empty")+ .max(255, "Partition cannot exceed 255 characters")+ .regex(+ F5_BIG_IP_OBJECT_NAME_REGEX,+ "Partition must contain only alphanumeric characters, hyphens, underscores, and periods"+ )+ .optional(),+ profileType: z.nativeEnum(F5BigIpProfileType).optional(),+ profileName: z+ .union([+ z+ .string()+ .trim()+ .max(255, "Profile name cannot exceed 255 characters")+ .regex(+ F5_BIG_IP_OBJECT_NAME_REGEX,+ "Profile name must contain only alphanumeric characters, hyphens, underscores, and periods"+ ),+ z.literal("")+ ])+ .optional()+ .transform((value) => (value ? value : undefined)),+ createProfileIfMissing: z.boolean().optional(),+ parentProfile: z+ .union([z.string().trim().max(511, "Parent profile cannot exceed 511 characters"), z.literal("")])+ .optional()+ .transform((value) => (value ? value : undefined))+ })+ .refine((value) => !hasProfileBinding(value.profileType) || Boolean(value.profileName), {+ message: "Profile name is required when a profile type is selected",+ path: ["profileName"]+ })+ .refine((value) => hasProfileBinding(value.profileType) || !value.createProfileIfMissing, {+ message:+ "Auto-create profile can only be enabled when binding to a Client SSL or Server SSL profile",+ path: ["createProfileIfMissing"]+ })+ .refine((value) => hasProfileBinding(value.profileType) || !value.parentProfile, {+ message: "Parent profile can only be set when binding to a Client SSL or Server SSL profile",+ path: ["parentProfile"]+ })+ .refine((value) => Boolean(value.createProfileIfMissing) || !value.parentProfile, {+ message: "Parent profile can only be set when 'Create profile if missing' is enabled",+ path: ["parentProfile"]+ });++export const F5BigIpPkiSyncDestinationSchema = BasePkiSyncSchema(F5BigIpSyncOptionsSchema).merge(+ z.object({+ destination: z.literal(PkiSync.F5BigIp),+ destinationConfig: F5BigIpDestinationConfigSchema+ })+);++export const UpdateF5BigIpPkiSyncDestinationSchema = F5BigIpPkiSyncDestinationSchema.partial().merge(+ z.object({+ name: z+ .string()+ .trim()+ .min(1, "Name is required")+ .max(255, "Name must be less than 255 characters"),+ destination: z.literal(PkiSync.F5BigIp),+ connection: z.object({+ id: z.string().uuid("Invalid connection ID format"),+ name: z+ .string()+ .min(1, "Connection name is required")+ .max(255, "Connection name must be less than 255 characters")+ })+ })+);diff --git a/frontend/src/components/pki-syncs/forms/schemas/pki-sync-schema.ts b/frontend/src/components/pki-syncs/forms/schemas/pki-sync-schema.tsindex bbc694de11..d6b9eeb4f3 100644--- a/frontend/src/components/pki-syncs/forms/schemas/pki-sync-schema.ts+++ b/frontend/src/components/pki-syncs/forms/schemas/pki-sync-schema.ts@@ -24,6 +24,10 @@ import {CloudflareCustomCertificatePkiSyncDestinationSchema,UpdateCloudflareCustomCertificatePkiSyncDestinationSchema} from "./cloudflare-custom-certificate-pki-sync-destination-schema";+import {+ F5BigIpPkiSyncDestinationSchema,+ UpdateF5BigIpPkiSyncDestinationSchema+} from "./f5-big-ip-pki-sync-destination-schema";import {NetScalerPkiSyncDestinationSchema,UpdateNetScalerPkiSyncDestinationSchema@@ -36,7 +40,8 @@ const PkiSyncUnionSchema = z.discriminatedUnion("destination", [AwsSecretsManagerPkiSyncDestinationSchema,ChefPkiSyncDestinationSchema,CloudflareCustomCertificatePkiSyncDestinationSchema,- NetScalerPkiSyncDestinationSchema+ NetScalerPkiSyncDestinationSchema,+ F5BigIpPkiSyncDestinationSchema]);const UpdatePkiSyncUnionSchema = z.discriminatedUnion("destination", [@@ -46,7 +51,8 @@ const UpdatePkiSyncUnionSchema = z.discriminatedUnion("destination", [UpdateAwsSecretsManagerPkiSyncDestinationSchema,UpdateChefPkiSyncDestinationSchema,UpdateCloudflareCustomCertificatePkiSyncDestinationSchema,- UpdateNetScalerPkiSyncDestinationSchema+ UpdateNetScalerPkiSyncDestinationSchema,+ UpdateF5BigIpPkiSyncDestinationSchema]);export const PkiSyncFormSchema = PkiSyncUnionSchema;diff --git a/frontend/src/helpers/appConnections.ts b/frontend/src/helpers/appConnections.tsindex 97a089b8a4..6e99e86bac 100644--- a/frontend/src/helpers/appConnections.ts+++ b/frontend/src/helpers/appConnections.ts@@ -62,6 +62,7 @@ import { DigitalOceanConnectionMethod } from "@app/hooks/api/appConnections/typeimport { DNSMadeEasyConnectionMethod } from "@app/hooks/api/appConnections/types/dns-made-easy-connection";import { DopplerConnectionMethod } from "@app/hooks/api/appConnections/types/doppler-connection";import { ExternalInfisicalConnectionMethod } from "@app/hooks/api/appConnections/types/external-infisical-connection";+import { F5BigIpConnectionMethod } from "@app/hooks/api/appConnections/types/f5-big-ip-connection";import { HerokuConnectionMethod } from "@app/hooks/api/appConnections/types/heroku-connection";import { LaravelForgeConnectionMethod } from "@app/hooks/api/appConnections/types/laravel-forge-connection";import { NetlifyConnectionMethod } from "@app/hooks/api/appConnections/types/netlify-connection";@@ -181,7 +182,8 @@ export const APP_CONNECTION_MAP: Record<[AppConnection.TravisCI]: { name: "Travis CI", image: "Travis CI.png" },[AppConnection.Salesforce]: { name: "Salesforce", image: "Salesforce.png" },[AppConnection.Snowflake]: { name: "Snowflake", image: "Snowflake.png" },- [AppConnection.Datadog]: { name: "Datadog", image: "DatadogWhite.png" }+ [AppConnection.Datadog]: { name: "Datadog", image: "DatadogWhite.png" },+ [AppConnection.F5BigIp]: { name: "F5 BIG-IP", image: "F5 BIG-IP.png" }};export const getAppConnectionMethodDetails = (method: TAppConnection["method"]) => {@@ -300,6 +302,8 @@ export const getAppConnectionMethodDetails = (method: TAppConnection["method"])return { name: "Basic Auth", icon: faLock };case OVHConnectionMethod.Certificate:return { name: "Certificate", icon: faCertificate };+ case F5BigIpConnectionMethod.BasicAuth:+ return { name: "Basic Auth", icon: faLock };default:throw new Error(`Unhandled App Connection Method: ${method}`);}diff --git a/frontend/src/helpers/pkiSyncs.ts b/frontend/src/helpers/pkiSyncs.tsindex a947692006..e9db4a8abc 100644--- a/frontend/src/helpers/pkiSyncs.ts+++ b/frontend/src/helpers/pkiSyncs.ts@@ -35,6 +35,10 @@ export const PKI_SYNC_MAP: Record<[PkiSync.NetScaler]: {name: "NetScaler",image: "NetScaler.png"+ },+ [PkiSync.F5BigIp]: {+ name: "F5 BIG-IP",+ image: "F5 BIG-IP.png"}};@@ -45,5 +49,6 @@ export const PKI_SYNC_CONNECTION_MAP: Record<PkiSync, AppConnection> = {[PkiSync.AwsElasticLoadBalancer]: AppConnection.AWS,[PkiSync.Chef]: AppConnection.Chef,[PkiSync.CloudflareCustomCertificate]: AppConnection.Cloudflare,- [PkiSync.NetScaler]: AppConnection.NetScaler+ [PkiSync.NetScaler]: AppConnection.NetScaler,+ [PkiSync.F5BigIp]: AppConnection.F5BigIp};diff --git a/frontend/src/hooks/api/appConnections/enums.ts b/frontend/src/hooks/api/appConnections/enums.tsindex 00dffd96f4..6ed2ddfaba 100644--- a/frontend/src/hooks/api/appConnections/enums.ts+++ b/frontend/src/hooks/api/appConnections/enums.ts@@ -64,5 +64,6 @@ export enum AppConnection {TravisCI = "travis-ci",Salesforce = "salesforce",Snowflake = "snowflake",- Datadog = "datadog"+ Datadog = "datadog",+ F5BigIp = "f5-big-ip"}diff --git a/frontend/src/hooks/api/appConnections/types/app-options.ts b/frontend/src/hooks/api/appConnections/types/app-options.tsindex 13a7d4f77e..eabf926318 100644--- a/frontend/src/hooks/api/appConnections/types/app-options.ts+++ b/frontend/src/hooks/api/appConnections/types/app-options.ts@@ -269,6 +269,7 @@ export type TTravisCIConnectionOption = TAppConnectionOptionBase & {export type TSalesforceConnectionOption = TAppConnectionOptionBase & {app: AppConnection.Salesforce;};+export type TSnowflakeConnectionOption = TAppConnectionOptionBase & {app: AppConnection.Snowflake;};@@ -277,6 +278,10 @@ export type TDatadogConnectionOption = TAppConnectionOptionBase & {app: AppConnection.Datadog;};+export type TF5BigIpConnectionOption = TAppConnectionOptionBase & {+ app: AppConnection.F5BigIp;+};+export type TAppConnectionOption =| TAwsConnectionOption| TGitHubConnectionOption@@ -343,7 +348,8 @@ export type TAppConnectionOption =| TTravisCIConnectionOption| TSalesforceConnectionOption| TSnowflakeConnectionOption- | TDatadogConnectionOption;+ | TDatadogConnectionOption+ | TF5BigIpConnectionOption;export type TAppConnectionOptionMap = {[AppConnection.AWS]: TAwsConnectionOption;@@ -412,4 +418,5 @@ export type TAppConnectionOptionMap = {[AppConnection.Salesforce]: TSalesforceConnectionOption;[AppConnection.Snowflake]: TSnowflakeConnectionOption;[AppConnection.Datadog]: TDatadogConnectionOption;+ [AppConnection.F5BigIp]: TF5BigIpConnectionOption;};diff --git a/frontend/src/hooks/api/appConnections/types/f5-big-ip-connection.ts b/frontend/src/hooks/api/appConnections/types/f5-big-ip-connection.tsnew file mode 100644index 0000000000..c36464b29b--- /dev/null+++ b/frontend/src/hooks/api/appConnections/types/f5-big-ip-connection.ts@@ -0,0 +1,18 @@+import { AppConnection } from "@app/hooks/api/appConnections/enums";+import { TRootAppConnection } from "@app/hooks/api/appConnections/types/root-connection";++export enum F5BigIpConnectionMethod {+ BasicAuth = "basic-auth"+}++export type TF5BigIpConnection = TRootAppConnection & { app: AppConnection.F5BigIp } & {+ method: F5BigIpConnectionMethod.BasicAuth;+ credentials: {+ hostname: string;+ port?: number;+ username: string;+ password: string;+ sslRejectUnauthorized?: boolean;+ sslCertificate?: string;+ };+};diff --git a/frontend/src/hooks/api/appConnections/types/index.ts b/frontend/src/hooks/api/appConnections/types/index.tsindex 08cf790c97..b44c6c0997 100644--- a/frontend/src/hooks/api/appConnections/types/index.ts+++ b/frontend/src/hooks/api/appConnections/types/index.ts@@ -26,6 +26,7 @@ import { TDigitalOceanConnection } from "./digital-ocean";import { TDNSMadeEasyConnection } from "./dns-made-easy-connection";import { TDopplerConnection } from "./doppler-connection";import { TExternalInfisicalConnection } from "./external-infisical-connection";+import { TF5BigIpConnection } from "./f5-big-ip-connection";import { TFlyioConnection } from "./flyio-connection";import { TGcpConnection } from "./gcp-connection";import { TGitHubConnection } from "./github-connection";@@ -91,6 +92,7 @@ export * from "./digicert-connection";export * from "./dns-made-easy-connection";export * from "./doppler-connection";export * from "./external-infisical-connection";+export * from "./f5-big-ip-connection";export * from "./flyio-connection";export * from "./gcp-connection";export * from "./github-connection";@@ -198,7 +200,8 @@ export type TAppConnection =| TTravisCIConnection| TSalesforceConnection| TSnowflakeConnection- | TDatadogConnection;+ | TDatadogConnection+ | TF5BigIpConnection;export type TAvailableAppConnection = Pick<TAppConnection, "name" | "id" | "projectId">;diff --git a/frontend/src/hooks/api/pkiSyncs/enums.ts b/frontend/src/hooks/api/pkiSyncs/enums.tsindex 1e5eaeca54..50e0de6ff1 100644--- a/frontend/src/hooks/api/pkiSyncs/enums.ts+++ b/frontend/src/hooks/api/pkiSyncs/enums.ts@@ -5,7 +5,8 @@ export enum PkiSync {AwsElasticLoadBalancer = "aws-elastic-load-balancer",Chef = "chef",CloudflareCustomCertificate = "cloudflare-custom-certificate",- NetScaler = "netscaler"+ NetScaler = "netscaler",+ F5BigIp = "f5-big-ip"}export enum PkiSyncStatus {diff --git a/frontend/src/hooks/api/pkiSyncs/types/f5-big-ip-sync.ts b/frontend/src/hooks/api/pkiSyncs/types/f5-big-ip-sync.tsnew file mode 100644index 0000000000..9bbdd744ad--- /dev/null+++ b/frontend/src/hooks/api/pkiSyncs/types/f5-big-ip-sync.ts@@ -0,0 +1,26 @@+import { AppConnection } from "@app/hooks/api/appConnections/enums";++import { PkiSync } from "../enums";+import { TRootPkiSync } from "./common";++export enum F5BigIpProfileType {+ None = "none",+ ClientSsl = "client-ssl",+ ServerSsl = "server-ssl"+}++export type TF5BigIpPkiSync = TRootPkiSync & {+ destination: PkiSync.F5BigIp;+ destinationConfig: {+ partition?: string;+ profileType?: F5BigIpProfileType;+ profileName?: string;+ createProfileIfMissing?: boolean;+ parentProfile?: string;+ };+ connection: {+ app: AppConnection.F5BigIp;+ name: string;+ id: string;+ };+};diff --git a/frontend/src/hooks/api/pkiSyncs/types/index.ts b/frontend/src/hooks/api/pkiSyncs/types/index.tsindex 94de25a903..0b98bafa60 100644--- a/frontend/src/hooks/api/pkiSyncs/types/index.ts+++ b/frontend/src/hooks/api/pkiSyncs/types/index.ts@@ -6,6 +6,7 @@ import { TAwsSecretsManagerPkiSync } from "./aws-secrets-manager-sync";import { TAzureKeyVaultPkiSync } from "./azure-key-vault-sync";import { TChefPkiSync } from "./chef-sync";import { TCloudflareCustomCertificatePkiSync } from "./cloudflare-custom-certificate-sync";+import { TF5BigIpPkiSync } from "./f5-big-ip-sync";import { TNetScalerPkiSync } from "./netscaler-sync";export type TPkiSyncOption = {@@ -28,7 +29,8 @@ export type TPkiSync =| TAwsElasticLoadBalancerPkiSync| TChefPkiSync| TCloudflareCustomCertificatePkiSync- | TNetScalerPkiSync;+ | TNetScalerPkiSync+ | TF5BigIpPkiSync;export type TListPkiSyncs = { pkiSyncs: TPkiSync[] };@@ -76,6 +78,11 @@ export type TCreatePkiSyncDTO = TCreatePkiSyncDTOBase & {}>;zoneId?: string;vserverName?: string;+ partition?: string;+ profileType?: string;+ profileName?: string;+ createProfileIfMissing?: boolean;+ parentProfile?: string;};};@@ -115,4 +122,5 @@ export * from "./azure-key-vault-sync";export * from "./chef-sync";export * from "./cloudflare-custom-certificate-sync";export * from "./common";+export * from "./f5-big-ip-sync";export * from "./netscaler-sync";diff --git a/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncDestinationSection.tsx b/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncDestinationSection.tsxindex ee75300cd1..1dcd175190 100644--- a/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncDestinationSection.tsx+++ b/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncDestinationSection.tsx@@ -13,6 +13,7 @@ import {AwsSecretsManagerPkiSyncDestinationSection,AzureKeyVaultPkiSyncDestinationSection,ChefPkiSyncDestinationSection,+ F5BigIpPkiSyncDestinationSection,NetScalerPkiSyncDestinationSection} from "./PkiSyncDestinationSection/index";@@ -53,6 +54,9 @@ export const PkiSyncDestinationSection = ({ pkiSync, onEditDestination }: Props)case PkiSync.NetScaler:DestinationComponents = <NetScalerPkiSyncDestinationSection pkiSync={pkiSync} />;break;+ case PkiSync.F5BigIp:+ DestinationComponents = <F5BigIpPkiSyncDestinationSection pkiSync={pkiSync} />;+ break;default:// For future destinations, return null (no additional fields to show)DestinationComponents = null;diff --git a/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncDestinationSection/F5BigIpPkiSyncDestinationSection.tsx b/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncDestinationSection/F5BigIpPkiSyncDestinationSection.tsxnew file mode 100644index 0000000000..0540c612d7--- /dev/null+++ b/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncDestinationSection/F5BigIpPkiSyncDestinationSection.tsx@@ -0,0 +1,52 @@+/* eslint-disable jsx-a11y/label-has-associated-control */+import { F5BigIpProfileType, TF5BigIpPkiSync } from "@app/hooks/api/pkiSyncs/types/f5-big-ip-sync";++const GenericFieldLabel = ({ label, children }: { label: string; children: React.ReactNode }) => (+ <div className="mb-4">+ <p className="text-sm font-medium text-mineshaft-300">{label}</p>+ <div className="text-sm text-mineshaft-300">{children}</div>+ </div>+);++const PROFILE_TYPE_LABELS: Record<F5BigIpProfileType, string> = {+ [F5BigIpProfileType.None]: "None",+ [F5BigIpProfileType.ClientSsl]: "Client SSL Profile",+ [F5BigIpProfileType.ServerSsl]: "Server SSL Profile"+};++type Props = {+ pkiSync: TF5BigIpPkiSync;+};++export const F5BigIpPkiSyncDestinationSection = ({ pkiSync }: Props) => {+ const { partition, profileType, profileName, createProfileIfMissing, parentProfile } =+ pkiSync.destinationConfig;+ const resolvedProfileType = profileType ?? F5BigIpProfileType.None;+ const hasProfileBinding = resolvedProfileType !== F5BigIpProfileType.None;++ return (+ <>+ <GenericFieldLabel label="Partition">{partition || "Common"}</GenericFieldLabel>+ <GenericFieldLabel label="Profile Binding">+ {PROFILE_TYPE_LABELS[resolvedProfileType]}+ </GenericFieldLabel>+ {hasProfileBinding && profileName ? (+ <GenericFieldLabel+ label={+ resolvedProfileType === F5BigIpProfileType.ServerSsl+ ? "Server SSL Profile Name"+ : "Client SSL Profile Name"+ }+ >+ {profileName}+ </GenericFieldLabel>+ ) : null}+ {hasProfileBinding && createProfileIfMissing ? (+ <GenericFieldLabel label="Create profile if missing">Yes</GenericFieldLabel>+ ) : null}+ {hasProfileBinding && createProfileIfMissing && parentProfile ? (+ <GenericFieldLabel label="Parent Profile">{parentProfile}</GenericFieldLabel>+ ) : null}+ </>+ );+};diff --git a/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncDestinationSection/index.ts b/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncDestinationSection/index.tsindex 1205722651..26da31da1c 100644--- a/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncDestinationSection/index.ts+++ b/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncDestinationSection/index.ts@@ -3,4 +3,5 @@ export { AwsElasticLoadBalancerPkiSyncDestinationSection } from "./AwsElasticLoaexport { AwsSecretsManagerPkiSyncDestinationSection } from "./AwsSecretsManagerPkiSyncDestinationSection";export { AzureKeyVaultPkiSyncDestinationSection } from "./AzureKeyVaultPkiSyncDestinationSection";export { ChefPkiSyncDestinationSection } from "./ChefPkiSyncDestinationSection";+export { F5BigIpPkiSyncDestinationSection } from "./F5BigIpPkiSyncDestinationSection";export { NetScalerPkiSyncDestinationSection } from "./NetScalerPkiSyncDestinationSection";diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsxindex fca36aa343..57f4b97369 100644--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx@@ -40,6 +40,7 @@ import { DigitalOceanConnectionForm } from "./DigitalOceanConnectionForm";import { DNSMadeEasyConnectionForm } from "./DNSMadeEasyConnectionForm";import { DopplerConnectionForm } from "./DopplerConnectionForm";import { ExternalInfisicalConnectionForm } from "./ExternalInfisicalConnectionForm";+import { F5BigIpConnectionForm } from "./F5BigIpConnectionForm";import { FlyioConnectionForm } from "./FlyioConnectionForm";import { GcpConnectionForm } from "./GcpConnectionForm";import { GitHubConnectionForm } from "./GitHubConnectionForm";@@ -307,6 +308,8 @@ const CreateForm = ({ app, onComplete, projectId }: CreateFormProps) => {return <SnowflakeConnectionForm onSubmit={onSubmit} />;case AppConnection.Datadog:return <DatadogConnectionForm onSubmit={onSubmit} />;+ case AppConnection.F5BigIp:+ return <F5BigIpConnectionForm onSubmit={onSubmit} />;default:throw new Error(`Unhandled App ${app}`);}@@ -536,6 +539,8 @@ const UpdateForm = ({ appConnection, onComplete }: UpdateFormProps) => {return <SnowflakeConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;case AppConnection.Datadog:return <DatadogConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;+ case AppConnection.F5BigIp:+ return <F5BigIpConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;case AppConnection.Venafi:return <VenafiConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;case AppConnection.VenafiTpp:diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/F5BigIpConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/F5BigIpConnectionForm.tsxnew file mode 100644index 0000000000..5a4fd198f2--- /dev/null+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/F5BigIpConnectionForm.tsx@@ -0,0 +1,344 @@+import { useState } from "react";+import { Controller, FormProvider, useForm } from "react-hook-form";+import { faQuestionCircle } from "@fortawesome/free-solid-svg-icons";+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";+import { Tab } from "@headlessui/react";+import { zodResolver } from "@hookform/resolvers/zod";+import { z } from "zod";++import { OrgPermissionCan } from "@app/components/permissions";+import {+ Button,+ FormControl,+ Input,+ ModalClose,+ SecretInput,+ Select,+ SelectItem,+ Switch,+ TextArea,+ Tooltip+} from "@app/components/v2";+import { GatewayPicker } from "@app/components/v3/platform/GatewayPicker";+import { OrgPermissionSubjects } from "@app/context";+import { OrgGatewayPermissionActions } from "@app/context/OrgPermissionContext/types";+import { APP_CONNECTION_MAP, getAppConnectionMethodDetails } from "@app/helpers/appConnections";+import { F5BigIpConnectionMethod, TF5BigIpConnection } from "@app/hooks/api/appConnections";+import { AppConnection } from "@app/hooks/api/appConnections/enums";++import {+ genericAppConnectionFieldsSchema,+ GenericAppConnectionsFields+} from "./GenericAppConnectionFields";++type Props = {+ appConnection?: TF5BigIpConnection;+ onSubmit: (formData: FormData) => Promise<void>;+};++const rootSchema = genericAppConnectionFieldsSchema.extend({+ app: z.literal(AppConnection.F5BigIp)+});++const formSchema = z.discriminatedUnion("method", [+ rootSchema.extend({+ method: z.literal(F5BigIpConnectionMethod.BasicAuth),+ credentials: z.object({+ hostname: z+ .string()+ .trim()+ .min(1, "Hostname is required")+ .max(512, "Hostname cannot exceed 512 characters"),+ port: z+ .union([z.coerce.number().int().min(1).max(65535), z.literal("")])+ .optional()+ .transform((val) => (val === "" ? undefined : val)),+ username: z+ .string()+ .trim()+ .min(1, "Username is required")+ .max(256, "Username cannot exceed 256 characters"),+ password: z+ .string()+ .trim()+ .min(1, "Password is required")+ .max(512, "Password cannot exceed 512 characters"),+ sslRejectUnauthorized: z.boolean(),+ sslCertificate: z+ .string()+ .trim()+ .transform((value) => value || undefined)+ .optional()+ })+ })+]);++type FormData = z.infer<typeof formSchema>;++export const F5BigIpConnectionForm = ({ appConnection, onSubmit }: Props) => {+ const isUpdate = Boolean(appConnection);+ const [selectedTabIndex, setSelectedTabIndex] = useState(0);++ const form = useForm<FormData>({+ resolver: zodResolver(formSchema),+ defaultValues: appConnection ?? {+ app: AppConnection.F5BigIp,+ method: F5BigIpConnectionMethod.BasicAuth,+ gatewayId: null,+ gatewayPoolId: null,+ credentials: {+ sslRejectUnauthorized: false,+ sslCertificate: undefined+ }+ }+ });++ const {+ handleSubmit,+ control,+ setValue,+ watch,+ formState: { isSubmitting, isDirty }+ } = form;++ const gatewayId = watch("gatewayId");+ const gatewayPoolId = watch("gatewayPoolId");++ return (+ <FormProvider {...form}>+ <form onSubmit={handleSubmit(onSubmit)}>+ {!isUpdate && <GenericAppConnectionsFields />}+ <OrgPermissionCan+ I={OrgGatewayPermissionActions.AttachGateways}+ a={OrgPermissionSubjects.Gateway}+ >+ {(isAllowed) => (+ <FormControl label="Gateway">+ <Tooltip+ isDisabled={isAllowed}+ content="Restricted access. You don't have permission to attach gateways to resources."+ >+ <div>+ <GatewayPicker+ isDisabled={!isAllowed}+ value={{ gatewayId: gatewayId ?? null, gatewayPoolId: gatewayPoolId ?? null }}+ onChange={({ gatewayId: newGwId, gatewayPoolId: newPoolId }) => {+ setValue("gatewayId", newGwId, { shouldDirty: true });+ setValue("gatewayPoolId", newPoolId, { shouldDirty: true });+ }}+ />+ </div>+ </Tooltip>+ </FormControl>+ )}+ </OrgPermissionCan>+ <Controller+ name="method"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl+ tooltipText={`The method you would like to use to connect with ${+ APP_CONNECTION_MAP[AppConnection.F5BigIp].name+ }. This field cannot be changed after creation.`}+ errorText={error?.message}+ isError={Boolean(error?.message)}+ label="Method"+ >+ <Select+ isDisabled={isUpdate}+ value={value}+ onValueChange={(val) => onChange(val)}+ className="w-full border border-mineshaft-500"+ position="popper"+ dropdownContainerClassName="max-w-none"+ >+ {Object.values(F5BigIpConnectionMethod).map((method) => {+ return (+ <SelectItem value={method} key={method}>+ {getAppConnectionMethodDetails(method).name}+ </SelectItem>+ );+ })}+ </Select>+ </FormControl>+ )}+ />+ <Tab.Group selectedIndex={selectedTabIndex} onChange={setSelectedTabIndex}>+ <Tab.List className="mb-3 flex w-full gap-4 border-b border-mineshaft-600">+ <Tab+ className={({ selected }) =>+ `-mb-[0.14rem] px-4 py-2 text-sm font-medium whitespace-nowrap outline-hidden disabled:opacity-60 ${+ selected+ ? "border-b-2 border-mineshaft-300 text-mineshaft-200"+ : "text-bunker-300"+ }`+ }+ >+ Configuration+ </Tab>+ <Tab+ className={({ selected }) =>+ `-mb-[0.14rem] px-4 py-2 text-sm font-medium whitespace-nowrap outline-hidden disabled:opacity-60 ${+ selected+ ? "border-b-2 border-mineshaft-300 text-mineshaft-200"+ : "text-bunker-300"+ }`+ }+ >+ SSL+ </Tab>+ </Tab.List>+ <Tab.Panels className="mb-4 rounded-sm border border-mineshaft-600 bg-mineshaft-700/70 p-3 pb-0">+ <Tab.Panel>+ <div className="grid grid-cols-[1fr_auto] gap-2">+ <Controller+ name="credentials.hostname"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl+ errorText={error?.message}+ isError={Boolean(error?.message)}+ label="Hostname"+ >+ <Input+ value={value}+ onChange={(e) => onChange(e.target.value)}+ placeholder="e.g. bigip.example.com"+ />+ </FormControl>+ )}+ />+ <Controller+ name="credentials.port"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl+ errorText={error?.message}+ isError={Boolean(error?.message)}+ label="Port"+ isOptional+ >+ <Input+ type="number"+ value={value ?? ""}+ onChange={(e) =>+ onChange(e.target.value ? Number(e.target.value) : undefined)+ }+ placeholder="443"+ className="w-24"+ />+ </FormControl>+ )}+ />+ </div>+ <div className="grid grid-cols-2 gap-2">+ <Controller+ name="credentials.username"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl+ errorText={error?.message}+ isError={Boolean(error?.message)}+ label="Username"+ >+ <Input+ value={value}+ onChange={(e) => onChange(e.target.value)}+ placeholder="admin"+ />+ </FormControl>+ )}+ />+ <Controller+ name="credentials.password"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl+ errorText={error?.message}+ isError={Boolean(error?.message)}+ label="Password"+ >+ <SecretInput+ containerClassName="text-gray-400 group-focus-within:border-primary-400/50! border border-mineshaft-500 bg-mineshaft-900 px-2.5 py-1.5"+ value={value}+ onChange={(e) => onChange(e.target.value)}+ />+ </FormControl>+ )}+ />+ </div>+ </Tab.Panel>+ <Tab.Panel>+ <Controller+ name="credentials.sslCertificate"+ control={control}+ render={({ field, fieldState: { error } }) => (+ <FormControl+ errorText={error?.message}+ isError={Boolean(error?.message)}+ label="SSL Certificate"+ isOptional+ >+ <TextArea+ className="h-[3.6rem] resize-none!"+ {...field}+ placeholder="-----BEGIN CERTIFICATE----- ... -----END CERTIFICATE-----"+ />+ </FormControl>+ )}+ />+ <Controller+ name="credentials.sslRejectUnauthorized"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl isError={Boolean(error?.message)} errorText={error?.message}>+ <Switch+ className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"+ id="ssl-reject-unauthorized"+ thumbClassName="bg-mineshaft-800"+ isChecked={value}+ onCheckedChange={onChange}+ >+ <p className="w-38">+ Reject Unauthorized+ <Tooltip+ className="max-w-md"+ content={+ <p>+ If enabled, Infisical will only connect to the F5 BIG-IP if it has a+ valid, trusted SSL certificate. Disable this for self-signed+ certificates or provide a CA certificate above.+ </p>+ }+ >+ <FontAwesomeIcon icon={faQuestionCircle} size="sm" className="ml-1" />+ </Tooltip>+ </p>+ </Switch>+ </FormControl>+ )}+ />+ </Tab.Panel>+ </Tab.Panels>+ </Tab.Group>+ <div className="mt-8 flex items-center">+ <Button+ className="mr-4"+ size="sm"+ type="submit"+ colorSchema="secondary"+ isLoading={isSubmitting}+ isDisabled={isSubmitting || !isDirty}+ >+ {isUpdate ? "Update Credentials" : "Connect to F5 BIG-IP"}+ </Button>+ <ModalClose asChild>+ <Button colorSchema="secondary" variant="plain">+ Cancel+ </Button>+ </ModalClose>+ </div>+ </form>+ </FormProvider>+ );+};