Skip to content

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

misc: addresseed comments

Sheen Capadngana66dd4d5e99c
diff --git a/backend-go/internal/config/config.go b/backend-go/internal/config/config.go
index f041a654a2..08e29f293b 100644
--- a/backend-go/internal/config/config.go
+++ b/backend-go/internal/config/config.go
@@ -250,11 +250,7 @@ type Config struct {
HSMSlot int
// Gateway
- GatewayInfisicalStaticIPAddress string
- GatewayRelayAddress string
- GatewayRelayRealm string
- GatewayRelayAuthSecret string
- RelayAuthSecret string
+ RelayAuthSecret string
// Dynamic Secrets
DynamicSecretAllowInternalIP bool
@@ -616,10 +612,6 @@ func LoadConfig() (*Config, error) {
OptionalInt(&cfg.HSMSlot, "HSM_SLOT", 0).
// Gateway
- Optional(&cfg.GatewayInfisicalStaticIPAddress, "GATEWAY_INFISICAL_STATIC_IP_ADDRESS", "").
- Optional(&cfg.GatewayRelayAddress, "GATEWAY_RELAY_ADDRESS", "").
- Optional(&cfg.GatewayRelayRealm, "GATEWAY_RELAY_REALM", "").
- Optional(&cfg.GatewayRelayAuthSecret, "GATEWAY_RELAY_AUTH_SECRET", "").
Optional(&cfg.RelayAuthSecret, "RELAY_AUTH_SECRET", "").
// Dynamic Secrets
diff --git a/backend/src/ee/services/dynamic-secret/dynamic-secret-service.ts b/backend/src/ee/services/dynamic-secret/dynamic-secret-service.ts
index a7a3aae20c..cd1fe33517 100644
--- a/backend/src/ee/services/dynamic-secret/dynamic-secret-service.ts
+++ b/backend/src/ee/services/dynamic-secret/dynamic-secret-service.ts
@@ -10,6 +10,7 @@ import {
import { crypto } from "@app/lib/crypto";
import { BadRequestError, NotFoundError } from "@app/lib/errors";
import { extractObjectFieldPaths, takeDistinctKeyScanWindow } from "@app/lib/fn";
+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";
@@ -177,9 +178,7 @@ export const dynamicSecretServiceFactory = ({
const [gatewayv2] = await gatewayV2DAL.find({ id: gatewayId, orgId: actorOrgId });
if (!gatewayv2) {
- throw new NotFoundError({
- message: `Gateway with ID ${gatewayId} not found`
- });
+ throw new NotFoundError({ message: getMissingGatewayMessage(gatewayId) });
}
const { permission: orgPermission } = await permissionService.getOrgPermission({
@@ -408,9 +407,7 @@ export const dynamicSecretServiceFactory = ({
const [gatewayv2] = await gatewayV2DAL.find({ id: gatewayId, orgId: actorOrgId });
if (!gatewayv2) {
- throw new NotFoundError({
- message: `Gateway with ID ${gatewayId} not found`
- });
+ throw new NotFoundError({ message: getMissingGatewayMessage(gatewayId) });
}
const { permission: orgPermission } = await permissionService.getOrgPermission({
@@ -445,6 +442,9 @@ export const dynamicSecretServiceFactory = ({
status: null,
...(hasGatewayFieldInInput
? {
+ // clears the retired v1 pin alongside, so a repointed secret never carries both
+ // columns; rows nobody edits keep their v1 value and stay revertible
+ gatewayId: null,
gatewayV2Id: !selectedGatewayPoolId ? selectedGatewayId : null,
gatewayPoolId: selectedGatewayPoolId
}
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.ts
index d374031c2b..879b8c36a3 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
@@ -169,7 +169,7 @@ describe("identityAuthTemplateServiceFactory kubernetes host validation", () =>
const { service } = createService();
await expect(patchTemplate(service, { gatewayId: "11111111-1111-1111-1111-111111111111" })).rejects.toThrow(
- "was not found in this organization"
+ "11111111-1111-1111-1111-111111111111' was not found"
);
});
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.ts
index b756d41ec4..2697b1d2be 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
@@ -15,6 +15,7 @@ import {
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
import { BadRequestError, NotFoundError } from "@app/lib/errors";
import { chunkArray } from "@app/lib/fn";
+import { getMissingGatewayMessage } from "@app/lib/gateway-v2/gateway-errors";
import { TOrgPermission } from "@app/lib/types";
import { blockLocalAndPrivateIpAddresses } from "@app/lib/validator";
import { ActorType } from "@app/services/auth/auth-type";
@@ -224,7 +225,7 @@ export const identityAuthTemplateServiceFactory = ({
const [gatewayV2] = await gatewayV2DAL.find({ id: gatewayId, orgId });
if (!gatewayV2) {
throw new BadRequestError({
- message: `Gateway with ID '${gatewayId}' was not found in this organization. Select an existing gateway for the template.`
+ message: getMissingGatewayMessage(gatewayId)
});
}
resolvedGatewayV2Id = gatewayId;
diff --git a/backend/src/keystore/keystore.ts b/backend/src/keystore/keystore.ts
index 3e893fac08..fbfea7b496 100644
--- a/backend/src/keystore/keystore.ts
+++ b/backend/src/keystore/keystore.ts
@@ -17,8 +17,6 @@ export const PgSqlLock = {
KmsRootKeyInit: 2025,
SanitizedSchemaGeneration: 2026,
EmailDomainCreationLock: () => pgAdvisoryLockHashText(`org-email-domain-creation`),
- OrgGatewayRootCaInit: (orgId: string) => pgAdvisoryLockHashText(`org-gateway-root-ca:${orgId}`),
- OrgGatewayCertExchange: (orgId: string) => pgAdvisoryLockHashText(`org-gateway-cert-exchange:${orgId}`),
SecretRotationV2Creation: (folderId: string) => pgAdvisoryLockHashText(`secret-rotation-v2-creation:${folderId}`),
CreateProject: (orgId: string) => pgAdvisoryLockHashText(`create-project:${orgId}`),
CreateFolder: (envId: string, projectId: string) => pgAdvisoryLockHashText(`create-folder:${envId}-${projectId}`),
@@ -89,7 +87,6 @@ export const KeyStorePrefixes = {
IdentityLastLoginDebounce: (identityId: string) => `identity-last-login-debounce:${identityId}` as const,
ProxiedServiceUsageDebounce: (serviceId: string) => `proxied-service-usage-debounce:${serviceId}` as const,
ServiceTokenStatusUpdate: (serviceTokenId: string) => `service-token-status:${serviceTokenId}`,
- GatewayIdentityCredential: (identityId: string) => `gateway-credentials:${identityId}`,
// The braces are a Redis Cluster hash tag: only the tagged part picks the slot, so these land on
// one node. Selection reads them for several gateways at once (one Lua script and two MGETs), and
// cluster refuses a multi-key command whose keys span slots. They are small counters, so
@@ -283,7 +280,6 @@ export const KeyStoreTtls = {
TelemetryAuditLogsViewedInSeconds: 3600, // 1 hour
SecretEtagInSeconds: 900, // 15 minutes
PkiAcmeNonceInSeconds: 300, // 5 minutes
- GatewayRelayCredentialInSeconds: 600, // 10 minutes - TURN credential lifetime
SecretReplicationSuccessInSeconds: 10,
NativeIntegrationDeprecationNoticeInSeconds: 3888000, // 45 days - outlives one monthly cycle
WorkerHeartbeatInSeconds: 300 // 5 minutes - tolerates several missed 60s beats
diff --git a/backend/src/lib/config/env.ts b/backend/src/lib/config/env.ts
index 7672c48ae7..821c643418 100644
--- a/backend/src/lib/config/env.ts
+++ b/backend/src/lib/config/env.ts
@@ -538,11 +538,6 @@ const envSchema = z
SHOULD_INIT_PG_QUEUE: zodStrBool.default("false"),
/* Gateway----------------------------------------------------------------------------- */
- GATEWAY_INFISICAL_STATIC_IP_ADDRESS: zpStr(z.string().optional()),
- GATEWAY_RELAY_ADDRESS: zpStr(z.string().optional()),
- GATEWAY_RELAY_REALM: zpStr(z.string().optional()),
- GATEWAY_RELAY_AUTH_SECRET: zpStr(z.string().optional()),
-
RELAY_AUTH_SECRET: zpStr(z.string().optional()),
DYNAMIC_SECRET_ALLOW_INTERNAL_IP: zodStrBool.default("false"),
diff --git a/backend/src/lib/gateway-v2/gateway-errors.ts b/backend/src/lib/gateway-v2/gateway-errors.ts
index a418ba0ef5..6d5018b5b5 100644
--- a/backend/src/lib/gateway-v2/gateway-errors.ts
+++ b/backend/src/lib/gateway-v2/gateway-errors.ts
@@ -1,7 +1,8 @@
/**
* A gateway id that resolves to no gateway is never safe to treat as "no gateway configured": the
* resource is pinned to it, so dialling the target directly would bypass the network boundary the
- * gateway exists to enforce. Every caller turns this into a 404 instead.
+ * gateway exists to enforce. Callers raise it instead, keeping whatever status that site already
+ * used — 404 on the dial and ownership paths, 400 where the id arrived as a field on a patch.
*
* The most likely reason a caller lands here is a resource still pointing at a legacy gateway.
* Those rows are retained but no longer read, and there is no in-place upgrade for one, so the
diff --git a/backend/src/lib/turn/credentials.ts b/backend/src/lib/turn/credentials.ts
deleted file mode 100644
index 34c30ac8fa..0000000000
--- a/backend/src/lib/turn/credentials.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { crypto } from "@app/lib/crypto/cryptography";
-
-const TURN_TOKEN_TTL = 24 * 60 * 60 * 1000; // 24 hours in milliseconds
-export const getTurnCredentials = (id: string, authSecret: string, ttl = TURN_TOKEN_TTL) => {
- const timestamp = Math.floor((Date.now() + ttl) / 1000);
- const username = `${timestamp}:${id}`;
-
- const hmac = crypto.nativeCrypto.createHmac("sha1", authSecret);
- hmac.update(username);
- const password = hmac.digest("base64");
-
- return {
- username,
- password
- };
-};
diff --git a/backend/src/services/app-connection/app-connection-service.ts b/backend/src/services/app-connection/app-connection-service.ts
index 37ecc4c6be..e29d365b45 100644
--- a/backend/src/services/app-connection/app-connection-service.ts
+++ b/backend/src/services/app-connection/app-connection-service.ts
@@ -25,6 +25,7 @@ import { TKeyStoreFactory } from "@app/keystore/keystore";
import { crypto } from "@app/lib/crypto/cryptography";
import { DatabaseErrorCode } from "@app/lib/error-codes";
import { BadRequestError, DatabaseError, NotFoundError } from "@app/lib/errors";
+import { getMissingGatewayMessage } from "@app/lib/gateway-v2/gateway-errors";
import { DiscriminativePick, OrgServiceActor } from "@app/lib/types";
import {
decryptAppConnection,
@@ -563,9 +564,7 @@ export const appConnectionServiceFactory = ({
const [gatewayV2] = await gatewayV2DAL.find({ id: gatewayId, orgId: actor.orgId });
if (!gatewayV2) {
- throw new NotFoundError({
- message: `Gateway with ID ${gatewayId} not found for org`
- });
+ throw new NotFoundError({ message: getMissingGatewayMessage(gatewayId) });
}
}
@@ -787,9 +786,7 @@ export const appConnectionServiceFactory = ({
if (gatewayId) {
const [gatewayV2] = await gatewayV2DAL.find({ id: gatewayId, orgId: actor.orgId });
if (!gatewayV2) {
- throw new NotFoundError({
- message: `Gateway with ID ${gatewayId} not found for org`
- });
+ throw new NotFoundError({ message: getMissingGatewayMessage(gatewayId) });
}
}
}
diff --git a/backend/src/services/app-connection/f5-big-ip/f5-big-ip-connection-fns.ts b/backend/src/services/app-connection/f5-big-ip/f5-big-ip-connection-fns.ts
index 50739aef82..5574fb7761 100644
--- a/backend/src/services/app-connection/f5-big-ip/f5-big-ip-connection-fns.ts
+++ b/backend/src/services/app-connection/f5-big-ip/f5-big-ip-connection-fns.ts
@@ -4,6 +4,7 @@ import https from "https";
import { TGatewayV2ServiceFactory } from "@app/ee/services/gateway-v2/gateway-v2-service";
import { request } from "@app/lib/config/request";
import { BadRequestError } from "@app/lib/errors";
+import { getMissingGatewayMessage } from "@app/lib/gateway-v2/gateway-errors";
import { withGatewayV2Proxy } from "@app/lib/gateway-v2/gateway-v2";
import { GatewayProxyProtocol } from "@app/lib/gateway-v2/types";
import { blockLocalAndPrivateIpAddresses, buildSsrfSafeAgent } from "@app/lib/validator";
@@ -32,7 +33,7 @@ const requestWithF5BigIpGateway = async <T>(
const { hostname, port: credPort } = credentials;
const port = credPort ?? F5_BIG_IP_DEFAULT_PORT;
- if (gatewayId && gatewayV2Service) {
+ if (gatewayId) {
await blockLocalAndPrivateIpAddresses(`https://${hostname}`, true);
const platformConnectionDetails = await gatewayV2Service.getPlatformConnectionDetailsByGatewayId({
@@ -172,7 +173,13 @@ export const executeF5BigIpOperationWithGateway = async <T>(
const { hostname, port: credPort } = credentials;
const port = credPort ?? F5_BIG_IP_DEFAULT_PORT;
- if (gatewayId && gatewayV2Service) {
+ if (gatewayId) {
+ // the service is optional on this overload, but a pinned gateway must never fall through to
+ // the direct-dial branch below, so a missing one is an error rather than a silent bypass
+ if (!gatewayV2Service) {
+ throw new BadRequestError({ message: getMissingGatewayMessage(gatewayId) });
+ }
+
await blockLocalAndPrivateIpAddresses(`https://${hostname}`, true);
const platformConnectionDetails = await gatewayV2Service.getPlatformConnectionDetailsByGatewayId({
diff --git a/backend/src/services/app-connection/hc-vault/hc-vault-connection-fns.ts b/backend/src/services/app-connection/hc-vault/hc-vault-connection-fns.ts
index 844ab0df9a..2fc1945b14 100644
--- a/backend/src/services/app-connection/hc-vault/hc-vault-connection-fns.ts
+++ b/backend/src/services/app-connection/hc-vault/hc-vault-connection-fns.ts
@@ -169,12 +169,12 @@ export const requestWithHCVaultGateway = async <T>(
return request.request(requestConfig);
}
- let gatewayConnectionDetails: TGatewayV2ConnectionDetails | undefined = gatewayDetails?.details;
-
+ let gatewayConnectionDetails: TGatewayV2ConnectionDetails | undefined;
let targetHost: string;
let targetPort: number;
if (gatewayDetails) {
+ gatewayConnectionDetails = gatewayDetails.details;
targetHost = gatewayDetails.target.host;
targetPort = gatewayDetails.target.port;
} else {
@@ -182,9 +182,6 @@ export const requestWithHCVaultGateway = async <T>(
// port is empty string when using protocol's default port (443 for https, 80 for http)
// eslint-disable-next-line no-nested-ternary
targetPort = url.port ? Number(url.port) : url.protocol === "https:" ? 443 : 80;
- }
-
- if (!gatewayDetails) {
gatewayConnectionDetails = await gatewayV2Service.getPlatformConnectionDetailsByGatewayId({
gatewayId,
targetHost,
diff --git a/backend/src/services/app-connection/ldap/ldap-connection-fns.ts b/backend/src/services/app-connection/ldap/ldap-connection-fns.ts
index b6180469ef..a2b7337ef0 100644
--- a/backend/src/services/app-connection/ldap/ldap-connection-fns.ts
+++ b/backend/src/services/app-connection/ldap/ldap-connection-fns.ts
@@ -239,7 +239,7 @@ export const executeWithPotentialGateway = async <T>(
? await gatewayPoolService.resolveEffectiveGatewayId({ gatewayId: directGatewayId, gatewayPoolId })
: directGatewayId;
- if (gatewayId && gatewayV2Service) {
+ if (gatewayId) {
await blockLocalAndPrivateIpAddresses(credentials.url, true);
const platformConnectionDetails = await gatewayV2Service.getPlatformConnectionDetailsByGatewayId({
gatewayId,
diff --git a/backend/src/services/app-connection/netscaler/netscaler-connection-fns.ts b/backend/src/services/app-connection/netscaler/netscaler-connection-fns.ts
index eae7912db4..58f6d09ae2 100644
--- a/backend/src/services/app-connection/netscaler/netscaler-connection-fns.ts
+++ b/backend/src/services/app-connection/netscaler/netscaler-connection-fns.ts
@@ -4,6 +4,7 @@ import https from "https";
import { TGatewayV2ServiceFactory } from "@app/ee/services/gateway-v2/gateway-v2-service";
import { request } from "@app/lib/config/request";
import { BadRequestError } from "@app/lib/errors";
+import { getMissingGatewayMessage } from "@app/lib/gateway-v2/gateway-errors";
import { withGatewayV2Proxy } from "@app/lib/gateway-v2/gateway-v2";
import { GatewayProxyProtocol } from "@app/lib/gateway-v2/types";
import { blockLocalAndPrivateIpAddresses } from "@app/lib/validator";
@@ -39,7 +40,7 @@ const requestWithNetScalerGateway = async <T>(
const { hostname, port: credPort } = credentials;
const port = credPort ?? 443;
- if (gatewayId && gatewayV2Service) {
+ if (gatewayId) {
await blockLocalAndPrivateIpAddresses(`https://${hostname}`, true);
const platformConnectionDetails = await gatewayV2Service.getPlatformConnectionDetailsByGatewayId({
@@ -156,7 +157,13 @@ export const executeNetScalerOperationWithGateway = async <T>(
const { hostname, port: credPort } = credentials;
const port = credPort ?? 443;
- if (gatewayId && gatewayV2Service) {
+ if (gatewayId) {
+ // the service is optional on this overload, but a pinned gateway must never fall through to
+ // the direct-dial branch below, so a missing one is an error rather than a silent bypass
+ if (!gatewayV2Service) {
+ throw new BadRequestError({ message: getMissingGatewayMessage(gatewayId) });
+ }
+
await blockLocalAndPrivateIpAddresses(`https://${hostname}`, true);
const platformConnectionDetails = await gatewayV2Service.getPlatformConnectionDetailsByGatewayId({
diff --git a/backend/src/services/app-connection/shared/sql/sql-connection-fns.ts b/backend/src/services/app-connection/shared/sql/sql-connection-fns.ts
index e3a7c66c46..ad6b35c597 100644
--- a/backend/src/services/app-connection/shared/sql/sql-connection-fns.ts
+++ b/backend/src/services/app-connection/shared/sql/sql-connection-fns.ts
@@ -166,7 +166,7 @@ export const executeWithPotentialGateway = async <T>(
? await gatewayPoolService.resolveEffectiveGatewayId({ gatewayId: directGatewayId, gatewayPoolId })
: directGatewayId;
- if (gatewayId && gatewayV2Service) {
+ if (gatewayId) {
const [targetHost] = await verifyHostInputValidity({
host: credentials.host,
isGateway: true,
diff --git a/backend/src/services/external-migration/external-migration-service.ts b/backend/src/services/external-migration/external-migration-service.ts
index 4519f02007..ec3a8f15f8 100644
--- a/backend/src/services/external-migration/external-migration-service.ts
+++ b/backend/src/services/external-migration/external-migration-service.ts
@@ -20,6 +20,7 @@ import {
} from "@app/ee/services/permission/project-permission";
import { crypto } from "@app/lib/crypto/cryptography";
import { BadRequestError, ForbiddenRequestError, NotFoundError } from "@app/lib/errors";
+import { getMissingGatewayMessage } from "@app/lib/gateway-v2/gateway-errors";
import { logger } from "@app/lib/logger";
import { recordLegacyRootKeyUsageMetric } from "@app/lib/telemetry/metrics";
import { OrgServiceActor } from "@app/lib/types";
@@ -313,7 +314,7 @@ export const externalMigrationServiceFactory = ({
// Ensure gatewayId is part of the actor's org
if (!gatewayV2.length) {
- throw new NotFoundError({ message: `Gateway with ID ${gatewayId} not found` });
+ throw new NotFoundError({ message: getMissingGatewayMessage(gatewayId) });
}
}
diff --git a/backend/src/services/github-app/github-app-service.ts b/backend/src/services/github-app/github-app-service.ts
index 9b028ac06f..1dcb9d6971 100644
--- a/backend/src/services/github-app/github-app-service.ts
+++ b/backend/src/services/github-app/github-app-service.ts
@@ -22,6 +22,7 @@ import { getConfig } from "@app/lib/config/env";
import { crypto } from "@app/lib/crypto";
import { DatabaseErrorCode } from "@app/lib/error-codes";
import { BadRequestError, DatabaseError, NotFoundError } from "@app/lib/errors";
+import { getMissingGatewayMessage } from "@app/lib/gateway-v2/gateway-errors";
import { logger } from "@app/lib/logger";
import { OrgServiceActor } from "@app/lib/types";
import { safeRequest } from "@app/lib/validator/safe-request";
@@ -147,9 +148,7 @@ export const gitHubAppServiceFactory = ({
const [gatewayV2] = await gatewayV2DAL.find({ id: gatewayId, orgId: orgPermission.orgId });
if (!gatewayV2) {
- throw new NotFoundError({
- message: `Gateway with ID ${gatewayId} not found for org`
- });
+ throw new NotFoundError({ message: getMissingGatewayMessage(gatewayId) });
}
};
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 ab73ff3a8b..c575e9cc46 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
@@ -981,9 +981,7 @@ export const identityKubernetesAuthServiceFactory = ({
const [gatewayV2] = await gatewayV2DAL.find({ id: gatewayId, orgId: identityMembershipOrg.scopeOrgId });
if (!gatewayV2) {
- throw new NotFoundError({
- message: `Gateway with ID ${gatewayId} not found`
- });
+ throw new NotFoundError({ message: getMissingGatewayMessage(gatewayId) });
}
// when the gateway comes from a template, attaching the gateway was authorized at
@@ -1368,9 +1366,7 @@ export const identityKubernetesAuthServiceFactory = ({
const [gatewayV2] = await gatewayV2DAL.find({ id: gatewayId, orgId: identityMembershipOrg.scopeOrgId });
if (!gatewayV2) {
- throw new NotFoundError({
- message: `Gateway with ID ${gatewayId} not found`
- });
+ throw new NotFoundError({ message: getMissingGatewayMessage(gatewayId) });
}
if (!template) {
@@ -1421,6 +1417,10 @@ export const identityKubernetesAuthServiceFactory = ({
// Strict check to see if gateway ID is undefined. It should update the gateway ID to null if its strictly set to null.
const shouldUpdateGatewayId = Boolean(gatewayId !== undefined || gatewayPoolId !== undefined);
+
+ if (isPinnedToRetiredGateway(identityKubernetesAuth) && !shouldUpdateGatewayId) {
+ throw new BadRequestError({ message: getRetiredGatewayMessage("This Kubernetes auth method") });
+ }
let gatewayV2IdValue: string | null | undefined = null;
if (!gatewayPoolId && gatewayId) {
gatewayV2IdValue = gatewayId;
diff --git a/frontend/src/hooks/api/gateways-v2/mutations.tsx b/frontend/src/hooks/api/gateways-v2/mutations.tsx
index 675ca94819..15ed3ad9b2 100644
--- a/frontend/src/hooks/api/gateways-v2/mutations.tsx
+++ b/frontend/src/hooks/api/gateways-v2/mutations.tsx
@@ -14,8 +14,7 @@ const invalidateGatewayQueries = (
queryClient: ReturnType<typeof useQueryClient>,
gatewayId?: string
) => {
- queryClient.invalidateQueries(gatewaysQueryKeys.list());
- queryClient.invalidateQueries(gatewaysQueryKeys.listWithTokens());
+ queryClient.invalidateQueries({ queryKey: gatewaysQueryKeys.listKey() });
if (gatewayId) {
queryClient.invalidateQueries({ queryKey: gatewaysV2QueryKeys.byIdKey(gatewayId) });
queryClient.invalidateQueries({
diff --git a/frontend/src/hooks/api/gateways/queries.tsx b/frontend/src/hooks/api/gateways/queries.tsx
index 1368bedc2c..23679f59a5 100644
--- a/frontend/src/hooks/api/gateways/queries.tsx
+++ b/frontend/src/hooks/api/gateways/queries.tsx
@@ -4,29 +4,26 @@ import { apiRequest } from "@app/config/request";
import { TGatewayV2 } from "../gateways-v2/types";
-export type TListedGateway = TGatewayV2;
+const hasConnected = (gateway: TGatewayV2) =>
+ Boolean(gateway.identityId || gateway.heartbeat || gateway.directHeartbeat);
+
+const fetchGateways = async () => {
+ const { data } = await apiRequest.get<TGatewayV2[]>("/api/v2/gateways");
+ return data;
+};
export const gatewaysQueryKeys = {
allKey: () => ["gateways"],
listKey: () => [...gatewaysQueryKeys.allKey(), "list"],
- list: () =>
+ listAll: () =>
queryOptions({
queryKey: gatewaysQueryKeys.listKey(),
- queryFn: async () => {
- const { data } = await apiRequest.get<TGatewayV2[]>("/api/v2/gateways");
-
- // Filter out enrollment-flow gateways that haven't connected yet
- // so gateway pickers don't show them as selectable options.
- return data.filter((g) => g.identityId || g.heartbeat || g.directHeartbeat);
- }
+ queryFn: fetchGateways
}),
- listWithTokensKey: () => [...gatewaysQueryKeys.allKey(), "list-with-tokens"],
- listWithTokens: () =>
+ list: () =>
queryOptions({
- queryKey: gatewaysQueryKeys.listWithTokensKey(),
- queryFn: async () => {
- const { data } = await apiRequest.get<TGatewayV2[]>("/api/v2/gateways");
- return data;
- }
+ queryKey: gatewaysQueryKeys.listKey(),
+ queryFn: fetchGateways,
+ select: (gateways: TGatewayV2[]) => gateways.filter(hasConnected)
})
};
diff --git a/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/GatewayTab.tsx b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/GatewayTab.tsx
index ec10e03c7d..382f1a9b86 100644
--- a/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/GatewayTab.tsx
+++ b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/GatewayTab.tsx
@@ -97,7 +97,7 @@ export const GatewayTab = withPermission(
const [poolSearch, setPoolSearch] = useState("");
const [selectedPoolId, setSelectedPoolId] = useState<string | null>(null);
const { data: gateways, isPending: isGatewaysLoading } = useQuery({
- ...gatewaysQueryKeys.listWithTokens(),
+ ...gatewaysQueryKeys.listAll(),
refetchInterval: 15_000
});
const { data: pools } = useListGatewayPools({ enabled: Boolean(showPoolsTab) });
diff --git a/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/GatewayDeployModal.tsx b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/GatewayDeployModal.tsx
index bd17b768d7..e705be9d30 100644
--- a/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/GatewayDeployModal.tsx
+++ b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/GatewayDeployModal.tsx
@@ -40,7 +40,7 @@ const Content = ({ onClose }: { onClose: () => void }) => {
const { currentOrg } = useOrganization();
const orgId = currentOrg?.id || "";
const navigate = useNavigate({ from: ROUTE_PATHS.Organization.NetworkingPage.path });
- const { data: gateways } = useQuery(gatewaysQueryKeys.listWithTokens());
+ const { data: gateways } = useQuery(gatewaysQueryKeys.listAll());
const { mutateAsync: createGateway, isPending } = useCreateGateway();
const {
diff --git a/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/GatewayPoolsContent.tsx b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/GatewayPoolsContent.tsx
index 409fdb1ccc..d9cb73ad93 100644
--- a/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/GatewayPoolsContent.tsx
+++ b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/GatewayPoolsContent.tsx
@@ -102,7 +102,7 @@ export const GatewayPoolsContent = ({ search }: Props) => {
</EmptyHeader>
</Empty>
) : (
- <Table className="min-w-[52rem]">
+ <Table className="w-full min-w-[52rem]">
<TableHeader>
<TableRow>
<TableHead>