Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

misc: addressed feedback

Sheen Capadnganf3d09218e093
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.ts
index d06ad282f0..94d9aa182e 100644
--- 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.ts
@@ -38,6 +38,17 @@ describe("assertIndividualGatewayAllowed", () => {
).rejects.toBeInstanceOf(BadRequestError);
});
+ test("names the template when the gateway was copied from one, so the user knows what to fix", async () => {
+ await expect(
+ assertIndividualGatewayAllowed({
+ orgDAL: orgDALWith(true),
+ orgId: "org-1",
+ gatewayId: "gw-1",
+ inheritedFrom: "Auth template 'prod-k8s'"
+ })
+ ).rejects.toThrow("Auth template 'prod-k8s' uses an individual gateway");
+ });
+
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();
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.ts
index 74c8043561..78020f9ea9 100644
--- a/backend/src/ee/services/gateway-pool/gateway-pool-policy-fns.ts
+++ b/backend/src/ee/services/gateway-pool/gateway-pool-policy-fns.ts
@@ -8,16 +8,24 @@ export const assertIndividualGatewayAllowed = async ({
orgDAL,
orgId,
gatewayId,
- previousGatewayId
+ previousGatewayId,
+ inheritedFrom
}: {
orgDAL: Pick<TOrgDALFactory, "findById">;
orgId: string;
gatewayId: string | null | undefined;
previousGatewayId?: string | null;
+ // Names what the gateway was copied from (such as a template), so the error points at what to fix.
+ inheritedFrom?: string;
}) => {
if (!gatewayId || gatewayId === previousGatewayId) return;
const org = await orgDAL.findById(orgId);
+ if (org?.requireGatewayPools && inheritedFrom) {
+ throw new BadRequestError({
+ message: `${inheritedFrom} uses an individual gateway, but your organization requires resources to connect through a gateway pool. Update it to use a gateway pool, or ask an organization admin to turn off Require Gateway Pools under Organization Settings > Networking.`
+ });
+ }
if (org?.requireGatewayPools) {
throw new BadRequestError({
message:
diff --git a/backend/src/ee/services/pam-account/pam-account-service.ts b/backend/src/ee/services/pam-account/pam-account-service.ts
index 1025f98b2c..140c272111 100644
--- a/backend/src/ee/services/pam-account/pam-account-service.ts
+++ b/backend/src/ee/services/pam-account/pam-account-service.ts
@@ -723,13 +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,
- template.gatewayId
+ undefined,
+ gatewayId ? undefined : `Account template '${template.name}'`
);
await validateRecordingConnection(deps, recordingConnectionId, ctx);
@@ -914,14 +914,13 @@ 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,
- isInheritedGateway ? effectiveGatewayId : (existing.gatewayId ?? existing.templateGatewayId)
+ existing.gatewayId ?? existing.templateGatewayId,
+ !nextGatewayId && template ? `Account template '${template.name}'` : undefined
);
}
await validateRecordingConnection(deps, recordingConnectionId, ctx);
diff --git a/backend/src/ee/services/pam/pam-validators.ts b/backend/src/ee/services/pam/pam-validators.ts
index 90a714be3c..59851f42c4 100644
--- a/backend/src/ee/services/pam/pam-validators.ts
+++ b/backend/src/ee/services/pam/pam-validators.ts
@@ -44,7 +44,8 @@ export const validateGatewayAttachment = async (
gwId: string | null | undefined,
poolId: string | null | undefined,
ctx: TActorContext,
- previousGatewayId?: string | null
+ previousGatewayId?: string | null,
+ inheritedFrom?: string
) => {
if (gwId) {
const gw = await gatewayV2DAL.findOne({ id: gwId, orgId: ctx.actorOrgId });
@@ -65,7 +66,13 @@ export const validateGatewayAttachment = async (
OrgPermissionSubjects.Gateway
);
- await assertIndividualGatewayAllowed({ orgDAL, orgId: ctx.actorOrgId, gatewayId: gwId, previousGatewayId });
+ await assertIndividualGatewayAllowed({
+ orgDAL,
+ orgId: ctx.actorOrgId,
+ gatewayId: gwId,
+ previousGatewayId,
+ inheritedFrom
+ });
}
if (poolId) {
await gatewayPoolService.resolveAttachableGatewayFromPool({
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.ts
index 4d5a843ff0..d4ac428eba 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
@@ -1018,8 +1018,14 @@ export const identityKubernetesAuthServiceFactory = ({
OrgPermissionGatewayActions.AttachGateways,
OrgPermissionSubjects.Gateway
);
- await assertIndividualGatewayAllowed({ orgDAL, orgId: identityMembershipOrg.scopeOrgId, gatewayId });
}
+ // A template's gateway can predate the org's pool requirement, so it is checked here as well.
+ await assertIndividualGatewayAllowed({
+ orgDAL,
+ orgId: identityMembershipOrg.scopeOrgId,
+ gatewayId,
+ inheritedFrom: template ? `Auth template '${template.name}'` : undefined
+ });
if (tokenReviewMode === IdentityKubernetesAuthTokenReviewMode.Gateway) {
const gatewayExecutor = $createGatewayValidationRequest(gatewayId);
@@ -1413,13 +1419,15 @@ export const identityKubernetesAuthServiceFactory = ({
OrgPermissionGatewayActions.AttachGateways,
OrgPermissionSubjects.Gateway
);
- await assertIndividualGatewayAllowed({
- orgDAL,
- orgId: identityMembershipOrg.scopeOrgId,
- gatewayId,
- previousGatewayId: identityKubernetesAuth.gatewayV2Id
- });
}
+ // A template's gateway can predate the org's pool requirement, so it is checked here as well.
+ await assertIndividualGatewayAllowed({
+ orgDAL,
+ orgId: identityMembershipOrg.scopeOrgId,
+ gatewayId,
+ previousGatewayId: identityKubernetesAuth.gatewayV2Id,
+ inheritedFrom: template ? `Auth template '${template.name}'` : undefined
+ });
}
// Handle gateway pool permission check
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.tsx
index 19a7a87630..840dbd6fdd 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
@@ -63,6 +63,9 @@ export const CreateHsmConnectorWizard = ({ isOpen, onOpenChange }: Props) => {
label: p.name,
group: "pool" as const
}));
+ // With no pool to pick, a list of only disabled gateways would hide the setup guidance, so the
+ // select shows its empty-state message instead.
+ if (isPoolRequired && poolOptions.length === 0) return [];
return [...gatewayOptions, ...poolOptions];
}, [gateways, pools, isPoolRequired]);
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.tsx
index 86d4661fc7..213237636e 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
@@ -45,17 +45,21 @@ export const HostStep = ({ form, options, isLoading }: Props) => {
const noOptionsMessage = useCallback(
() => (
<div className="space-y-1 py-2">
- <p>No Gateways connected to an HSM yet.</p>
+ <p>
+ {isPoolRequired
+ ? "Your organization requires a gateway pool, but none exist yet."
+ : "No Gateways connected to an HSM yet."}
+ </p>
<Link
to="/organizations/$orgId/networking"
params={{ orgId: orgId ?? "" }}
className="underline hover:text-foreground"
>
- Configure one in Networking
+ {isPoolRequired ? "Create one in Networking" : "Configure one in Networking"}
</Link>
</div>
),
- [orgId]
+ [orgId, isPoolRequired]
);
return (