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
feat: add support for restricting to gateway pools
Sheen Capadngan48461ee25ee7
diff --git a/backend/CLAUDE.md b/backend/CLAUDE.mdindex 7b22c041bc..f60d5c32f1 100644--- a/backend/CLAUDE.md+++ b/backend/CLAUDE.md@@ -993,6 +993,14 @@ directly, so falling through turns a dangling gateway reference into a silent byboundary the gateway exists to enforce. And `app_connections.gatewayId` is **not** a v1 column — unlike thethree above it never grew a `gatewayV2Id`, so that one column carries v2 ids and must stay.+**Any new path that attaches an individual gateway must call `assertIndividualGatewayAllowed`**+(`ee/services/gateway-pool/gateway-pool-policy-fns.ts`) next to its `AttachGateways` check. It enforces the+org-level `requireGatewayPools` setting. Pass the gateway the resource already had as `previousGatewayId`,+because clients re-send unchanged values on every save and resources created before the setting was turned+on must stay editable. The check reads the setting, not the plan, so it keeps applying after a downgrade.+Only exempt a mode that refuses pools outright, the way gateway Kubernetes auth in Gateway review mode does+(`$assertCanAttachProxy` in `resource-auth-method-service.ts`), or the policy removes that mode entirely.+### Server PluginsKey plugins in `src/server/plugins/`:diff --git a/backend/src/db/migrations/20261001120000_require-gateway-pools-setting.ts b/backend/src/db/migrations/20261001120000_require-gateway-pools-setting.tsnew file mode 100644index 0000000000..4a64ec4bf1--- /dev/null+++ b/backend/src/db/migrations/20261001120000_require-gateway-pools-setting.ts@@ -0,0 +1,21 @@+import { Knex } from "knex";++import { TableName } from "../schemas";++export async function up(knex: Knex): Promise<void> {+ const hasColumn = await knex.schema.hasColumn(TableName.Organization, "requireGatewayPools");+ if (!hasColumn) {+ await knex.schema.table(TableName.Organization, (table) => {+ table.boolean("requireGatewayPools").notNullable().defaultTo(false);+ });+ }+}++export async function down(knex: Knex): Promise<void> {+ const hasColumn = await knex.schema.hasColumn(TableName.Organization, "requireGatewayPools");+ if (hasColumn) {+ await knex.schema.table(TableName.Organization, (table) => {+ table.dropColumn("requireGatewayPools");+ });+ }+}diff --git a/backend/src/db/sanitized-schema.yaml b/backend/src/db/sanitized-schema.yamlindex 535fa20a92..5222eac113 100644--- a/backend/src/db/sanitized-schema.yaml+++ b/backend/src/db/sanitized-schema.yaml@@ -676,6 +676,7 @@ tables:- parentOrgId- rootOrgId- blockDuplicateSecretSyncDestinations+ - requireGatewayPools- name: pam_accountssource: public.pam_accountsdiff --git a/backend/src/db/schemas/organizations.ts b/backend/src/db/schemas/organizations.tsindex d516635f42..1f5fcb9bc8 100644--- a/backend/src/db/schemas/organizations.ts+++ b/backend/src/db/schemas/organizations.ts@@ -44,7 +44,8 @@ export const OrganizationsSchema = z.object({secretShareBrandConfig: z.unknown().nullable().optional(),defaultCertManagerProjectId: z.string().nullable().optional(),allowCrossProjectSecretSharing: z.boolean().default(false),- createdByUserId: z.string().uuid().nullable().optional()+ createdByUserId: z.string().uuid().nullable().optional(),+ requireGatewayPools: z.boolean().default(false)});export type TOrganizations = z.infer<typeof OrganizationsSchema>;diff --git a/backend/src/ee/services/dynamic-secret/dynamic-secret-service.ts b/backend/src/ee/services/dynamic-secret/dynamic-secret-service.tsindex 27fcdfc20c..918640f139 100644--- a/backend/src/ee/services/dynamic-secret/dynamic-secret-service.ts+++ b/backend/src/ee/services/dynamic-secret/dynamic-secret-service.ts@@ -1,6 +1,7 @@import { ForbiddenError, subject } from "@casl/ability";import { ActionProjectType, OrganizationActionScope } from "@app/db/schemas";+import { assertIndividualGatewayAllowed } from "@app/ee/services/gateway-pool/gateway-pool-policy-fns";import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";import {@@ -14,6 +15,7 @@ import { getMissingGatewayMessage } from "@app/lib/gateway-v2/gateway-errors";import { OrderByDirection } from "@app/lib/types";import { TKmsServiceFactory } from "@app/services/kms/kms-service";import { KmsDataKey } from "@app/services/kms/kms-types";+import { TOrgDALFactory } from "@app/services/org/org-dal";import { TProjectDALFactory } from "@app/services/project/project-dal";import { TResourceMetadataDALFactory } from "@app/services/resource-metadata/resource-metadata-dal";import { TSecretFolderDALFactory } from "@app/services/secret-folder/secret-folder-dal";@@ -48,6 +50,7 @@ type TDynamicSecretServiceFactoryDep = {kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">;gatewayV2DAL: Pick<TGatewayV2DALFactory, "findOne" | "find">;gatewayPoolService: Pick<TGatewayPoolServiceFactory, "resolveAttachableGatewayFromPool">;+ orgDAL: Pick<TOrgDALFactory, "findById">;resourceMetadataDAL: Pick<TResourceMetadataDALFactory, "insertMany" | "delete">;};@@ -91,6 +94,7 @@ export const dynamicSecretServiceFactory = ({kmsService,gatewayV2DAL,gatewayPoolService,+ orgDAL,resourceMetadataDAL}: TDynamicSecretServiceFactoryDep): TDynamicSecretServiceFactory => {const create: TDynamicSecretServiceFactory["create"] = async ({@@ -199,6 +203,8 @@ export const dynamicSecretServiceFactory = ({OrgPermissionSubjects.Gateway);+ await assertIndividualGatewayAllowed({ orgDAL, orgId: actorOrgId, gatewayId: gatewayv2.id });+selectedGatewayId = gatewayv2.id;}@@ -433,6 +439,13 @@ export const dynamicSecretServiceFactory = ({OrgPermissionSubjects.Gateway);+ await assertIndividualGatewayAllowed({+ orgDAL,+ orgId: actorOrgId,+ gatewayId: gatewayv2.id,+ previousGatewayId: dynamicSecretCfg.gatewayV2Id+ });+selectedGatewayId = gatewayv2.id;}diff --git a/backend/src/ee/services/gateway-pool/gateway-pool-policy-fns.test.ts b/backend/src/ee/services/gateway-pool/gateway-pool-policy-fns.test.tsnew file mode 100644index 0000000000..d06ad282f0--- /dev/null+++ b/backend/src/ee/services/gateway-pool/gateway-pool-policy-fns.test.ts@@ -0,0 +1,46 @@+import { BadRequestError } from "@app/lib/errors";++import { assertIndividualGatewayAllowed } from "./gateway-pool-policy-fns";++const orgDALWith = (requireGatewayPools: boolean) => ({+ findById: vi.fn().mockResolvedValue({ id: "org-1", requireGatewayPools })+});++describe("assertIndividualGatewayAllowed", () => {+ test("rejects a newly attached gateway when the org requires pools", async () => {+ await expect(+ assertIndividualGatewayAllowed({ orgDAL: orgDALWith(true), orgId: "org-1", gatewayId: "gw-1" })+ ).rejects.toBeInstanceOf(BadRequestError);+ });++ test("allows a gateway when the org does not require pools", async () => {+ await expect(+ assertIndividualGatewayAllowed({ orgDAL: orgDALWith(false), orgId: "org-1", gatewayId: "gw-1" })+ ).resolves.toBeUndefined();+ });++ test("allows keeping the gateway a resource already had, so existing resources stay editable", async () => {+ const orgDAL = orgDALWith(true);+ await expect(+ assertIndividualGatewayAllowed({ orgDAL, orgId: "org-1", gatewayId: "gw-1", previousGatewayId: "gw-1" })+ ).resolves.toBeUndefined();+ expect(orgDAL.findById).not.toHaveBeenCalled();+ });++ test("rejects switching to a different individual gateway when the org requires pools", async () => {+ await expect(+ assertIndividualGatewayAllowed({+ orgDAL: orgDALWith(true),+ orgId: "org-1",+ gatewayId: "gw-2",+ previousGatewayId: "gw-1"+ })+ ).rejects.toBeInstanceOf(BadRequestError);+ });++ test("does nothing when no individual gateway is being attached", async () => {+ const orgDAL = orgDALWith(true);+ await expect(assertIndividualGatewayAllowed({ orgDAL, orgId: "org-1", gatewayId: null })).resolves.toBeUndefined();+ expect(orgDAL.findById).not.toHaveBeenCalled();+ });+});diff --git a/backend/src/ee/services/gateway-pool/gateway-pool-policy-fns.ts b/backend/src/ee/services/gateway-pool/gateway-pool-policy-fns.tsnew file mode 100644index 0000000000..74c8043561--- /dev/null+++ b/backend/src/ee/services/gateway-pool/gateway-pool-policy-fns.ts@@ -0,0 +1,27 @@+import { BadRequestError } from "@app/lib/errors";+import { TOrgDALFactory } from "@app/services/org/org-dal";++// Only a newly attached individual gateway is rejected. Keeping the one a resource already has+// stays allowed, since clients re-send unchanged values on every save and resources created+// before the policy was enabled must stay editable.+export const assertIndividualGatewayAllowed = async ({+ orgDAL,+ orgId,+ gatewayId,+ previousGatewayId+}: {+ orgDAL: Pick<TOrgDALFactory, "findById">;+ orgId: string;+ gatewayId: string | null | undefined;+ previousGatewayId?: string | null;+}) => {+ if (!gatewayId || gatewayId === previousGatewayId) return;++ const org = await orgDAL.findById(orgId);+ if (org?.requireGatewayPools) {+ throw new BadRequestError({+ message:+ "Your organization requires resources to connect through a gateway pool. Select a gateway pool instead of an individual gateway, or ask an organization admin to turn off Require Gateway Pools under Organization Settings > Networking."+ });+ }+};diff --git a/backend/src/ee/services/identity-auth-template/identity-auth-template-service.test.ts b/backend/src/ee/services/identity-auth-template/identity-auth-template-service.test.tsindex 879b8c36a3..4f9d9dfe96 100644--- a/backend/src/ee/services/identity-auth-template/identity-auth-template-service.test.ts+++ b/backend/src/ee/services/identity-auth-template/identity-auth-template-service.test.ts@@ -90,6 +90,7 @@ const createService = ({identityOidcAuthDAL,gatewayV2DAL,gatewayPoolDAL,+ orgDAL: { findById: vi.fn().mockResolvedValue({ requireGatewayPools: false }) },permissionService: {getOrgPermission: vi.fn()diff --git a/backend/src/ee/services/identity-auth-template/identity-auth-template-service.ts b/backend/src/ee/services/identity-auth-template/identity-auth-template-service.tsindex 2697b1d2be..7b2158ffdc 100644--- a/backend/src/ee/services/identity-auth-template/identity-auth-template-service.ts+++ b/backend/src/ee/services/identity-auth-template/identity-auth-template-service.ts@@ -4,6 +4,7 @@ import { OrganizationActionScope, TIdentityKubernetesAuthsUpdate, TIdentityOidcAimport { TIdentityAuthTemplates } from "@app/db/schemas/identity-auth-templates";import { EventType, TAuditLogServiceFactory } from "@app/ee/services/audit-log/audit-log-types";import { TGatewayPoolDALFactory } from "@app/ee/services/gateway-pool/gateway-pool-dal";+import { assertIndividualGatewayAllowed } from "@app/ee/services/gateway-pool/gateway-pool-policy-fns";import { TGatewayV2DALFactory } from "@app/ee/services/gateway-v2/gateway-v2-dal";import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";import {@@ -27,6 +28,7 @@ import { TIdentityLdapAuthDALFactory } from "@app/services/identity-ldap-auth/idimport { TIdentityOidcAuthDALFactory } from "@app/services/identity-oidc-auth/identity-oidc-auth-dal";import { TKmsServiceFactory } from "@app/services/kms/kms-service";import { KmsDataKey } from "@app/services/kms/kms-types";+import { TOrgDALFactory } from "@app/services/org/org-dal";import { TIdentityAuthTemplateDALFactory } from "./identity-auth-template-dal";import { IdentityAuthTemplateMethod, TEMPLATE_SECRET_FIELDS_BY_METHOD } from "./identity-auth-template-enums";@@ -51,6 +53,7 @@ type TIdentityAuthTemplateServiceFactoryDep = {identityOidcAuthDAL: Pick<TIdentityOidcAuthDALFactory, "updateByTemplateId">;gatewayV2DAL: Pick<TGatewayV2DALFactory, "find">;gatewayPoolDAL: Pick<TGatewayPoolDALFactory, "findById">;+ orgDAL: Pick<TOrgDALFactory, "findById">;permissionService: Pick<TPermissionServiceFactory, "getOrgPermission">;kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey" | "encryptWithInputKey" | "decryptWithInputKey">;licenseService: Pick<TLicenseServiceFactory, "getPlan">;@@ -68,6 +71,7 @@ export const identityAuthTemplateServiceFactory = ({identityOidcAuthDAL,gatewayV2DAL,gatewayPoolDAL,+ orgDAL,permissionService,kmsService,licenseService,@@ -332,6 +336,7 @@ export const identityAuthTemplateServiceFactory = ({plan,permission});+ await assertIndividualGatewayAllowed({ orgDAL, orgId: actorOrgId, gatewayId: normalizedFields.gatewayId });const { resolvedGatewayV2Id, resolvedGatewayPoolId } = await $resolveKubernetesTemplateGateway({gatewayId: normalizedFields.gatewayId,gatewayPoolId: normalizedFields.gatewayPoolId,@@ -457,6 +462,12 @@ export const identityAuthTemplateServiceFactory = ({plan,permission});+ await assertIndividualGatewayAllowed({+ orgDAL,+ orgId: template.orgId,+ gatewayId: merged.gatewayId,+ previousGatewayId: template.gatewayV2Id+ });const { resolvedGatewayV2Id, resolvedGatewayPoolId } = await $resolveKubernetesTemplateGateway({gatewayId: merged.gatewayId,gatewayPoolId: merged.gatewayPoolId,diff --git a/backend/src/ee/services/pam-account-template/pam-account-template-service.ts b/backend/src/ee/services/pam-account-template/pam-account-template-service.tsindex 3d4e454e4c..cdd027c8fd 100644--- a/backend/src/ee/services/pam-account-template/pam-account-template-service.ts+++ b/backend/src/ee/services/pam-account-template/pam-account-template-service.ts@@ -215,14 +215,15 @@ export const pamAccountTemplateServiceFactory = (deps: TPamAccountTemplateServic...ctx}: TUpdatePamAccountTemplateDTO & TActorContext) => {await verifyProductAdmin(projectId, ctx);- await validateGatewayAttachment(deps, gatewayId, gatewayPoolId, ctx);- await validateRecordingConnection(deps, recordingConnectionId, ctx);const existing = await pamAccountTemplateDAL.findById(templateId);if (!existing || existing.projectId !== projectId) {throw new NotFoundError({ message: `Account template with ID '${templateId}' not found` });}+ await validateGatewayAttachment(deps, gatewayId, gatewayPoolId, ctx, existing.gatewayId);+ await validateRecordingConnection(deps, recordingConnectionId, ctx);+const validatedPolicies = validateTemplatePolicies(existing.type, policies);validateTemplateRotationConfig(existing.type, settings);diff --git a/backend/src/ee/services/pam-account/pam-account-service.ts b/backend/src/ee/services/pam-account/pam-account-service.tsindex c618fdd128..1025f98b2c 100644--- a/backend/src/ee/services/pam-account/pam-account-service.ts+++ b/backend/src/ee/services/pam-account/pam-account-service.ts@@ -112,7 +112,7 @@ type TPamAccountServiceFactoryDep = {pamSessionDAL: Pick<TPamSessionDALFactory, "find" | "update">;pamDiscoverySourceDAL: Pick<TPamDiscoverySourceDALFactory, "find">;userDAL: Pick<TUserDALFactory, "findById">;- orgDAL: Pick<TOrgDALFactory, "findOrgById">;+ orgDAL: Pick<TOrgDALFactory, "findOrgById" | "findById">;mfaSessionService: Pick<TMfaSessionServiceFactory,"createMfaSession" | "getMfaSession" | "deleteMfaSession" | "sendMfaCode"@@ -723,11 +723,13 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>}const effectiveGatewayId = gatewayId ?? template.gatewayId;+ // The template's gateway was checked against the pool policy when it was set on the template.await validateGatewayAttachment(deps,effectiveGatewayId,effectiveGatewayId ? null : (gatewayPoolId ?? template.gatewayPoolId),- ctx+ ctx,+ template.gatewayId);await validateRecordingConnection(deps, recordingConnectionId, ctx);@@ -912,11 +914,14 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>const nextTemplateGatewayPoolId = template ? template.gatewayPoolId : existing.templateGatewayPoolId;const effectiveGatewayId = nextGatewayId ?? nextTemplateGatewayId;+ // An inherited template gateway was checked against the pool policy on the template itself.+ const isInheritedGateway = !nextGatewayId && effectiveGatewayId === nextTemplateGatewayId;await validateGatewayAttachment(deps,effectiveGatewayId,effectiveGatewayId ? null : (nextGatewayPoolId ?? nextTemplateGatewayPoolId),- ctx+ ctx,+ isInheritedGateway ? effectiveGatewayId : (existing.gatewayId ?? existing.templateGatewayId));}await validateRecordingConnection(deps, recordingConnectionId, ctx);diff --git a/backend/src/ee/services/pam-discovery/pam-discovery-source-service.ts b/backend/src/ee/services/pam-discovery/pam-discovery-source-service.tsindex 9f5963befa..a986ed119b 100644--- a/backend/src/ee/services/pam-discovery/pam-discovery-source-service.ts+++ b/backend/src/ee/services/pam-discovery/pam-discovery-source-service.ts@@ -16,6 +16,7 @@ import { QueueJobs, QueueName, TQueueServiceFactory } from "@app/queue";import { ActorType } from "@app/services/auth/auth-type";import { TKmsServiceFactory } from "@app/services/kms/kms-service";import { KmsDataKey } from "@app/services/kms/kms-types";+import { TOrgDALFactory } from "@app/services/org/org-dal";import { PamAccountType, PamPostgresAuthMethod, PamProductRole, PamSshAuthMethod } from "../pam/pam-enums";import { checkAccountAccess, TActorContext, verifyProductMembership } from "../pam/pam-permission";@@ -70,6 +71,7 @@ type TPamDiscoverySourceServiceFactoryDep = {TGatewayPoolServiceFactory,"resolveEffectiveGatewayId" | "resolveAttachableGatewayFromPool">;+ orgDAL: Pick<TOrgDALFactory, "findById">;queueService: Pick<TQueueServiceFactory, "queue" | "start">;cronJob: TCronJobFactory;auditLogService: Pick<TAuditLogServiceFactory, "createAuditLog">;@@ -375,7 +377,7 @@ export const pamDiscoverySourceServiceFactory = (deps: TPamDiscoverySourceServic}if (gatewayId !== undefined || gatewayPoolId !== undefined) {- await validateGatewayAttachment(deps, gatewayId, gatewayPoolId, ctx);+ await validateGatewayAttachment(deps, gatewayId, gatewayPoolId, ctx, source.gatewayId);}const discoveryConfiguration =diff --git a/backend/src/ee/services/pam/pam-validators.ts b/backend/src/ee/services/pam/pam-validators.tsindex 4d322d741c..90a714be3c 100644--- a/backend/src/ee/services/pam/pam-validators.ts+++ b/backend/src/ee/services/pam/pam-validators.ts@@ -1,6 +1,7 @@import { ForbiddenError, subject } from "@casl/ability";import { OrganizationActionScope } from "@app/db/schemas";+import { assertIndividualGatewayAllowed } from "@app/ee/services/gateway-pool/gateway-pool-policy-fns";import { TGatewayPoolServiceFactory } from "@app/ee/services/gateway-pool/gateway-pool-service";import { TGatewayV2DALFactory } from "@app/ee/services/gateway-v2/gateway-v2-dal";import {@@ -16,6 +17,7 @@ import { decryptAppConnection } from "@app/services/app-connection/app-connectioimport { getAwsConnectionConfig } from "@app/services/app-connection/aws/aws-connection-fns";import { TAwsConnectionConfig } from "@app/services/app-connection/aws/aws-connection-types";import { TKmsServiceFactory } from "@app/services/kms/kms-service";+import { TOrgDALFactory } from "@app/services/org/org-dal";import { TPamAccountSettingsOverrides } from "../pam-account-template/pam-account-template-schemas";import { PamRecordingStorageBackend } from "../pam-session-recording/pam-recording-enums";@@ -29,17 +31,20 @@ export type TPamValidatorDeps = {gatewayPoolService: Pick<TGatewayPoolServiceFactory, "resolveAttachableGatewayFromPool">;appConnectionDAL: Pick<TAppConnectionDALFactory, "findOne" | "findById">;kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">;+ orgDAL: Pick<TOrgDALFactory, "findById">;};export const validateGatewayAttachment = async ({permissionService,gatewayV2DAL,- gatewayPoolService- }: Pick<TPamValidatorDeps, "permissionService" | "gatewayV2DAL" | "gatewayPoolService">,+ gatewayPoolService,+ orgDAL+ }: Pick<TPamValidatorDeps, "permissionService" | "gatewayV2DAL" | "gatewayPoolService" | "orgDAL">,gwId: string | null | undefined,poolId: string | null | undefined,- ctx: TActorContext+ ctx: TActorContext,+ previousGatewayId?: string | null) => {if (gwId) {const gw = await gatewayV2DAL.findOne({ id: gwId, orgId: ctx.actorOrgId });@@ -59,6 +64,8 @@ export const validateGatewayAttachment = async (OrgPermissionGatewayActions.AttachGateways,OrgPermissionSubjects.Gateway);++ await assertIndividualGatewayAllowed({ orgDAL, orgId: ctx.actorOrgId, gatewayId: gwId, previousGatewayId });}if (poolId) {await gatewayPoolService.resolveAttachableGatewayFromPool({diff --git a/backend/src/ee/services/pki-discovery/pki-discovery-service.ts b/backend/src/ee/services/pki-discovery/pki-discovery-service.tsindex b399665bd4..6c58027e8c 100644--- a/backend/src/ee/services/pki-discovery/pki-discovery-service.ts+++ b/backend/src/ee/services/pki-discovery/pki-discovery-service.ts@@ -2,6 +2,7 @@ import { ForbiddenError } from "@casl/ability";import { ActionProjectType, OrganizationActionScope } from "@app/db/schemas";import { TGatewayPoolDALFactory } from "@app/ee/services/gateway-pool/gateway-pool-dal";+import { assertIndividualGatewayAllowed } from "@app/ee/services/gateway-pool/gateway-pool-policy-fns";import { TGatewayPoolServiceFactory } from "@app/ee/services/gateway-pool/gateway-pool-service";import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";import { OrgPermissionGatewayActions, OrgPermissionSubjects } from "@app/ee/services/permission/org-permission";@@ -12,6 +13,7 @@ import {} from "@app/ee/services/permission/project-permission";import { getConfig } from "@app/lib/config/env";import { BadRequestError, DatabaseError, ForbiddenRequestError, NotFoundError } from "@app/lib/errors";+import { TOrgDALFactory } from "@app/services/org/org-dal";import { TGatewayV2DALFactory } from "../gateway-v2/gateway-v2-dal";import { TPkiDiscoveryConfigDALFactory } from "./pki-discovery-config-dal";@@ -54,6 +56,7 @@ type TPkiDiscoveryServiceFactoryDep = {gatewayV2DAL: Pick<TGatewayV2DALFactory, "findOne">;gatewayPoolDAL: Pick<TGatewayPoolDALFactory, "findById">;gatewayPoolService: Pick<TGatewayPoolServiceFactory, "resolveAttachableGatewayFromPool">;+ orgDAL: Pick<TOrgDALFactory, "findById">;queuePkiDiscoveryScan: (discoveryId: string) => Promise<void>;};@@ -81,6 +84,7 @@ export const pkiDiscoveryServiceFactory = ({gatewayV2DAL,gatewayPoolDAL,gatewayPoolService,+ orgDAL,queuePkiDiscoveryScan}: TPkiDiscoveryServiceFactoryDep) => {const createDiscovery = async ({@@ -156,6 +160,8 @@ export const pkiDiscoveryServiceFactory = ({OrgPermissionGatewayActions.AttachGateways,OrgPermissionSubjects.Gateway);++ await assertIndividualGatewayAllowed({ orgDAL, orgId: actorOrgId, gatewayId });} else if (gatewayPoolId) {await gatewayPoolService.resolveAttachableGatewayFromPool({poolId: gatewayPoolId,@@ -254,6 +260,13 @@ export const pkiDiscoveryServiceFactory = ({OrgPermissionGatewayActions.AttachGateways,OrgPermissionSubjects.Gateway);++ await assertIndividualGatewayAllowed({+ orgDAL,+ orgId: actorOrgId,+ gatewayId,+ previousGatewayId: discovery.gatewayId+ });} else if (gatewayPoolId && gatewayPoolId !== discovery.gatewayPoolId) {await gatewayPoolService.resolveAttachableGatewayFromPool({poolId: gatewayPoolId,diff --git a/backend/src/ee/services/resource-auth-method/resource-auth-method-service.ts b/backend/src/ee/services/resource-auth-method/resource-auth-method-service.tsindex 0ac7dffcc2..dc20f0d8dc 100644--- a/backend/src/ee/services/resource-auth-method/resource-auth-method-service.ts+++ b/backend/src/ee/services/resource-auth-method/resource-auth-method-service.ts@@ -2,12 +2,14 @@ import { ForbiddenError } from "@casl/ability";import { Knex } from "knex";import { ActionProjectType, OrganizationActionScope } from "@app/db/schemas";+import { assertIndividualGatewayAllowed } from "@app/ee/services/gateway-pool/gateway-pool-policy-fns";import { crypto } from "@app/lib/crypto";import { BadRequestError, NotFoundError, UnauthorizedError } from "@app/lib/errors";import { OrgServiceActor } from "@app/lib/types";import { TIdentityDALFactory } from "@app/services/identity/identity-dal";import { TKmsServiceFactory } from "@app/services/kms/kms-service";import { KmsDataKey } from "@app/services/kms/kms-types";+import { TOrgDALFactory } from "@app/services/org/org-dal";import { TAgentVaultProxyDALFactory } from "../agent-vault-proxy/agent-vault-proxy-dal";import { TGatewayPoolDALFactory } from "../gateway-pool/gateway-pool-dal";@@ -58,6 +60,7 @@ import {ResourceAuthLoginFailureReason,ResourceAuthMethodType,type ResourceRef,+ type TKubernetesTokenReviewMode,type TSettableAuthMethod} from "./resource-auth-method-fns";import {@@ -112,6 +115,7 @@ type TResourceAuthMethodServiceFactoryDep = {identityDAL: Pick<TIdentityDALFactory, "findById">;permissionService: Pick<TPermissionServiceFactory, "getOrgPermission" | "getProjectPermission">;licenseService: Pick<TLicenseServiceFactory, "getPlan">;+ orgDAL: Pick<TOrgDALFactory, "findById">;gatewayProxyRegistry: TGatewayProxyRegistry;};@@ -177,6 +181,7 @@ export const resourceAuthMethodServiceFactory = ({identityDAL,permissionService,licenseService,+ orgDAL,gatewayProxyRegistry}: TResourceAuthMethodServiceFactoryDep) => {// Registry rows carry the resource FK in a per-type column (gatewayId/relayId/kmipServerId).@@ -306,7 +311,12 @@ export const resourceAuthMethodServiceFactory = ({// Machine identity Kubernetes auth gates its gateway selection the same way.const $assertCanAttachProxy = async (actor: Pick<OrgServiceActor, "type" | "id" | "authMethod" | "orgId">,- proxy: { gatewayV2Id?: string | null; gatewayPoolId?: string | null }+ proxy: {+ gatewayV2Id?: string | null;+ gatewayPoolId?: string | null;+ tokenReviewMode?: TKubernetesTokenReviewMode | null;+ },+ previousGatewayV2Id?: string | null) => {if (!proxy.gatewayV2Id && !proxy.gatewayPoolId) return;@@ -323,6 +333,16 @@ export const resourceAuthMethodServiceFactory = ({OrgPermissionGatewayActions.AttachGateways,OrgPermissionSubjects.Gateway);+ // The reviewing gateway attests every login, so it has to be one specific gateway and a pool is+ // refused for this mode. Exempting it keeps the mode usable under the org's pool requirement.+ if (proxy.tokenReviewMode !== KubernetesTokenReviewMode.Gateway) {+ await assertIndividualGatewayAllowed({+ orgDAL,+ orgId: actor.orgId,+ gatewayId: proxy.gatewayV2Id,+ previousGatewayId: previousGatewayV2Id+ });+ }}// Pools carry their own attach permission, so holding it for gateways is not sufficient.@@ -852,8 +872,9 @@ export const resourceAuthMethodServiceFactory = ({let effectiveCa = authMethod.caCertificate;let effectiveReviewer = authMethod.tokenReviewerJwt;let destinationChanged = false;+ const stored =+ !isMethodChange && current ? await resourceKubernetesAuthDAL.findOne({ authMethodId: current.id }) : undefined;if (!isMethodChange && current && (effectiveCa === undefined || effectiveReviewer === undefined)) {- const stored = await resourceKubernetesAuthDAL.findOne({ authMethodId: current.id });const { decryptor } = await kmsService.createCipherPairWithDataKey({type: KmsDataKey.Organization,orgId: actor.orgId@@ -886,7 +907,7 @@ export const resourceAuthMethodServiceFactory = ({}await $assertProxyNotSelf(resource, authMethod);- await $assertCanAttachProxy(actor, authMethod);+ await $assertCanAttachProxy(actor, authMethod, stored?.gatewayV2Id);const validation = await $buildKubernetesExecutor({diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.tsindex b4aa05adee..59eeb46423 100644--- a/backend/src/server/routes/index.ts+++ b/backend/src/server/routes/index.ts@@ -1990,6 +1990,7 @@ export const registerRoutes = async (const gatewayProxyRegistry = gatewayProxyRegistryFactory();const resourceAuthMethodService = resourceAuthMethodServiceFactory({+ orgDAL,resourceAuthMethodDAL,resourceAwsAuthDAL,resourceGcpAuthDAL,@@ -2082,6 +2083,7 @@ export const registerRoutes = async (});const pamAccountTemplateService = pamAccountTemplateServiceFactory({+ orgDAL,pamAccountTemplateDAL,pamAccountDAL,permissionService,@@ -2588,6 +2590,7 @@ export const registerRoutes = async (});const identityAuthTemplateService = identityAuthTemplateServiceFactory({+ orgDAL,identityAuthTemplateDAL,identityLdapAuthDAL,identityKubernetesAuthDAL,@@ -2865,6 +2868,7 @@ export const registerRoutes = async (projectDAL});const dynamicSecretService = dynamicSecretServiceFactory({+ orgDAL,projectDAL,dynamicSecretQueueService,dynamicSecretDAL,@@ -3058,6 +3062,7 @@ export const registerRoutes = async (});const appConnectionService = appConnectionServiceFactory({+ orgDAL,appConnectionDAL,permissionService,kmsService,@@ -3085,6 +3090,7 @@ export const registerRoutes = async (});const hsmConnectorService = hsmConnectorServiceFactory({+ orgDAL,hsmConnectorDAL,permissionService,kmsService,@@ -3757,6 +3763,7 @@ export const registerRoutes = async (const pamAccountDependencyDAL = pamAccountDependencyDALFactory(db);const pamDiscoveryService = pamDiscoverySourceServiceFactory({+ orgDAL,pamDiscoverySourceDAL,pamDiscoverySourceRunDAL,pamDiscoveredAccountDAL,@@ -4052,6 +4059,7 @@ export const registerRoutes = async (});const pkiDiscoveryService = pkiDiscoveryServiceFactory({+ orgDAL,pkiDiscoveryConfigDAL,pkiDiscoveryScanHistoryDAL,permissionService,diff --git a/backend/src/server/routes/v1/organization-router.ts b/backend/src/server/routes/v1/organization-router.tsindex 2e96bf6b99..4dc24d4d59 100644--- a/backend/src/server/routes/v1/organization-router.ts+++ b/backend/src/server/routes/v1/organization-router.ts@@ -431,6 +431,12 @@ export const registerOrgRouter = async (server: FastifyZodProvider) => {.boolean().optional().describe("Allow secret imports and references to target secrets in other projects within the organization"),+ requireGatewayPools: z+ .boolean()+ .optional()+ .describe(+ "Require resources in the organization to connect through a gateway pool instead of an individual gateway"+ ),secretShareBrandConfig: z.object({primaryColor: zdiff --git a/backend/src/services/app-connection/app-connection-service.ts b/backend/src/services/app-connection/app-connection-service.tsindex e163b8636b..1e5f39ff40 100644--- a/backend/src/services/app-connection/app-connection-service.ts+++ b/backend/src/services/app-connection/app-connection-service.ts@@ -7,6 +7,7 @@ import { chefConnectionService } from "@app/ee/services/app-connections/chef/cheimport { ValidateOCIConnectionCredentialsSchema } from "@app/ee/services/app-connections/oci";import { ociConnectionService } from "@app/ee/services/app-connections/oci/oci-connection-service";import { ValidateOracleDBConnectionCredentialsSchema } from "@app/ee/services/app-connections/oracledb";+import { assertIndividualGatewayAllowed } from "@app/ee/services/gateway-pool/gateway-pool-policy-fns";import { TGatewayPoolServiceFactory } from "@app/ee/services/gateway-pool/gateway-pool-service";import { TGatewayV2DALFactory } from "@app/ee/services/gateway-v2/gateway-v2-dal";import { TGatewayV2ServiceFactory } from "@app/ee/services/gateway-v2/gateway-v2-service";@@ -43,6 +44,7 @@ import {import { TGitHubAppDALFactory } from "@app/services/github-app/github-app-dal";import { TIdentityUaDALFactory } from "@app/services/identity-ua/identity-ua-dal";import { TKmsServiceFactory } from "@app/services/kms/kms-service";+import { TOrgDALFactory } from "@app/services/org/org-dal";import { TProjectDALFactory } from "@app/services/project/project-dal";import { ValidateOnePassConnectionCredentialsSchema } from "./1password";@@ -217,6 +219,7 @@ export type TAppConnectionServiceFactoryDep = {"resolveAttachableGatewayFromPool" | "resolveEffectiveGatewayId" | "runWithPoolFailover">;gatewayV2DAL: Pick<TGatewayV2DALFactory, "find">;+ orgDAL: Pick<TOrgDALFactory, "findById">;projectDAL: Pick<TProjectDALFactory, "findProjectById">;appConnectionCredentialRotationService: TAppConnectionCredentialRotationServiceFactory;identityUaDAL: Pick<TIdentityUaDALFactory, "findOne">;@@ -326,6 +329,7 @@ export const appConnectionServiceFactory = ({gatewayV2Service,gatewayPoolService,gatewayV2DAL,+ orgDAL,projectDAL,appConnectionCredentialRotationService,identityUaDAL,@@ -595,6 +599,8 @@ export const appConnectionServiceFactory = ({if (!gatewayV2) {throw new NotFoundError({ message: getMissingGatewayMessage(gatewayId) });}++ await assertIndividualGatewayAllowed({ orgDAL, orgId: actor.orgId, gatewayId });}if (gatewayPoolId) {@@ -823,6 +829,8 @@ export const appConnectionServiceFactory = ({if (!gatewayV2) {throw new NotFoundError({ message: getMissingGatewayMessage(gatewayId) });}++ await assertIndividualGatewayAllowed({ orgDAL, orgId: actor.orgId, gatewayId });}}diff --git a/backend/src/services/hsm-connector/hsm-connector-service.ts b/backend/src/services/hsm-connector/hsm-connector-service.tsindex 328df10a78..9dbffae2e5 100644--- a/backend/src/services/hsm-connector/hsm-connector-service.ts+++ b/backend/src/services/hsm-connector/hsm-connector-service.ts@@ -2,6 +2,7 @@ import { ForbiddenError } from "@casl/ability";import { ActionProjectType } from "@app/db/schemas";import { TGatewayPoolDALFactory } from "@app/ee/services/gateway-pool/gateway-pool-dal";+import { assertIndividualGatewayAllowed } from "@app/ee/services/gateway-pool/gateway-pool-policy-fns";import { TGatewayPoolServiceFactory } from "@app/ee/services/gateway-pool/gateway-pool-service";import { TGatewayV2DALFactory } from "@app/ee/services/gateway-v2/gateway-v2-dal";import { TGatewayV2ServiceFactory } from "@app/ee/services/gateway-v2/gateway-v2-service";@@ -15,6 +16,7 @@ import {} from "@app/ee/services/permission/project-permission";import { BadRequestError, NotFoundError } from "@app/lib/errors";import { TKmsServiceFactory } from "@app/services/kms/kms-service";+import { TOrgDALFactory } from "@app/services/org/org-dal";import { HsmKeyAlgorithm } from "@app/services/signer/signer-enums";import type { THsmConnectorDALFactory } from "./hsm-connector-dal";@@ -45,6 +47,7 @@ export type THsmConnectorServiceFactoryDep = {gatewayPoolService: Pick<TGatewayPoolServiceFactory, "listHealthyGateways" | "selectGatewayFromPool">;gatewayV2DAL: Pick<TGatewayV2DALFactory, "findById">;gatewayPoolDAL: Pick<TGatewayPoolDALFactory, "findById">;+ orgDAL: Pick<TOrgDALFactory, "findById">;licenseService: Pick<TLicenseServiceFactory, "getPlan">;};@@ -58,6 +61,7 @@ export const hsmConnectorServiceFactory = ({gatewayPoolService,gatewayV2DAL,gatewayPoolDAL,+ orgDAL,licenseService}: THsmConnectorServiceFactoryDep) => {const routing = hsmConnectorRoutingFactory({ gatewayV2Service, gatewayPoolService });@@ -65,13 +69,15 @@ export const hsmConnectorServiceFactory = ({const assertGatewayBelongsToOrg = async (actorOrgId: string,gatewayId: string | null | undefined,- gatewayPoolId: string | null | undefined+ gatewayPoolId: string | null | undefined,+ previousGatewayId?: string | null) => {if (gatewayId) {const gw = await gatewayV2DAL.findById(gatewayId);if (!gw || gw.orgId !== actorOrgId) {throw new NotFoundError({ message: `Gateway ${gatewayId} not found.` });}+ await assertIndividualGatewayAllowed({ orgDAL, orgId: actorOrgId, gatewayId, previousGatewayId });}if (gatewayPoolId) {const pool = await gatewayPoolDAL.findById(gatewayPoolId);@@ -246,7 +252,7 @@ export const hsmConnectorServiceFactory = ({}if (routingChanged) {- await assertGatewayBelongsToOrg(actor.orgId, nextGatewayId, nextGatewayPoolId);+ await assertGatewayBelongsToOrg(actor.orgId, nextGatewayId, nextGatewayPoolId, row.gatewayId);}const effectiveRoutingChanged =diff --git a/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts b/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.tsindex 42b8e2fe50..4d5a843ff0 100644--- a/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts+++ b/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts@@ -14,6 +14,7 @@ import {} from "@app/db/schemas";import { TIdentityAuthTemplates } from "@app/db/schemas/identity-auth-templates";import { TGatewayPoolDALFactory } from "@app/ee/services/gateway-pool/gateway-pool-dal";+import { assertIndividualGatewayAllowed } from "@app/ee/services/gateway-pool/gateway-pool-policy-fns";import { TGatewayPoolServiceFactory } from "@app/ee/services/gateway-pool/gateway-pool-service";import { TGatewayV2DALFactory } from "@app/ee/services/gateway-v2/gateway-v2-dal";import { TGatewayV2ServiceFactory } from "@app/ee/services/gateway-v2/gateway-v2-service";@@ -1017,6 +1018,7 @@ export const identityKubernetesAuthServiceFactory = ({OrgPermissionGatewayActions.AttachGateways,OrgPermissionSubjects.Gateway);+ await assertIndividualGatewayAllowed({ orgDAL, orgId: identityMembershipOrg.scopeOrgId, gatewayId });}if (tokenReviewMode === IdentityKubernetesAuthTokenReviewMode.Gateway) {@@ -1411,6 +1413,12 @@ export const identityKubernetesAuthServiceFactory = ({OrgPermissionGatewayActions.AttachGateways,OrgPermissionSubjects.Gateway);+ await assertIndividualGatewayAllowed({+ orgDAL,+ orgId: identityMembershipOrg.scopeOrgId,+ gatewayId,+ previousGatewayId: identityKubernetesAuth.gatewayV2Id+ });}}diff --git a/backend/src/services/org/org-schema.ts b/backend/src/services/org/org-schema.tsindex 545d364d26..2bf8655223 100644--- a/backend/src/services/org/org-schema.ts+++ b/backend/src/services/org/org-schema.ts@@ -31,6 +31,7 @@ export const sanitizedOrganizationSchema = OrganizationsSchema.pick({maxSharedSecretViewLimit: true,blockDuplicateSecretSyncDestinations: true,allowCrossProjectSecretSharing: true,+ requireGatewayPools: true,rootOrgId: true,parentOrgId: true,secretShareBrandConfig: truediff --git a/backend/src/services/org/org-service.ts b/backend/src/services/org/org-service.tsindex 214e8ab255..6f60dd9864 100644--- a/backend/src/services/org/org-service.ts+++ b/backend/src/services/org/org-service.ts@@ -473,6 +473,7 @@ export const orgServiceFactory = ({maxSharedSecretViewLimit,blockDuplicateSecretSyncDestinations,allowCrossProjectSecretSharing,+ requireGatewayPools,secretShareBrandConfig}}: TUpdateOrgDTO) => {@@ -515,6 +516,15 @@ export const orgServiceFactory = ({}}+ if (requireGatewayPools) {+ if (!plan.gatewayPool) {+ throw new BadRequestError({+ message:+ "Failed to require gateway pools due to plan restriction. Upgrade to Infisical Enterprise to use gateway pools."+ });+ }+ }+if (enforceMfa !== undefined) {if (!plan.enforceMfa) {throw new BadRequestError({@@ -678,6 +688,7 @@ export const orgServiceFactory = ({maxSharedSecretViewLimit,blockDuplicateSecretSyncDestinations,allowCrossProjectSecretSharing,+ requireGatewayPools,secretShareBrandConfig});if (!org) throw new NotFoundError({ message: `Organization with ID '${orgId}' not found` });diff --git a/backend/src/services/org/org-types.ts b/backend/src/services/org/org-types.tsindex cad5ea20ce..beef563466 100644--- a/backend/src/services/org/org-types.ts+++ b/backend/src/services/org/org-types.ts@@ -90,6 +90,7 @@ export type TUpdateOrgDTO = {maxSharedSecretViewLimit: number | null;blockDuplicateSecretSyncDestinations: boolean;allowCrossProjectSecretSharing: boolean;+ requireGatewayPools: boolean;secretShareBrandConfig: TSecretShareBrandConfig;}>;} & TOrgPermission;diff --git a/docs/documentation/platform/gateways/gateway-pools.mdx b/docs/documentation/platform/gateways/gateway-pools.mdxindex 3d6a9b0054..b8c361c1de 100644--- a/docs/documentation/platform/gateways/gateway-pools.mdx+++ b/docs/documentation/platform/gateways/gateway-pools.mdx@@ -57,6 +57,32 @@ Anywhere you configure a gateway, the gateway picker dropdown shows both individWhen you select a pool, the platform validates connectivity through one of its healthy gateways before saving.+## Requiring gateway pools++If a resource connects through an individual gateway, the resource loses its connection whenever that gateway is redeployed or goes down. To prevent this, you can require every resource in your organization to connect through a gateway pool instead. You need permission to edit organization settings to change this setting.++<Steps>+ <Step>+ Go to **Settings**, select **Networking**, then open the **Gateways** tab.+ </Step>+ <Step>+ In the **Enforcement** section, turn on **Require Gateway Pools**.+ </Step>+</Steps>++While the setting is on:++- The gateway picker still lists individual gateways, but you can't select them+- Infisical rejects any request that attaches an individual gateway to a resource, including requests made through the API+- Resources that already use an individual gateway keep working, and you can edit their other settings without changing the gateway+- Resources that connect without a gateway aren't affected++Turning the setting off doesn't change any resource.++<Note>+ A gateway's own Kubernetes Auth can still use an individual gateway in **Gateway as Reviewer** mode, because a pool can't perform the review. If you select an individual gateway there while the setting is on, the review mode switches to **Gateway as Reviewer**.+</Note>+## Gateway selectionEach gateway reports how many connections it's currently handling. When a request is routed through a pool, the platform picks the healthy member handling the fewest, so a gateway holding several long-lived sessions stops attracting new work until the others catch up.diff --git a/frontend/src/components/v3/platform/GatewayPicker/GatewayPicker.tsx b/frontend/src/components/v3/platform/GatewayPicker/GatewayPicker.tsxindex c0eadb5a75..de428296fc 100644--- a/frontend/src/components/v3/platform/GatewayPicker/GatewayPicker.tsx+++ b/frontend/src/components/v3/platform/GatewayPicker/GatewayPicker.tsx@@ -5,6 +5,7 @@ import { GlobeIcon, Layers3Icon, type LucideIcon, ServerIcon } from "lucide-reacimport { useOrganization, useOrgPermission, useSubscription } from "@app/context";import {OrgGatewayPermissionActions,+ OrgGatewayPoolPermissionActions,OrgPermissionSubjects} from "@app/context/OrgPermissionContext/types";import { gatewayPoolsQueryKeys } from "@app/hooks/api/gateway-pools/queries";@@ -38,6 +39,8 @@ type Props = {noGatewayIcon?: LucideIcon;// Hides one gateway from the list, for callers where selecting it would be self-referential.excludeGatewayId?: string;+ // For callers where the backend exempts an individual gateway from the org's pool requirement.+ allowIndividualGateways?: boolean;};const SectionLabel = ({ children }: { children: React.ReactNode }) => (@@ -56,12 +59,16 @@ export const GatewayPicker = ({isError,noGatewayLabel = "Internet Gateway",noGatewayIcon: NoGatewayIcon = GlobeIcon,- excludeGatewayId+ excludeGatewayId,+ allowIndividualGateways}: Props) => {const { subscription } = useSubscription();const { currentOrg } = useOrganization();const { permission } = useOrgPermission();- const showPools = subscription?.gatewayPool;+ const isPoolRequired = Boolean(currentOrg?.requireGatewayPools) && !allowIndividualGateways;+ // Pools stay listed when the policy is on even if the plan no longer includes them, or the+ // picker would have nothing selectable.+ const showPools = subscription?.gatewayPool || Boolean(currentOrg?.requireGatewayPools);const { data: gateways, isPending: isGatewaysLoading } = useQuery(gatewaysQueryKeys.list());const { data: pools, isPending: isPoolsLoading } = useQuery({@@ -94,10 +101,15 @@ export const GatewayPicker = ({const poolCount = pools?.length ?? 0;const hasAnyGateways = v2Gateways.length > 0 || poolCount > 0;+ const isGatewayBlocked = (gatewayId: string) => isPoolRequired && gatewayId !== value.gatewayId;const canCreateGateway = permission.can(OrgGatewayPermissionActions.CreateGateways,OrgPermissionSubjects.Gateway);+ const canCreateGatewayPool = permission.can(+ OrgGatewayPoolPermissionActions.CreateGatewayPools,+ OrgPermissionSubjects.GatewayPool+ );return (<Select value={selectValue} onValueChange={handleChange} disabled={isDisabled || isLoading}>@@ -155,9 +167,19 @@ export const GatewayPicker = ({<ServerIcon className="size-3" />Individual Gateways</div>+ {isPoolRequired && (+ <div className="mt-1 text-[11px]">+ Your organization requires a gateway pool, so individual gateways can't be+ selected.+ </div>+ )}</SectionLabel>{v2Gateways.map((gw) => (- <SelectItem value={`gateway:${gw.id}`} key={`gw-${gw.id}`}>+ <SelectItem+ value={`gateway:${gw.id}`}+ key={`gw-${gw.id}`}+ disabled={isGatewayBlocked(gw.id)}+ ><span className="flex min-w-0 items-center gap-2"><ServerIcon className="size-3.5 shrink-0 text-muted" /><span className="truncate">{gw.name}</span>@@ -172,7 +194,28 @@ export const GatewayPicker = ({</>)}- {isRequired && !hasAnyGateways && (+ {isPoolRequired && poolCount === 0 && (+ <div className="px-2 py-4 text-center text-sm text-muted">+ {canCreateGatewayPool ? (+ <>+ Your organization requires a gateway pool, but none exist yet.{" "}+ <Link+ to="/organizations/$orgId/networking"+ params={{ orgId: currentOrg.id }}+ target="_blank"+ className="text-foreground underline underline-offset-2 hover:text-info"+ >+ Create one+ </Link>{" "}+ to continue.+ </>+ ) : (+ "Your organization requires a gateway pool, but none exist yet. Ask your organization admin to create one."+ )}+ </div>+ )}++ {!isPoolRequired && isRequired && !hasAnyGateways && (<div className="px-2 py-4 text-center text-sm text-muted">{canCreateGateway ? (<>diff --git a/frontend/src/hooks/api/organization/queries.tsx b/frontend/src/hooks/api/organization/queries.tsxindex 7666c910c0..f08ac1af4a 100644--- a/frontend/src/hooks/api/organization/queries.tsx+++ b/frontend/src/hooks/api/organization/queries.tsx@@ -154,6 +154,7 @@ export const useUpdateOrg = () => {maxSharedSecretViewLimit,blockDuplicateSecretSyncDestinations,allowCrossProjectSecretSharing,+ requireGatewayPools,secretShareBrandConfig}) => {return apiRequest.patch(`/api/v1/organization/${orgId}`, {@@ -177,6 +178,7 @@ export const useUpdateOrg = () => {maxSharedSecretViewLimit,blockDuplicateSecretSyncDestinations,allowCrossProjectSecretSharing,+ requireGatewayPools,secretShareBrandConfig});},diff --git a/frontend/src/hooks/api/organization/types.ts b/frontend/src/hooks/api/organization/types.tsindex db9d8a00d7..b2fc53df57 100644--- a/frontend/src/hooks/api/organization/types.ts+++ b/frontend/src/hooks/api/organization/types.ts@@ -36,6 +36,7 @@ export type Organization = {maxSharedSecretViewLimit: number | null;blockDuplicateSecretSyncDestinations: boolean;allowCrossProjectSecretSharing: boolean;+ requireGatewayPools: boolean;parentOrgId: string | null;rootOrgId: string | null;secretShareBrandConfig?: TSecretShareBrandConfig;@@ -65,6 +66,7 @@ export type UpdateOrgDTO = {maxSharedSecretLifetime?: number;blockDuplicateSecretSyncDestinations?: boolean;allowCrossProjectSecretSharing?: boolean;+ requireGatewayPools?: boolean;secretShareBrandConfig?: TSecretShareBrandConfig;};diff --git a/frontend/src/pages/cert-manager/SettingsPage/components/HsmConnectorsTab/CreateHsmConnectorWizard/CreateHsmConnectorWizard.tsx b/frontend/src/pages/cert-manager/SettingsPage/components/HsmConnectorsTab/CreateHsmConnectorWizard/CreateHsmConnectorWizard.tsxindex de07281a43..19a7a87630 100644--- a/frontend/src/pages/cert-manager/SettingsPage/components/HsmConnectorsTab/CreateHsmConnectorWizard/CreateHsmConnectorWizard.tsx+++ b/frontend/src/pages/cert-manager/SettingsPage/components/HsmConnectorsTab/CreateHsmConnectorWizard/CreateHsmConnectorWizard.tsx@@ -15,6 +15,7 @@ import {StepperList,StepperStep} from "@app/components/v3";+import { useOrganization } from "@app/context";import { useListGatewayPools } from "@app/hooks/api/gateway-pools";import { gatewaysQueryKeys } from "@app/hooks/api/gateways/queries";import { useCreateHsmConnector } from "@app/hooks/api/hsmConnectors";@@ -45,18 +46,25 @@ export const CreateHsmConnectorWizard = ({ isOpen, onOpenChange }: Props) => {const { data: gateways = [], isPending: isGatewaysLoading } = useQuery(gatewaysQueryKeys.list());const { data: pools = [], isPending: isPoolsLoading } = useListGatewayPools();const createMutation = useCreateHsmConnector();+ const { currentOrg } = useOrganization();+ const isPoolRequired = Boolean(currentOrg?.requireGatewayPools);const reachedFromOptions: ReachedFromOption[] = useMemo(() => {const gatewayOptions: ReachedFromOption[] = gateways.filter((g) => g.capabilities?.pkcs11 === true)- .map((g) => ({ value: `gateway:${g.id}`, label: g.name, group: "gateway" as const }));+ .map((g) => ({+ value: `gateway:${g.id}`,+ label: g.name,+ group: "gateway" as const,+ isDisabled: isPoolRequired+ }));const poolOptions: ReachedFromOption[] = pools.map((p) => ({value: `pool:${p.id}`,label: p.name,group: "pool" as const}));return [...gatewayOptions, ...poolOptions];- }, [gateways, pools]);+ }, [gateways, pools, isPoolRequired]);const basicsForm = useForm<BasicsForm>({resolver: zodResolver(basicsSchema),diff --git a/frontend/src/pages/cert-manager/SettingsPage/components/HsmConnectorsTab/CreateHsmConnectorWizard/HostStep.tsx b/frontend/src/pages/cert-manager/SettingsPage/components/HsmConnectorsTab/CreateHsmConnectorWizard/HostStep.tsxindex 9c3ffaacd8..86d4661fc7 100644--- a/frontend/src/pages/cert-manager/SettingsPage/components/HsmConnectorsTab/CreateHsmConnectorWizard/HostStep.tsx+++ b/frontend/src/pages/cert-manager/SettingsPage/components/HsmConnectorsTab/CreateHsmConnectorWizard/HostStep.tsx@@ -12,6 +12,7 @@ import {FieldLabel,FilterableSelect} from "@app/components/v3";+import { useOrganization } from "@app/context";import { HostForm } from "./schemas";@@ -19,6 +20,7 @@ export type ReachedFromOption = {value: string;label: string;group: "gateway" | "pool";+ isDisabled?: boolean;};type Props = {@@ -27,8 +29,18 @@ type Props = {isLoading: boolean;};+export const getReachedFromGroupLabel = (+ group: ReachedFromOption["group"],+ isPoolRequired: boolean+) => {+ if (group === "pool") return "Gateway Pools";+ return isPoolRequired ? "Gateways (your organization requires a gateway pool)" : "Gateways";+};+export const HostStep = ({ form, options, isLoading }: Props) => {const { orgId } = useParams({ strict: false });+ const { currentOrg } = useOrganization();+ const isPoolRequired = Boolean(currentOrg?.requireGatewayPools);const noOptionsMessage = useCallback(() => (@@ -71,7 +83,7 @@ export const HostStep = ({ form, options, isLoading }: Props) => {getGroupHeaderLabel={options.length > 0? (group: ReachedFromOption["group"]) =>- group === "gateway" ? "Gateways" : "Gateway Pools"+ getReachedFromGroupLabel(group, isPoolRequired): undefined}placeholder="Select a Gateway or Gateway Pool..."diff --git a/frontend/src/pages/cert-manager/SettingsPage/components/HsmConnectorsTab/EditHsmConnectorSheet.tsx b/frontend/src/pages/cert-manager/SettingsPage/components/HsmConnectorsTab/EditHsmConnectorSheet.tsxindex 28edf60258..fc0c5890d7 100644--- a/frontend/src/pages/cert-manager/SettingsPage/components/HsmConnectorsTab/EditHsmConnectorSheet.tsx+++ b/frontend/src/pages/cert-manager/SettingsPage/components/HsmConnectorsTab/EditHsmConnectorSheet.tsx@@ -22,11 +22,14 @@ import {SheetTitle,TextArea} from "@app/components/v3";+import { useOrganization } from "@app/context";import { useListGatewayPools } from "@app/hooks/api/gateway-pools";import { gatewaysQueryKeys } from "@app/hooks/api/gateways/queries";import { THsmConnector, useUpdateHsmConnector } from "@app/hooks/api/hsmConnectors";import { slugSchema } from "@app/lib/schemas";+import { getReachedFromGroupLabel } from "./CreateHsmConnectorWizard/HostStep";+const editSchema = z.object({name: slugSchema({ min: 1, max: 32, field: "Name" }),description: z.string().trim().max(256).optional(),@@ -37,7 +40,12 @@ const editSchema = z.object({});type EditForm = z.infer<typeof editSchema>;-type ReachedFromOption = { value: string; label: string; group: "gateway" | "pool" };+type ReachedFromOption = {+ value: string;+ label: string;+ group: "gateway" | "pool";+ isDisabled?: boolean;+};type Props = {connector: THsmConnector | null;@@ -50,6 +58,8 @@ export const EditHsmConnectorSheet = ({ connector, onClose }: Props) => {const { data: gateways = [] } = useQuery(gatewaysQueryKeys.list());const { data: pools = [] } = useListGatewayPools();+ const { currentOrg } = useOrganization();+ const isPoolRequired = Boolean(currentOrg?.requireGatewayPools);const reachedFromOptions: ReachedFromOption[] = useMemo(() => {const currentValue = (() => {@@ -59,7 +69,12 @@ export const EditHsmConnectorSheet = ({ connector, onClose }: Props) => {})();const gatewayOptions: ReachedFromOption[] = gateways.filter((g) => g.capabilities?.pkcs11 === true)- .map((g) => ({ value: `gateway:${g.id}`, label: g.name, group: "gateway" as const }));+ .map((g) => ({+ value: `gateway:${g.id}`,+ label: g.name,+ group: "gateway" as const,+ isDisabled: isPoolRequired && `gateway:${g.id}` !== currentValue+ }));const poolOptions: ReachedFromOption[] = pools.map((p) => ({value: `pool:${p.id}`,label: p.name,@@ -86,7 +101,7 @@ export const EditHsmConnectorSheet = ({ connector, onClose }: Props) => {];}return options;- }, [gateways, pools, connector]);+ }, [gateways, pools, connector, isPoolRequired]);const form = useForm<EditForm>({resolver: zodResolver(editSchema),@@ -251,7 +266,7 @@ export const EditHsmConnectorSheet = ({ connector, onClose }: Props) => {getGroupHeaderLabel={reachedFromOptions.length > 0? (group: ReachedFromOption["group"]) =>- group === "gateway" ? "Gateways" : "Gateway Pools"+ getReachedFromGroupLabel(group, isPoolRequired): undefined}placeholder="Select a Gateway..."diff --git a/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/GatewayTab.tsx b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/GatewayTab.tsxindex 6307f4cd72..382e1fd09c 100644--- a/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/GatewayTab.tsx+++ b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/GatewayTab.tsx@@ -83,6 +83,7 @@ import { RenameGatewayModal } from "../RenameGatewayModal";import { CreateGatewayPoolModal } from "./components/CreateGatewayPoolModal";import { GatewayDeployModal } from "./components/GatewayDeployModal";import { GatewayHealthStatus } from "./components/GatewayHealthStatus";+import { GatewayPoliciesSection } from "./components/GatewayPoliciesSection";import { GatewayPoolsContent } from "./components/GatewayPoolsContent";import { PoolDetailSheet } from "./components/PoolDetailSheet";@@ -157,355 +158,370 @@ export const GatewayTab = withPermission();return (- <Card className="mb-6">- <CardHeader>- <CardTitle>- Gateways- <DocumentationLinkBadge- href={- activeSubTab === "gateway-pools"- ? "https://infisical.com/docs/documentation/platform/gateways/gateway-pools"- : "https://infisical.com/docs/documentation/platform/gateways/overview"- }- />- </CardTitle>- <CardDescription>- {activeSubTab === "gateway-pools"- ? "Pool gateways for high availability and automatic failover"- : "Create and manage gateways that securely proxy Infisical traffic into your infrastructure"}- </CardDescription>- <CardAction>- {activeSubTab === "all-gateways" ? (- <OrgPermissionCan- I={OrgGatewayPermissionActions.CreateGateways}- a={OrgPermissionSubjects.Gateway}- >- {(isAllowed: boolean) => (- <Button- variant="org"- onClick={() => handlePopUpOpen("deployGateway")}- isDisabled={!isAllowed}- >- <PlusIcon />- Create Gateway- </Button>- )}- </OrgPermissionCan>- ) : (- <OrgPermissionCan- I={OrgGatewayPoolPermissionActions.CreateGatewayPools}- a={OrgPermissionSubjects.GatewayPool}+ <div className="mb-6 grid grid-cols-1 gap-4 lg:grid-cols-3">+ <Card className="min-w-0 lg:col-span-2">+ <CardHeader>+ <CardTitle>+ Gateways+ <DocumentationLinkBadge+ href={+ activeSubTab === "gateway-pools"+ ? "https://infisical.com/docs/documentation/platform/gateways/gateway-pools"+ : "https://infisical.com/docs/documentation/platform/gateways/overview"+ }+ />+ </CardTitle>+ <CardDescription>+ {activeSubTab === "gateway-pools"+ ? "Pool gateways for high availability and automatic failover"+ : "Create and manage gateways that securely proxy Infisical traffic into your infrastructure"}+ </CardDescription>+ <CardAction>+ {activeSubTab === "all-gateways" ? (+ <OrgPermissionCan+ I={OrgGatewayPermissionActions.CreateGateways}+ a={OrgPermissionSubjects.Gateway}+ >+ {(isAllowed: boolean) => (+ <Button+ variant="org"+ onClick={() => handlePopUpOpen("deployGateway")}+ isDisabled={!isAllowed}+ >+ <PlusIcon />+ Create Gateway+ </Button>+ )}+ </OrgPermissionCan>+ ) : (+ <OrgPermissionCan+ I={OrgGatewayPoolPermissionActions.CreateGatewayPools}+ a={OrgPermissionSubjects.GatewayPool}+ >+ {(isAllowed: boolean) => (+ <Button+ variant="org"+ onClick={() => {+ if (!subscription?.gatewayPool) {+ handlePopUpOpen("upgradePlan");+ return;+ }+ handlePopUpOpen("createPool");+ }}+ isDisabled={!isAllowed}+ >+ <PlusIcon />+ Create Pool+ </Button>+ )}+ </OrgPermissionCan>+ )}+ </CardAction>+ </CardHeader>+ <CardContent>+ <div className="mb-4 flex flex-wrap items-center justify-between gap-3">+ <Tabs+ value={activeSubTab}+ onValueChange={(value) =>+ setActiveSubTab(value as "all-gateways" | "gateway-pools")+ }>- {(isAllowed: boolean) => (- <Button- variant="org"- onClick={() => {- if (!subscription?.gatewayPool) {- handlePopUpOpen("upgradePlan");- return;- }- handlePopUpOpen("createPool");- }}- isDisabled={!isAllowed}- >- <PlusIcon />- Create Pool- </Button>- )}- </OrgPermissionCan>- )}- </CardAction>- </CardHeader>- <CardContent>- <div className="mb-4 flex flex-wrap items-center justify-between gap-3">- <Tabs- value={activeSubTab}- onValueChange={(value) => setActiveSubTab(value as "all-gateways" | "gateway-pools")}- >- <TabsList variant="filled">- <TabsTrigger value="all-gateways">All Gateways</TabsTrigger>- <TabsTrigger value="gateway-pools">Gateway Pools</TabsTrigger>- </TabsList>- </Tabs>- {activeSubTab === "all-gateways" ? (- <InputGroup className="w-1/2 min-w-64">- <InputGroupAddon align="inline-start">- <SearchIcon />- </InputGroupAddon>- <InputGroupInput- value={search}- onChange={(e) => setSearch(e.target.value)}- placeholder="Search gateway..."- />- </InputGroup>- ) : (- <InputGroup className="w-1/2 min-w-64">- <InputGroupAddon align="inline-start">- <SearchIcon />- </InputGroupAddon>- <InputGroupInput- value={poolSearch}- onChange={(e) => setPoolSearch(e.target.value)}- placeholder="Search pool..."- />- </InputGroup>- )}- </div>- {activeSubTab === "gateway-pools" ? (- <GatewayPoolsContent search={poolSearch} />- ) : (- <>- {!isGatewaysLoading && !filteredGateway?.length ? (- <Empty className="border">- <EmptyHeader>- <EmptyMedia variant="icon">- {gateways?.length ? <SearchIcon /> : <DoorClosedIcon />}- </EmptyMedia>- <EmptyTitle>- {gateways?.length- ? "No gateways match your search"- : "No gateways configured"}- </EmptyTitle>- </EmptyHeader>- </Empty>+ <TabsList variant="filled">+ <TabsTrigger value="all-gateways">All Gateways</TabsTrigger>+ <TabsTrigger value="gateway-pools">Gateway Pools</TabsTrigger>+ </TabsList>+ </Tabs>+ {activeSubTab === "all-gateways" ? (+ <InputGroup className="w-1/2 min-w-64">+ <InputGroupAddon align="inline-start">+ <SearchIcon />+ </InputGroupAddon>+ <InputGroupInput+ value={search}+ onChange={(e) => setSearch(e.target.value)}+ placeholder="Search gateway..."+ />+ </InputGroup>) : (- <Table>- <TableHeader>- <TableRow>- <TableHead>- <TableHeadLabel>Name</TableHeadLabel>- </TableHead>- {showPoolsTab && (+ <InputGroup className="w-1/2 min-w-64">+ <InputGroupAddon align="inline-start">+ <SearchIcon />+ </InputGroupAddon>+ <InputGroupInput+ value={poolSearch}+ onChange={(e) => setPoolSearch(e.target.value)}+ placeholder="Search pool..."+ />+ </InputGroup>+ )}+ </div>+ {activeSubTab === "gateway-pools" ? (+ <GatewayPoolsContent search={poolSearch} />+ ) : (+ <>+ {!isGatewaysLoading && !filteredGateway?.length ? (+ <Empty className="border">+ <EmptyHeader>+ <EmptyMedia variant="icon">+ {gateways?.length ? <SearchIcon /> : <DoorClosedIcon />}+ </EmptyMedia>+ <EmptyTitle>+ {gateways?.length+ ? "No gateways match your search"+ : "No gateways configured"}+ </EmptyTitle>+ </EmptyHeader>+ </Empty>+ ) : (+ <Table>+ <TableHeader>+ <TableRow><TableHead>- <TableHeadLabel>Pools</TableHeadLabel>+ <TableHeadLabel>Name</TableHeadLabel></TableHead>- )}- <TableHead>- <TableHeadLabel>Connected</TableHeadLabel>- </TableHead>- <TableHead>- <TableHeadLabel- trailing={- <Tooltip>- <TooltipTrigger asChild>- <InfoIcon className="size-3" />- </TooltipTrigger>- <TooltipContent>- The last known health check. Triggers every 3 minutes.- </TooltipContent>- </Tooltip>- }- >- Health Check- </TableHeadLabel>- </TableHead>- <TableHead variant="action" />- </TableRow>- </TableHeader>- <TableBody>- {isGatewaysLoading &&- ["first", "second", "third"].map((row) => (- <TableRow key={`gateway-skeleton-${row}`}>- {["name", "pools", "connected", "health", "actions"]- .slice(0, showPoolsTab ? 5 : 4)- .map((cell) => (- <TableCell key={`gateway-skeleton-${row}-${cell}`}>- <Skeleton className="h-4 w-full" />- </TableCell>- ))}- </TableRow>- ))}- {filteredGateway?.map((el) => {- return (- <TableRow- key={el.id}- className="cursor-pointer"- onClick={() =>- navigate({- to: "/organizations/$orgId/networking/gateways/$gatewayId",- params: { orgId, gatewayId: el.id }- })- }- >- <TableCell>- <div className="flex min-w-0 items-center gap-2">+ {showPoolsTab && (+ <TableHead>+ <TableHeadLabel>Pools</TableHeadLabel>+ </TableHead>+ )}+ <TableHead>+ <TableHeadLabel>Connected</TableHeadLabel>+ </TableHead>+ <TableHead>+ <TableHeadLabel+ trailing={<Tooltip><TooltipTrigger asChild>- <span className="min-w-0 flex-1 truncate">{el.name}</span>+ <InfoIcon className="size-3" /></TooltipTrigger>- <TooltipContent>{el.name}</TooltipContent>+ <TooltipContent>+ The last known health check. Triggers every 3 minutes.+ </TooltipContent></Tooltip>- </div>- </TableCell>- {showPoolsTab && (+ }+ >+ Health Check+ </TableHeadLabel>+ </TableHead>+ <TableHead variant="action" />+ </TableRow>+ </TableHeader>+ <TableBody>+ {isGatewaysLoading &&+ ["first", "second", "third"].map((row) => (+ <TableRow key={`gateway-skeleton-${row}`}>+ {["name", "pools", "connected", "health", "actions"]+ .slice(0, showPoolsTab ? 5 : 4)+ .map((cell) => (+ <TableCell key={`gateway-skeleton-${row}-${cell}`}>+ <Skeleton className="h-4 w-full" />+ </TableCell>+ ))}+ </TableRow>+ ))}+ {filteredGateway?.map((el) => {+ return (+ <TableRow+ key={el.id}+ className="cursor-pointer"+ onClick={() =>+ navigate({+ to: "/organizations/$orgId/networking/gateways/$gatewayId",+ params: { orgId, gatewayId: el.id }+ })+ }+ ><TableCell>- {(gatewayPoolMap.get(el.id) ?? []).length > 0 ? (- <OverflowBadgeList- items={gatewayPoolMap.get(el.id) ?? []}- getKey={(pool) => pool.id}- getLabel={(pool) => pool.name}- appearance="text"- onItemClick={(pool) => setSelectedPoolId(pool.id)}- maxBadgeWidth={144}- />+ <div className="flex min-w-0 items-center gap-2">+ <Tooltip>+ <TooltipTrigger asChild>+ <span className="min-w-0 flex-1 truncate">{el.name}</span>+ </TooltipTrigger>+ <TooltipContent>{el.name}</TooltipContent>+ </Tooltip>+ </div>+ </TableCell>+ {showPoolsTab && (+ <TableCell>+ {(gatewayPoolMap.get(el.id) ?? []).length > 0 ? (+ <OverflowBadgeList+ items={gatewayPoolMap.get(el.id) ?? []}+ getKey={(pool) => pool.id}+ getLabel={(pool) => pool.name}+ appearance="text"+ onItemClick={(pool) => setSelectedPoolId(pool.id)}+ maxBadgeWidth={144}+ />+ ) : (+ <span className="text-muted">—</span>+ )}+ </TableCell>+ )}+ <TableCell className="whitespace-nowrap">+ {el.connectedResourcesCount > 0 ? (+ <span>+ {el.connectedResourcesCount} resource+ {el.connectedResourcesCount !== 1 ? "s" : ""}+ </span>) : (- <span className="text-muted">—</span>+ <span className="text-muted">—</span>)}</TableCell>- )}- <TableCell className="whitespace-nowrap">- {el.connectedResourcesCount > 0 ? (- <span>- {el.connectedResourcesCount} resource- {el.connectedResourcesCount !== 1 ? "s" : ""}- </span>- ) : (- <span className="text-muted">—</span>- )}- </TableCell>- <TableCell className="whitespace-nowrap">- <GatewayHealthStatus- heartbeat={"heartbeat" in el ? el.heartbeat : null}- relayId={"relayId" in el ? el.relayId : null}- directAddress={"directAddress" in el ? el.directAddress : null}- directHeartbeat={"directHeartbeat" in el ? el.directHeartbeat : null}- heartbeatTTL={"heartbeatTTL" in el ? el.heartbeatTTL : null}- />- </TableCell>- <TableCell variant="action" onClick={(e) => e.stopPropagation()}>- <DropdownMenu>- <DropdownMenuTrigger asChild>- <IconButton aria-label="Gateway options" variant="ghost" size="sm">- <MoreHorizontalIcon />- </IconButton>- </DropdownMenuTrigger>- <DropdownMenuContent align="end">- <DropdownMenuItem- onClick={() => navigator.clipboard.writeText(el.id)}- >- <CopyIcon />- Copy ID- </DropdownMenuItem>- {(!!el.directAddress ||- !!el.relayId ||- !!el.heartbeat ||- el.heartbeatTTL !== null) && (- <DropdownMenuItem onClick={() => handleTriggerHealthCheck(el.id)}>- <HeartPulseIcon />- Trigger Health Check+ <TableCell className="whitespace-nowrap">+ <GatewayHealthStatus+ heartbeat={"heartbeat" in el ? el.heartbeat : null}+ relayId={"relayId" in el ? el.relayId : null}+ directAddress={"directAddress" in el ? el.directAddress : null}+ directHeartbeat={+ "directHeartbeat" in el ? el.directHeartbeat : null+ }+ heartbeatTTL={"heartbeatTTL" in el ? el.heartbeatTTL : null}+ />+ </TableCell>+ <TableCell variant="action" onClick={(e) => e.stopPropagation()}>+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <IconButton+ aria-label="Gateway options"+ variant="ghost"+ size="sm"+ >+ <MoreHorizontalIcon />+ </IconButton>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end">+ <DropdownMenuItem+ onClick={() => navigator.clipboard.writeText(el.id)}+ >+ <CopyIcon />+ Copy ID</DropdownMenuItem>- )}- <OrgPermissionCan- I={OrgGatewayPermissionActions.EditGateways}- a={OrgPermissionSubjects.Gateway}- >- {(isAllowed: boolean) => (- <DropdownMenuItem- isDisabled={!isAllowed}- onClick={() => handlePopUpOpen("renameGateway", el)}- >- <PencilIcon />- Rename Gateway- </DropdownMenuItem>- )}- </OrgPermissionCan>- <OrgPermissionCan- I={OrgGatewayPermissionActions.DeleteGateways}- a={OrgPermissionSubjects.Gateway}- >- {(isAllowed: boolean) => (+ {(!!el.directAddress ||+ !!el.relayId ||+ !!el.heartbeat ||+ el.heartbeatTTL !== null) && (<DropdownMenuItem- isDisabled={!isAllowed}- variant="danger"- onClick={() => handlePopUpOpen("deleteGateway", el)}+ onClick={() => handleTriggerHealthCheck(el.id)}>- <TrashIcon />- Delete Gateway+ <HeartPulseIcon />+ Trigger Health Check</DropdownMenuItem>)}- </OrgPermissionCan>- </DropdownMenuContent>- </DropdownMenu>- </TableCell>- </TableRow>- );- })}- </TableBody>- </Table>- )}- {Boolean(popUp.renameGateway.data) && (- <RenameGatewayModal- isOpen={popUp.renameGateway.isOpen}- onToggle={(isOpen) => handlePopUpToggle("renameGateway", isOpen)}- gateway={popUp.renameGateway.data as TGatewayV2}- />- )}- <AlertDialog- open={popUp.deleteGateway.isOpen}- confirmationValue={- (popUp.deleteGateway.data as { name?: string })?.name || "gateway"- }- onOpenChange={(open) => handlePopUpToggle("deleteGateway", open)}- >- <AlertDialogContent>- <AlertDialogHeader>- <AlertDialogTitle>Delete Gateway?</AlertDialogTitle>- <AlertDialogDescription>- This permanently removes the gateway from your organization.- </AlertDialogDescription>- </AlertDialogHeader>- <AlertDialogConfirmationField- inputProps={{- placeholder:- (popUp.deleteGateway.data as { name?: string })?.name || "gateway"- }}+ <OrgPermissionCan+ I={OrgGatewayPermissionActions.EditGateways}+ a={OrgPermissionSubjects.Gateway}+ >+ {(isAllowed: boolean) => (+ <DropdownMenuItem+ isDisabled={!isAllowed}+ onClick={() => handlePopUpOpen("renameGateway", el)}+ >+ <PencilIcon />+ Rename Gateway+ </DropdownMenuItem>+ )}+ </OrgPermissionCan>+ <OrgPermissionCan+ I={OrgGatewayPermissionActions.DeleteGateways}+ a={OrgPermissionSubjects.Gateway}+ >+ {(isAllowed: boolean) => (+ <DropdownMenuItem+ isDisabled={!isAllowed}+ variant="danger"+ onClick={() => handlePopUpOpen("deleteGateway", el)}+ >+ <TrashIcon />+ Delete Gateway+ </DropdownMenuItem>+ )}+ </OrgPermissionCan>+ </DropdownMenuContent>+ </DropdownMenu>+ </TableCell>+ </TableRow>+ );+ })}+ </TableBody>+ </Table>+ )}+ {Boolean(popUp.renameGateway.data) && (+ <RenameGatewayModal+ isOpen={popUp.renameGateway.isOpen}+ onToggle={(isOpen) => handlePopUpToggle("renameGateway", isOpen)}+ gateway={popUp.renameGateway.data as TGatewayV2}/>- <Alert variant="danger" appearance="borderless">- <AlertDescription>Deleting this gateway cannot be undone.</AlertDescription>- </Alert>- <AlertDialogFooter>- <AlertDialogCancel isDisabled={deleteGatewayV2ById.isPending}>- Cancel- </AlertDialogCancel>- <AlertDialogAction- variant="danger"- isPending={deleteGatewayV2ById.isPending}- onClick={(event) => {- event.preventDefault();- handleDeleteGateway();+ )}+ <AlertDialog+ open={popUp.deleteGateway.isOpen}+ confirmationValue={+ (popUp.deleteGateway.data as { name?: string })?.name || "gateway"+ }+ onOpenChange={(open) => handlePopUpToggle("deleteGateway", open)}+ >+ <AlertDialogContent>+ <AlertDialogHeader>+ <AlertDialogTitle>Delete Gateway?</AlertDialogTitle>+ <AlertDialogDescription>+ This permanently removes the gateway from your organization.+ </AlertDialogDescription>+ </AlertDialogHeader>+ <AlertDialogConfirmationField+ inputProps={{+ placeholder:+ (popUp.deleteGateway.data as { name?: string })?.name || "gateway"}}- >- Delete Gateway- </AlertDialogAction>- </AlertDialogFooter>- </AlertDialogContent>- </AlertDialog>- <GatewayDeployModal- isOpen={popUp.deployGateway.isOpen}- onOpenChange={(isOpen) => handlePopUpToggle("deployGateway", isOpen)}- />- </>- )}- </CardContent>- <PoolDetailSheet- isOpen={Boolean(selectedPoolId)}- onOpenChange={(open) => {- if (!open) setSelectedPoolId(null);- }}- pool={selectedPool}- />- <CreateGatewayPoolModal- isOpen={popUp.createPool.isOpen}- onToggle={(isOpen) => handlePopUpToggle("createPool", isOpen)}- />- <UpgradePlanModal- paywallKey="organization.gateway"- isOpen={popUp.upgradePlan.isOpen}- onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}- text="Your current plan does not include access to gateway pools. To unlock this feature, please upgrade to Infisical Enterprise plan."- isEnterpriseFeature- />- </Card>+ />+ <Alert variant="danger" appearance="borderless">+ <AlertDescription>Deleting this gateway cannot be undone.</AlertDescription>+ </Alert>+ <AlertDialogFooter>+ <AlertDialogCancel isDisabled={deleteGatewayV2ById.isPending}>+ Cancel+ </AlertDialogCancel>+ <AlertDialogAction+ variant="danger"+ isPending={deleteGatewayV2ById.isPending}+ onClick={(event) => {+ event.preventDefault();+ handleDeleteGateway();+ }}+ >+ Delete Gateway+ </AlertDialogAction>+ </AlertDialogFooter>+ </AlertDialogContent>+ </AlertDialog>+ <GatewayDeployModal+ isOpen={popUp.deployGateway.isOpen}+ onOpenChange={(isOpen) => handlePopUpToggle("deployGateway", isOpen)}+ />+ </>+ )}+ </CardContent>+ <PoolDetailSheet+ isOpen={Boolean(selectedPoolId)}+ onOpenChange={(open) => {+ if (!open) setSelectedPoolId(null);+ }}+ pool={selectedPool}+ />+ <CreateGatewayPoolModal+ isOpen={popUp.createPool.isOpen}+ onToggle={(isOpen) => handlePopUpToggle("createPool", isOpen)}+ />+ <UpgradePlanModal+ paywallKey="organization.gateway"+ isOpen={popUp.upgradePlan.isOpen}+ onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}+ text="Your current plan does not include access to gateway pools. To unlock this feature, please upgrade to Infisical Enterprise plan."+ isEnterpriseFeature+ />+ </Card>+ <div className="flex flex-col gap-4">+ <GatewayPoliciesSection />+ </div>+ </div>);},{diff --git a/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/GatewayPoliciesSection.tsx b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/GatewayPoliciesSection.tsxnew file mode 100644index 0000000000..5a8fc5bc74--- /dev/null+++ b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/GatewayPoliciesSection.tsx@@ -0,0 +1,102 @@+import { ShieldCheck } from "lucide-react";++import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";+import { createNotification } from "@app/components/notifications";+import { OrgPermissionCan } from "@app/components/permissions";+import {+ Badge,+ Card,+ CardContent,+ CardDescription,+ CardHeader,+ CardTitle,+ Field,+ FieldContent,+ FieldDescription,+ FieldGroup,+ FieldTitle,+ Toggle+} from "@app/components/v3";+import {+ OrgPermissionActions,+ OrgPermissionSubjects,+ useOrganization,+ useSubscription+} from "@app/context";+import { usePopUp } from "@app/hooks";+import { useUpdateOrg } from "@app/hooks/api/organization/queries";++export const GatewayPoliciesSection = () => {+ const { currentOrg } = useOrganization();+ const { subscription } = useSubscription();+ const { mutateAsync: updateOrg, isPending } = useUpdateOrg();+ const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp(["upgradePlan"] as const);++ const isPoolRequired = Boolean(currentOrg?.requireGatewayPools);++ const handleToggle = async (state: boolean) => {+ if (!currentOrg?.id) return;++ if (state && !subscription?.gatewayPool) {+ handlePopUpOpen("upgradePlan");+ return;+ }++ await updateOrg({ orgId: currentOrg.id, requireGatewayPools: state });++ createNotification({+ text: state+ ? "Resources in this organization now require a gateway pool"+ : "Resources in this organization can now use individual gateways",+ type: "success"+ });+ };++ return (+ <>+ <Card>+ <CardHeader className="border-b">+ <CardTitle>+ <ShieldCheck className="size-4 text-accent" />+ Enforcement+ {isPoolRequired && <Badge variant="success">Active</Badge>}+ </CardTitle>+ <CardDescription>+ Control how resources in your organization use gateways.+ </CardDescription>+ </CardHeader>+ <CardContent>+ <FieldGroup>+ <Field orientation="horizontal">+ <FieldContent>+ <FieldTitle>Require Gateway Pools</FieldTitle>+ <FieldDescription>+ Only allow resources to connect through a gateway pool, not an individual gateway.+ Resources already using an individual gateway keep working.+ </FieldDescription>+ </FieldContent>+ <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Settings}>+ {(isAllowed) => (+ <Toggle+ id="require-gateway-pools"+ variant="org"+ checked={isPoolRequired}+ onCheckedChange={handleToggle}+ disabled={!isAllowed || isPending}+ />+ )}+ </OrgPermissionCan>+ </Field>+ </FieldGroup>+ </CardContent>+ </Card>+ <UpgradePlanModal+ paywallKey="organization.gateway.require-pools"+ isOpen={popUp.upgradePlan.isOpen}+ onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}+ text="Your current plan does not include access to gateway pools. To unlock this feature, please upgrade to Infisical Enterprise plan."+ isEnterpriseFeature+ />+ </>+ );+};diff --git a/frontend/src/pages/organization/NetworkingPage/components/NetworkingAuthMethodForm.tsx b/frontend/src/pages/organization/NetworkingPage/components/NetworkingAuthMethodForm.tsxindex d114a38723..6394165863 100644--- a/frontend/src/pages/organization/NetworkingPage/components/NetworkingAuthMethodForm.tsx+++ b/frontend/src/pages/organization/NetworkingPage/components/NetworkingAuthMethodForm.tsx@@ -8,6 +8,7 @@ import {Button,Field,FieldContent,+ FieldDescription,FieldError,FieldLabel,FilterableSelect,@@ -246,7 +247,7 @@ export const NetworkingAuthMethodForm = ({currentGatewayId,onUpdate}: Props) => {- const { isSubOrganization } = useOrganization();+ const { isSubOrganization, currentOrg } = useOrganization();const initialMethod: NetworkingAuthMethod = currentMethod.method;const initialAws = currentMethod.method === "aws" ? currentMethod.config : undefined;const initialGcp = currentMethod.method === "gcp" ? currentMethod.config : undefined;@@ -321,6 +322,15 @@ export const NetworkingAuthMethodForm = ({const gatewayPoolId = watch("gatewayPoolId");const isProxied = Boolean(gatewayId || gatewayPoolId);const isGatewayReviewer = tokenReviewMode === "gateway";+ // Under the org's pool requirement the backend only accepts a new individual gateway as the+ // reviewer, since a pool can't perform the review. The gateway the config already had is kept as-is.+ const isPoolRequired = Boolean(currentOrg?.requireGatewayPools);+ const isNewIndividualGateway = Boolean(gatewayId) && gatewayId !== initialKubernetes?.gatewayId;+ const mustUseGatewayReviewer = isPoolRequired && isNewIndividualGateway;+ const reviewModeOptions = REVIEW_MODE_OPTIONS.map((option) => ({+ ...option,+ isDisabled: option.value === "api" && mustUseGatewayReviewer+ }));const isTokenReviewerJwtConfigured =Boolean(initialKubernetes?.hasTokenReviewerJwt) && !watch("resetTokenReviewerJwt");@@ -572,11 +582,26 @@ export const NetworkingAuthMethodForm = ({if (!next.gatewayId && !next.gatewayPoolId) {setValue("tokenReviewMode", "api", { shouldDirty: true });}+ if (+ isPoolRequired &&+ next.gatewayId &&+ next.gatewayId !== initialKubernetes?.gatewayId+ ) {+ setValue("tokenReviewMode", "gateway", { shouldDirty: true });+ }}}isDisabled={isDisabled || isSaving}isError={Boolean(error)}excludeGatewayId={currentGatewayId}+ allowIndividualGateways/>+ {isPoolRequired && (+ <FieldDescription>+ Your organization requires gateway pools. You can still select an individual+ gateway here, but only with Gateway as Reviewer, because a pool can't+ perform the review.+ </FieldDescription>+ )}<FieldError errors={[error]} /></FieldContent></Field>@@ -604,12 +629,12 @@ export const NetworkingAuthMethodForm = ({</FieldLabel><FieldContent><FilterableSelect- value={REVIEW_MODE_OPTIONS.find((option) => option.value === field.value)}+ value={reviewModeOptions.find((option) => option.value === field.value)}onChange={(option) => {const next = option as { value: "api" | "gateway" } | null;if (next) field.onChange(next.value);}}- options={REVIEW_MODE_OPTIONS}+ options={reviewModeOptions}isDisabled={isDisabled || isSaving}isSearchable={false}isClearable={false}