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
fix(gateway-deploy): mint a new token on connection mode change
bernie-g7d30fce6547c
diff --git a/frontend/src/pages/organization/NetworkingPage/GatewayDetailsByIDPage/components/GatewayDeploySection/GatewayDeploySection.tsx b/frontend/src/pages/organization/NetworkingPage/GatewayDetailsByIDPage/components/GatewayDeploySection/GatewayDeploySection.tsxindex c42f554a97..3ceadb2460 100644--- a/frontend/src/pages/organization/NetworkingPage/GatewayDetailsByIDPage/components/GatewayDeploySection/GatewayDeploySection.tsx+++ b/frontend/src/pages/organization/NetworkingPage/GatewayDetailsByIDPage/components/GatewayDeploySection/GatewayDeploySection.tsx@@ -1,4 +1,4 @@-import { useState } from "react";+import { useRef, useState } from "react";import { LockKeyholeIcon, RefreshCwIcon, RocketIcon } from "lucide-react";import { createNotification } from "@app/components/notifications";@@ -96,6 +96,7 @@ export const GatewayDeploySection = ({(TGatewayEnrollmentToken & { gatewayId: string }) | null>(null);const [isCommandDirty, setIsCommandDirty] = useState(false);+ const mintSequence = useRef(0);const { mutateAsync: mint, isPending: isMinting } = useMintGatewayToken();const { permission } = useOrgPermission();const enrollment = mintedEnrollment?.gatewayId === gatewayId ? mintedEnrollment : null;@@ -115,14 +116,26 @@ export const GatewayDeploySection = ({: deploymentTabs[0];const handleGenerate = async () => {+ const sequence = mintSequence.current + 1;+ mintSequence.current = sequence;try {const result = await mint({ gatewayId });+ // Minting deletes the previous token, so a slower earlier response would show a dead one.+ if (mintSequence.current !== sequence) return;setMintedEnrollment({ ...result, gatewayId });} catch {createNotification({ type: "error", text: "Failed to generate enrollment token" });}};+ const handleConnectionModeChange = (value: string) => {+ const nextMode = value as "relay" | "direct";+ if (nextMode === connectionMode) return;+ setConnectionMode(nextMode);+ // The command rewrites its flags on mode change, and enrollment tokens are single use.+ if (enrollment) void handleGenerate();+ };+return (<Tabs value={activeTab} onValueChange={setDeploymentMethod} className="min-w-0"><Card className="min-w-0" aria-labelledby="gateway-deployment-title">@@ -168,10 +181,7 @@ export const GatewayDeploySection = ({{!isCloud && (<Field><FieldLabel>Connection Mode</FieldLabel>- <RadioGroup- value={connectionMode}- onValueChange={(value) => setConnectionMode(value as "relay" | "direct")}- >+ <RadioGroup value={connectionMode} onValueChange={handleConnectionModeChange}><FieldLabel htmlFor="gateway-connection-mode-direct" variant="org"><Field orientation="horizontal"><FieldContent>