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
misc: addressed feedback
Sheen Capadnganb7b75d201184
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 cdd027c8fd..8c2faba613 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@@ -221,7 +221,9 @@ export const pamAccountTemplateServiceFactory = (deps: TPamAccountTemplateServicthrow new NotFoundError({ message: `Account template with ID '${templateId}' not found` });}- await validateGatewayAttachment(deps, gatewayId, gatewayPoolId, ctx, existing.gatewayId);+ await validateGatewayAttachment(deps, gatewayId, gatewayPoolId, ctx, {+ previousGatewayId: existing.gatewayId+ });await validateRecordingConnection(deps, recordingConnectionId, ctx);const validatedPolicies = validateTemplatePolicies(existing.type, policies);diff --git a/backend/src/ee/services/pam-account/pam-account-service.ts b/backend/src/ee/services/pam-account/pam-account-service.tsindex 140c272111..5d1d794d0a 100644--- a/backend/src/ee/services/pam-account/pam-account-service.ts+++ b/backend/src/ee/services/pam-account/pam-account-service.ts@@ -728,8 +728,7 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>effectiveGatewayId,effectiveGatewayId ? null : (gatewayPoolId ?? template.gatewayPoolId),ctx,- undefined,- gatewayId ? undefined : `Account template '${template.name}'`+ { inheritedFrom: gatewayId ? undefined : `Account template '${template.name}'` });await validateRecordingConnection(deps, recordingConnectionId, ctx);@@ -919,8 +918,10 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>effectiveGatewayId,effectiveGatewayId ? null : (nextGatewayPoolId ?? nextTemplateGatewayPoolId),ctx,- existing.gatewayId ?? existing.templateGatewayId,- !nextGatewayId && template ? `Account template '${template.name}'` : undefined+ {+ previousGatewayId: existing.gatewayId ?? existing.templateGatewayId,+ inheritedFrom: nextGatewayId ? undefined : `Account template '${template?.name ?? existing.templateName}'`+ });}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 a986ed119b..a9f862680b 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@@ -377,7 +377,9 @@ export const pamDiscoverySourceServiceFactory = (deps: TPamDiscoverySourceServic}if (gatewayId !== undefined || gatewayPoolId !== undefined) {- await validateGatewayAttachment(deps, gatewayId, gatewayPoolId, ctx, source.gatewayId);+ await validateGatewayAttachment(deps, gatewayId, gatewayPoolId, ctx, {+ previousGatewayId: source.gatewayId+ });}const discoveryConfiguration =diff --git a/backend/src/ee/services/pam/pam-validators.ts b/backend/src/ee/services/pam/pam-validators.tsindex 59851f42c4..c36d7901f7 100644--- a/backend/src/ee/services/pam/pam-validators.ts+++ b/backend/src/ee/services/pam/pam-validators.ts@@ -44,8 +44,8 @@ export const validateGatewayAttachment = async (gwId: string | null | undefined,poolId: string | null | undefined,ctx: TActorContext,- previousGatewayId?: string | null,- inheritedFrom?: string+ // Feeds the org's gateway pool requirement; see assertIndividualGatewayAllowed.+ { previousGatewayId, inheritedFrom }: { previousGatewayId?: string | null; inheritedFrom?: string } = {}) => {if (gwId) {const gw = await gatewayV2DAL.findOne({ id: gwId, orgId: ctx.actorOrgId });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 dc20f0d8dc..1d5c24741c 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@@ -907,7 +907,13 @@ export const resourceAuthMethodServiceFactory = ({}await $assertProxyNotSelf(resource, authMethod);- await $assertCanAttachProxy(actor, authMethod, stored?.gatewayV2Id);+ // A reviewer gateway was only allowed through the exemption, so it can't be carried into another+ // review mode as if it were a kept attachment.+ await $assertCanAttachProxy(+ actor,+ authMethod,+ stored?.tokenReviewMode === KubernetesTokenReviewMode.Gateway ? undefined : stored?.gatewayV2Id+ );const validation = await $buildKubernetesExecutor({diff --git a/frontend/src/components/v3/platform/GatewayPicker/GatewayPicker.tsx b/frontend/src/components/v3/platform/GatewayPicker/GatewayPicker.tsxindex de428296fc..9d1cc52dd0 100644--- a/frontend/src/components/v3/platform/GatewayPicker/GatewayPicker.tsx+++ b/frontend/src/components/v3/platform/GatewayPicker/GatewayPicker.tsx@@ -10,6 +10,7 @@ import {} from "@app/context/OrgPermissionContext/types";import { gatewayPoolsQueryKeys } from "@app/hooks/api/gateway-pools/queries";import { gatewaysQueryKeys } from "@app/hooks/api/gateways/queries";+import { TGatewayV2 } from "@app/hooks/api/gateways-v2/types";import { isGatewayHealthy } from "@app/hooks/api/gateways-v2/utils";import { PoolHealthBadge } from "@app/pages/organization/NetworkingPage/components/GatewayTab/components/PoolHealthBadge";@@ -41,6 +42,9 @@ type Props = {excludeGatewayId?: string;// For callers where the backend exempts an individual gateway from the org's pool requirement.allowIndividualGateways?: boolean;+ // Limits the individual gateways to those that can serve the caller, such as HSM-capable ones.+ // The currently selected gateway is always kept so an existing value stays visible.+ filterGateway?: (gateway: TGatewayV2) => boolean;};const SectionLabel = ({ children }: { children: React.ReactNode }) => (@@ -60,7 +64,8 @@ export const GatewayPicker = ({noGatewayLabel = "Internet Gateway",noGatewayIcon: NoGatewayIcon = GlobeIcon,excludeGatewayId,- allowIndividualGateways+ allowIndividualGateways,+ filterGateway}: Props) => {const { subscription } = useSubscription();const { currentOrg } = useOrganization();@@ -71,6 +76,12 @@ export const GatewayPicker = ({const showPools = subscription?.gatewayPool || Boolean(currentOrg?.requireGatewayPools);const { data: gateways, isPending: isGatewaysLoading } = useQuery(gatewaysQueryKeys.list());+ // The list above drops gateways that never connected. A saved value can still point at one, so it+ // is looked up in the unfiltered list (same cached query) to keep the selection visible.+ const { data: allGateways } = useQuery({+ ...gatewaysQueryKeys.listAll(),+ enabled: Boolean(value.gatewayId)+ });const { data: pools, isPending: isPoolsLoading } = useQuery({...gatewayPoolsQueryKeys.list(),enabled: Boolean(showPools)@@ -95,7 +106,19 @@ export const GatewayPicker = ({}};- const v2Gateways = gateways?.filter((g) => g.id !== excludeGatewayId) ?? [];+ const listedGateways =+ gateways?.filter(+ (g) =>+ g.id !== excludeGatewayId &&+ (!filterGateway || filterGateway(g) || g.id === value.gatewayId)+ ) ?? [];+ const unlistedSelectedGateway =+ value.gatewayId && !listedGateways.some((g) => g.id === value.gatewayId)+ ? allGateways?.find((g) => g.id === value.gatewayId)+ : undefined;+ const v2Gateways = unlistedSelectedGateway+ ? [unlistedSelectedGateway, ...listedGateways]+ : listedGateways;const isOnline = (gw: (typeof v2Gateways)[number]) => isGatewayHealthy(gw);@@ -202,6 +225,7 @@ export const GatewayPicker = ({<Linkto="/organizations/$orgId/networking"params={{ orgId: currentOrg.id }}+ search={{ selectedTab: "gateways", gatewayView: "gateway-pools" }}target="_blank"className="text-foreground underline underline-offset-2 hover:text-info">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 840dbd6fdd..e92d8c53fc 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@@ -1,7 +1,6 @@-import { useMemo, useState } from "react";+import { useState } from "react";import { useForm } from "react-hook-form";import { zodResolver } from "@hookform/resolvers/zod";-import { useQuery } from "@tanstack/react-query";import { ShieldCheckIcon } from "lucide-react";import { createNotification } from "@app/components/notifications";@@ -15,14 +14,11 @@ 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";import { AccessStep } from "./AccessStep";import { BasicsStep } from "./BasicsStep";-import { HostStep, ReachedFromOption } from "./HostStep";+import { HostStep } from "./HostStep";import {AccessForm,accessSchema,@@ -43,31 +39,7 @@ export const CreateHsmConnectorWizard = ({ isOpen, onOpenChange }: Props) => {const [state, setState] = useState<WizardState>(INITIAL_WIZARD_STATE);const [submitting, setSubmitting] = useState(false);- 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,- isDisabled: isPoolRequired- }));- const poolOptions: ReachedFromOption[] = pools.map((p) => ({- value: `pool:${p.id}`,- 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]);const basicsForm = useForm<BasicsForm>({resolver: zodResolver(basicsSchema),@@ -228,13 +200,7 @@ export const CreateHsmConnectorWizard = ({ isOpen, onOpenChange }: Props) => {</div>{step === 0 && <BasicsStep form={basicsForm} />}- {step === 1 && (- <HostStep- form={hostForm}- options={reachedFromOptions}- isLoading={isGatewaysLoading || isPoolsLoading}- />- )}+ {step === 1 && <HostStep form={hostForm} />}{step === 2 && <AccessStep form={accessForm} />}</div>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 213237636e..c8729981cb 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@@ -1,5 +1,5 @@-import { useCallback } from "react";import { Controller, useForm } from "react-hook-form";+import { useQuery } from "@tanstack/react-query";import { Link, useParams } from "@tanstack/react-router";import { ServerIcon } from "lucide-react";@@ -9,58 +9,58 @@ import {FieldDescription,FieldError,FieldGroup,- FieldLabel,- FilterableSelect+ FieldLabel} from "@app/components/v3";-import { useOrganization } from "@app/context";+import { GatewayPicker } from "@app/components/v3/platform/GatewayPicker/GatewayPicker";+import { useOrganization, useSubscription } from "@app/context";+import { gatewayPoolsQueryKeys } from "@app/hooks/api/gateway-pools/queries";+import { gatewaysQueryKeys } from "@app/hooks/api/gateways/queries";+import { TGatewayV2 } from "@app/hooks/api/gateways-v2/types";import { HostForm } from "./schemas";-export type ReachedFromOption = {- value: string;- label: string;- group: "gateway" | "pool";- isDisabled?: boolean;-};-type Props = {form: ReturnType<typeof useForm<HostForm>>;- options: ReachedFromOption[];- 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 isHsmCapableGateway = (gateway: TGatewayV2) => gateway.capabilities?.pkcs11 === true;++// The HSM forms store the route as "gateway:<id>" or "pool:<id>"; the picker works with the two ids.+export const toGatewayPickerValue = (reachedFrom: string) => {+ const [kind, id] = reachedFrom.split(":");+ return {+ gatewayId: kind === "gateway" && id ? id : null,+ gatewayPoolId: kind === "pool" && id ? id : null+ };+};++export const fromGatewayPickerValue = ({+ gatewayId,+ gatewayPoolId+}: {+ gatewayId: string | null;+ gatewayPoolId: string | null;+}) => {+ if (gatewayPoolId) return `pool:${gatewayPoolId}`;+ if (gatewayId) return `gateway:${gatewayId}`;+ return "";};-export const HostStep = ({ form, options, isLoading }: Props) => {+export const HostStep = ({ form }: Props) => {const { orgId } = useParams({ strict: false });const { currentOrg } = useOrganization();+ const { subscription } = useSubscription();const isPoolRequired = Boolean(currentOrg?.requireGatewayPools);+ const showPools = Boolean(subscription?.gatewayPool) || isPoolRequired;- const noOptionsMessage = useCallback(- () => (- <div className="space-y-1 py-2">- <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"- >- {isPoolRequired ? "Create one in Networking" : "Configure one in Networking"}- </Link>- </div>- ),- [orgId, isPoolRequired]- );+ const { data: gateways = [], isPending: isGatewaysLoading } = useQuery(gatewaysQueryKeys.list());+ const { data: pools = [], isPending: isPoolsLoading } = useQuery({+ ...gatewayPoolsQueryKeys.list(),+ enabled: showPools+ });+ const isLoading = isGatewaysLoading || (showPools && isPoolsLoading);+ const hasPools = showPools && pools.length > 0;+ const hasUsableRoute = isPoolRequired ? hasPools : hasPools || gateways.some(isHsmCapableGateway);return (<FieldGroup>@@ -73,25 +73,12 @@ export const HostStep = ({ form, options, isLoading }: Props) => {Gateway <span className="text-danger">*</span></FieldLabel><FieldContent>- <FilterableSelect<ReachedFromOption>- isLoading={isLoading}- options={options}- value={options.find((o) => o.value === field.value) ?? null}- onChange={(selected) => {- const opt = selected as ReachedFromOption | null;- field.onChange(opt?.value ?? "");- }}- getOptionLabel={(opt) => opt.label}- getOptionValue={(opt) => opt.value}- groupBy={options.length > 0 ? "group" : undefined}- getGroupHeaderLabel={- options.length > 0- ? (group: ReachedFromOption["group"]) =>- getReachedFromGroupLabel(group, isPoolRequired)- : undefined- }+ <GatewayPicker+ isRequired+ value={toGatewayPickerValue(field.value)}+ onChange={(next) => field.onChange(fromGatewayPickerValue(next))}+ filterGateway={isHsmCapableGateway}placeholder="Select a Gateway or Gateway Pool..."- noOptionsMessage={noOptionsMessage}isError={Boolean(error)}/><FieldDescription>@@ -113,26 +100,47 @@ export const HostStep = ({ form, options, isLoading }: Props) => {)}/>- {!isLoading && options.length === 0 && (+ {!isLoading && !hasUsableRoute && (<div className="rounded-md border border-border bg-surface-raised p-4"><div className="flex items-start gap-3"><ServerIcon className="mt-0.5 size-4 shrink-0 text-muted" />- <div className="min-w-0 flex-1 space-y-2 text-sm">- <p className="font-medium text-foreground">No Gateways are connected to an HSM yet</p>- <p className="text-muted">- A Gateway with PKCS#11 support must be running on a machine that can reach your HSM.- This is set up by someone with network and infrastructure access.{" "}- <a- href="https://infisical.com/docs/documentation/platform/pki/settings/hsm-connectors"- target="_blank"- rel="noreferrer"- className="text-project hover:underline"- >- Read the HSM Connectors setup guide- </a>- .- </p>- </div>+ {isPoolRequired ? (+ <div className="min-w-0 flex-1 space-y-2 text-sm">+ <p className="font-medium text-foreground">No gateway pools exist yet</p>+ <p className="text-muted">+ Your organization requires HSM Connectors to connect through a gateway pool. Add+ Gateways with PKCS#11 support to a pool, then come back to select it.{" "}+ <Link+ to="/organizations/$orgId/networking"+ params={{ orgId: orgId ?? "" }}+ search={{ selectedTab: "gateways", gatewayView: "gateway-pools" }}+ className="text-project hover:underline"+ >+ Create a pool in Networking+ </Link>+ .+ </p>+ </div>+ ) : (+ <div className="min-w-0 flex-1 space-y-2 text-sm">+ <p className="font-medium text-foreground">+ No Gateways are connected to an HSM yet+ </p>+ <p className="text-muted">+ A Gateway with PKCS#11 support must be running on a machine that can reach your+ HSM. This is set up by someone with network and infrastructure access.{" "}+ <a+ href="https://infisical.com/docs/documentation/platform/pki/settings/hsm-connectors"+ target="_blank"+ rel="noreferrer"+ className="text-project hover:underline"+ >+ Read the HSM Connectors setup guide+ </a>+ .+ </p>+ </div>+ )}</div></div>)}diff --git a/frontend/src/pages/cert-manager/SettingsPage/components/HsmConnectorsTab/EditHsmConnectorSheet.tsx b/frontend/src/pages/cert-manager/SettingsPage/components/HsmConnectorsTab/EditHsmConnectorSheet.tsxindex fc0c5890d7..5f591d5489 100644--- a/frontend/src/pages/cert-manager/SettingsPage/components/HsmConnectorsTab/EditHsmConnectorSheet.tsx+++ b/frontend/src/pages/cert-manager/SettingsPage/components/HsmConnectorsTab/EditHsmConnectorSheet.tsx@@ -1,7 +1,6 @@import { useEffect, useMemo } from "react";import { Controller, useForm } from "react-hook-form";import { zodResolver } from "@hookform/resolvers/zod";-import { useQuery } from "@tanstack/react-query";import { ShieldCheckIcon } from "lucide-react";import { z } from "zod";@@ -14,7 +13,6 @@ import {FieldError,FieldGroup,FieldLabel,- FilterableSelect,Input,Sheet,SheetContent,@@ -22,13 +20,15 @@ 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 { GatewayPicker } from "@app/components/v3/platform/GatewayPicker/GatewayPicker";import { THsmConnector, useUpdateHsmConnector } from "@app/hooks/api/hsmConnectors";import { slugSchema } from "@app/lib/schemas";-import { getReachedFromGroupLabel } from "./CreateHsmConnectorWizard/HostStep";+import {+ fromGatewayPickerValue,+ isHsmCapableGateway,+ toGatewayPickerValue+} from "./CreateHsmConnectorWizard/HostStep";const editSchema = z.object({name: slugSchema({ min: 1, max: 32, field: "Name" }),@@ -40,13 +40,6 @@ const editSchema = z.object({});type EditForm = z.infer<typeof editSchema>;-type ReachedFromOption = {- value: string;- label: string;- group: "gateway" | "pool";- isDisabled?: boolean;-};-type Props = {connector: THsmConnector | null;onClose: () => void;@@ -56,53 +49,6 @@ export const EditHsmConnectorSheet = ({ connector, onClose }: Props) => {const isOpen = Boolean(connector);const updateMutation = useUpdateHsmConnector();- const { data: gateways = [] } = useQuery(gatewaysQueryKeys.list());- const { data: pools = [] } = useListGatewayPools();- const { currentOrg } = useOrganization();- const isPoolRequired = Boolean(currentOrg?.requireGatewayPools);-- const reachedFromOptions: ReachedFromOption[] = useMemo(() => {- const currentValue = (() => {- if (connector?.gatewayId) return `gateway:${connector.gatewayId}`;- if (connector?.gatewayPoolId) return `pool:${connector.gatewayPoolId}`;- return "";- })();- const gatewayOptions: ReachedFromOption[] = gateways- .filter((g) => g.capabilities?.pkcs11 === true)- .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,- group: "pool" as const- }));- const options = [...gatewayOptions, ...poolOptions];- const currentIncluded = options.some((o) => o.value === currentValue);- if (!currentIncluded && connector && currentValue) {- let label = "";- if (connector.gatewayId) {- const g = gateways.find((x) => x.id === connector.gatewayId);- label = g?.name ? `${g.name} (offline)` : `${connector.gatewayId} (offline)`;- } else if (connector.gatewayPoolId) {- const p = pools.find((x) => x.id === connector.gatewayPoolId);- label = p?.name ?? connector.gatewayPoolId;- }- return [- {- value: currentValue,- label,- group: connector.gatewayId ? ("gateway" as const) : ("pool" as const)- },- ...options- ];- }- return options;- }, [gateways, pools, connector, isPoolRequired]);-const form = useForm<EditForm>({resolver: zodResolver(editSchema),defaultValues: {@@ -253,24 +199,12 @@ export const EditHsmConnectorSheet = ({ connector, onClose }: Props) => {Reached from <span className="text-danger">*</span></FieldLabel><FieldContent>- <FilterableSelect<ReachedFromOption>- options={reachedFromOptions}- value={reachedFromOptions.find((o) => o.value === field.value) ?? null}- onChange={(selected) => {- const opt = selected as ReachedFromOption | null;- field.onChange(opt?.value ?? "");- }}- getOptionLabel={(opt) => opt.label}- getOptionValue={(opt) => opt.value}- groupBy={reachedFromOptions.length > 0 ? "group" : undefined}- getGroupHeaderLabel={- reachedFromOptions.length > 0- ? (group: ReachedFromOption["group"]) =>- getReachedFromGroupLabel(group, isPoolRequired)- : undefined- }+ <GatewayPicker+ isRequired+ value={toGatewayPickerValue(field.value)}+ onChange={(next) => field.onChange(fromGatewayPickerValue(next))}+ filterGateway={isHsmCapableGateway}placeholder="Select a Gateway..."- noOptionsMessage={() => "No PKCS#11-enabled Gateways found."}isError={Boolean(error)}/><FieldDescription>diff --git a/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/GatewayTab.tsx b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/GatewayTab.tsxindex 382e1fd09c..72826fba31 100644--- a/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/GatewayTab.tsx+++ b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/GatewayTab.tsx@@ -1,6 +1,6 @@import { useState } from "react";import { useQuery } from "@tanstack/react-query";-import { useNavigate } from "@tanstack/react-router";+import { useNavigate, useSearch } from "@tanstack/react-router";import {CopyIcon,DoorClosedIcon,@@ -64,6 +64,7 @@ import {TooltipContent,TooltipTrigger} from "@app/components/v3";+import { ROUTE_PATHS } from "@app/const/routes";import { useOrganization } from "@app/context";import {OrgGatewayPermissionActions,@@ -92,8 +93,12 @@ export const GatewayTab = withPermission(const navigate = useNavigate();const { currentOrg } = useOrganization();const orgId = currentOrg?.id || "";+ const initialSubTab = useSearch({+ from: ROUTE_PATHS.Organization.NetworkingPage.id,+ select: (el) => el.gatewayView+ });const [activeSubTab, setActiveSubTab] = useState<"all-gateways" | "gateway-pools">(- "all-gateways"+ initialSubTab ?? "all-gateways");const { subscription } = useSubscription();const showPoolsTab = subscription?.gatewayPool;diff --git a/frontend/src/pages/organization/NetworkingPage/components/NetworkingAuthMethodForm.tsx b/frontend/src/pages/organization/NetworkingPage/components/NetworkingAuthMethodForm.tsxindex 6394165863..1d4f1192bf 100644--- a/frontend/src/pages/organization/NetworkingPage/components/NetworkingAuthMethodForm.tsx+++ b/frontend/src/pages/organization/NetworkingPage/components/NetworkingAuthMethodForm.tsx@@ -283,7 +283,8 @@ export const NetworkingAuthMethodForm = ({watch,reset,setValue,- formState: { isSubmitting, isDirty }+ trigger,+ formState: { isSubmitting, isDirty, isSubmitted }} = useForm<FormData>({resolver: zodResolver(schema),defaultValues@@ -323,10 +324,12 @@ export const NetworkingAuthMethodForm = ({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.+ // reviewer, since a pool can't perform the review. A gateway the config already had in API mode is+ // kept as-is; one saved as the reviewer was only allowed for that mode, so it stays in it.const isPoolRequired = Boolean(currentOrg?.requireGatewayPools);- const isNewIndividualGateway = Boolean(gatewayId) && gatewayId !== initialKubernetes?.gatewayId;- const mustUseGatewayReviewer = isPoolRequired && isNewIndividualGateway;+ const isKeptApiGateway =+ gatewayId === initialKubernetes?.gatewayId && initialKubernetes?.tokenReviewMode !== "gateway";+ const mustUseGatewayReviewer = isPoolRequired && Boolean(gatewayId) && !isKeptApiGateway;const reviewModeOptions = REVIEW_MODE_OPTIONS.map((option) => ({...option,isDisabled: option.value === "api" && mustUseGatewayReviewer@@ -589,6 +592,12 @@ export const NetworkingAuthMethodForm = ({) {setValue("tokenReviewMode", "gateway", { shouldDirty: true });}+ // A pool can't perform the review, so Gateway as Reviewer never applies to one.+ if (next.gatewayPoolId) {+ setValue("tokenReviewMode", "api", { shouldDirty: true });+ }+ // Clears a stale review-mode error from an earlier submit.+ if (isSubmitted) trigger("gatewayId");}}isDisabled={isDisabled || isSaving}isError={Boolean(error)}diff --git a/frontend/src/pages/organization/NetworkingPage/route.tsx b/frontend/src/pages/organization/NetworkingPage/route.tsxindex 68f5897f5c..71e07477e3 100644--- a/frontend/src/pages/organization/NetworkingPage/route.tsx+++ b/frontend/src/pages/organization/NetworkingPage/route.tsx@@ -6,6 +6,7 @@ import { NetworkingPage } from "./NetworkingPage";const NetworkingPageQueryParams = z.object({selectedTab: z.string().catch("gateways"),+ gatewayView: z.enum(["all-gateways", "gateway-pools"]).optional().catch(undefined),action: z.string().optional()});