Skip to content

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

add support for gateway

adilson97f42fa3fe1e
diff --git a/backend/src/ee/services/dynamic-secret/providers/index.ts b/backend/src/ee/services/dynamic-secret/providers/index.ts
index cd41e10c4e..189a3e5002 100644
--- a/backend/src/ee/services/dynamic-secret/providers/index.ts
+++ b/backend/src/ee/services/dynamic-secret/providers/index.ts
@@ -67,6 +67,6 @@ export const buildDynamicSecretProviders = ({
[DynamicSecretProviders.GcpIam]: GcpIamProvider(),
[DynamicSecretProviders.Github]: GithubProvider(),
[DynamicSecretProviders.Couchbase]: CouchbaseProvider(),
- [DynamicSecretProviders.Milvus]: MilvusProvider(),
+ [DynamicSecretProviders.Milvus]: MilvusProvider({ gatewayService, gatewayV2Service, gatewayPoolService }),
[DynamicSecretProviders.Ssh]: SshProvider()
});
diff --git a/backend/src/ee/services/dynamic-secret/providers/milvus.ts b/backend/src/ee/services/dynamic-secret/providers/milvus.ts
index 200841d472..530930acef 100644
--- a/backend/src/ee/services/dynamic-secret/providers/milvus.ts
+++ b/backend/src/ee/services/dynamic-secret/providers/milvus.ts
@@ -7,42 +7,72 @@ import { TDynamicSecrets } from "@app/db/schemas";
import { request } from "@app/lib/config/request";
import { BadRequestError } from "@app/lib/errors";
import { sanitizeString } from "@app/lib/fn";
+import { GatewayProxyProtocol, withGatewayProxy } from "@app/lib/gateway";
+import { withGatewayV2Proxy } from "@app/lib/gateway-v2/gateway-v2";
import { logger } from "@app/lib/logger";
import { blockLocalAndPrivateIpAddresses } from "@app/lib/validator/validate-url";
import { ActorIdentityAttributes } from "../../dynamic-secret-lease/dynamic-secret-lease-types";
+import { TGatewayServiceFactory } from "../../gateway/gateway-service";
+import { TGatewayPoolServiceFactory } from "../../gateway-pool/gateway-pool-service";
+import { TGatewayV2ServiceFactory } from "../../gateway-v2/gateway-v2-service";
import { verifyHostInputValidity } from "../dynamic-secret-fns";
import { DynamicSecretMilvusSchema, TDynamicProviderFns } from "./models";
import { generateUsername } from "./templateUtils";
type TMilvusProviderInputs = z.infer<typeof DynamicSecretMilvusSchema>;
+type TMilvusProviderDTO = {
+ gatewayService: Pick<TGatewayServiceFactory, "fnGetGatewayClientTlsByGatewayId">;
+ gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">;
+ gatewayPoolService: Pick<TGatewayPoolServiceFactory, "resolveEffectiveGatewayId">;
+};
+
+type MilvusRolePrivilege = {
+ dbName: string;
+ grantor: string;
+ objectName: string;
+ objectType: string;
+ privilege: string;
+};
+
+type MilvusDescribeRoleResponse = {
+ code: number;
+ data: MilvusRolePrivilege[];
+};
+
const generatePassword = () => {
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_!@*";
return customAlphabet(charset, 32)();
};
-const buildBaseUrl = (providerInputs: TMilvusProviderInputs) => {
- const hostHasScheme = /^https?:\/\//i.test(providerInputs.host);
+const buildBaseUrl = (providerInputs: TMilvusProviderInputs, host: string, port: number) => {
+ const sanitizedHost = host.replace(/^https?:\/\//i, "");
const scheme = providerInputs.ca ? "https" : "http";
- const normalizedHost = hostHasScheme ? providerInputs.host : `${scheme}://${providerInputs.host}`;
- return `${normalizedHost}:${providerInputs.port}`;
+ return `${scheme}://${sanitizedHost}:${port}`;
};
const deriveRoleName = (username: string) => `infisical_role_${username}`;
-export const MilvusProvider = (): TDynamicProviderFns => {
+export const MilvusProvider = ({
+ gatewayService,
+ gatewayV2Service,
+ gatewayPoolService
+}: TMilvusProviderDTO): TDynamicProviderFns => {
const validateProviderInputs = async (inputs: object) => {
const providerInputs = await DynamicSecretMilvusSchema.parseAsync(inputs);
const sanitizedHost = providerInputs.host.replace(/^https?:\/\//i, "");
+ const isGateway = Boolean(providerInputs.gatewayId || providerInputs.gatewayPoolId);
- await blockLocalAndPrivateIpAddresses(sanitizedHost);
- await verifyHostInputValidity({ host: sanitizedHost, isDynamicSecret: true });
+ if (!isGateway) {
+ await blockLocalAndPrivateIpAddresses(sanitizedHost);
+ }
+ await verifyHostInputValidity({ host: sanitizedHost, isDynamicSecret: true, isGateway });
return providerInputs;
};
- const $requestConfig = (providerInputs: TMilvusProviderInputs) => ({
- baseURL: buildBaseUrl(providerInputs),
+ const $requestConfig = (providerInputs: TMilvusProviderInputs, host: string, port: number) => ({
+ baseURL: buildBaseUrl(providerInputs, host, port),
headers: {
Authorization: `Bearer ${providerInputs.username}:${providerInputs.password}`,
"Content-Type": "application/json"
@@ -55,27 +85,109 @@ export const MilvusProvider = (): TDynamicProviderFns => {
})
});
- const validateConnection = async (inputs: unknown) => {
- const providerInputs = await validateProviderInputs(inputs as object);
- const requestConfig = $requestConfig(providerInputs);
+ const $buildClientHttpsAgent = (providerInputs: TMilvusProviderInputs) =>
+ providerInputs.ca
+ ? new https.Agent({
+ ca: providerInputs.ca,
+ rejectUnauthorized: providerInputs.sslRejectUnauthorized
+ })
+ : undefined;
- await blockLocalAndPrivateIpAddresses(requestConfig.baseURL);
- try {
- await request.post(
- "/v2/vectordb/users/describe",
- { userName: providerInputs.username },
- $requestConfig(providerInputs)
+ const $gatewayProxyWrapper = async <T>(
+ inputs: {
+ gatewayId: string;
+ targetHost: string;
+ targetPort: number;
+ httpsAgent?: https.Agent;
+ },
+ gatewayCallback: (host: string, port: number) => Promise<T>
+ ): Promise<T> => {
+ const sanitizedTargetHost = inputs.targetHost.replace(/^https?:\/\//i, "");
+
+ const gatewayV2ConnectionDetails = await gatewayV2Service.getPlatformConnectionDetailsByGatewayId({
+ gatewayId: inputs.gatewayId,
+ targetHost: sanitizedTargetHost,
+ targetPort: inputs.targetPort
+ });
+
+ if (gatewayV2ConnectionDetails) {
+ return withGatewayV2Proxy(async (port) => gatewayCallback("localhost", port), {
+ relayHost: gatewayV2ConnectionDetails.relayHost,
+ gateway: gatewayV2ConnectionDetails.gateway,
+ relay: gatewayV2ConnectionDetails.relay,
+ protocol: GatewayProxyProtocol.Tcp,
+ httpsAgent: inputs.httpsAgent
+ });
+ }
+
+ const relayDetails = await gatewayService.fnGetGatewayClientTlsByGatewayId(inputs.gatewayId);
+ return withGatewayProxy(async (port) => gatewayCallback("localhost", port), {
+ relayDetails,
+ protocol: GatewayProxyProtocol.Tcp,
+ targetHost: sanitizedTargetHost,
+ targetPort: inputs.targetPort,
+ httpsAgent: inputs.httpsAgent
+ });
+ };
+
+ const $runWithOptionalGateway = async <T>(
+ providerInputs: TMilvusProviderInputs,
+ gatewayCallback: (host: string, port: number) => Promise<T>
+ ): Promise<T> => {
+ const effectiveGatewayId = await gatewayPoolService.resolveEffectiveGatewayId(providerInputs);
+ if (effectiveGatewayId) {
+ return $gatewayProxyWrapper(
+ {
+ gatewayId: effectiveGatewayId,
+ targetHost: providerInputs.host,
+ targetPort: providerInputs.port,
+ httpsAgent: $buildClientHttpsAgent(providerInputs)
+ },
+ gatewayCallback
);
- return true;
+ }
+ return gatewayCallback(providerInputs.host, providerInputs.port);
+ };
+
+ const describeRole = async (
+ providerInputs: TMilvusProviderInputs,
+ host: string,
+ port: number,
+ roleName: string
+ ): Promise<MilvusDescribeRoleResponse> => {
+ const requestConfig = $requestConfig(providerInputs, host, port);
+ try {
+ const response = await request.post("/v2/vectordb/roles/describe", { roleName }, requestConfig);
+ return response.data as MilvusDescribeRoleResponse;
} catch (err) {
const sanitizedErrorMessage = sanitizeString({
unsanitizedString: (err as Error)?.message,
- tokens: [providerInputs.username, providerInputs.password, providerInputs.host]
+ tokens: [roleName, providerInputs.username, providerInputs.password, providerInputs.host]
});
- throw new BadRequestError({ message: `Failed to connect with Milvus: ${sanitizedErrorMessage}` });
+ throw new BadRequestError({ message: `Failed to describe Milvus role: ${sanitizedErrorMessage}` });
}
};
+ const validateConnection = async (inputs: unknown) => {
+ const providerInputs = await validateProviderInputs(inputs as object);
+
+ const gatewayCallback = async (host: string, port: number) => {
+ const requestConfig = $requestConfig(providerInputs, host, port);
+ try {
+ await request.post("/v2/vectordb/users/describe", { userName: providerInputs.username }, requestConfig);
+ } catch (err) {
+ const sanitizedErrorMessage = sanitizeString({
+ unsanitizedString: (err as Error)?.message,
+ tokens: [providerInputs.username, providerInputs.password, providerInputs.host]
+ });
+ throw new BadRequestError({ message: `Failed to connect with Milvus: ${sanitizedErrorMessage}` });
+ }
+ };
+
+ await $runWithOptionalGateway(providerInputs, gatewayCallback);
+ return true;
+ };
+
const create = async (data: {
inputs: unknown;
usernameTemplate?: string | null;
@@ -84,9 +196,6 @@ export const MilvusProvider = (): TDynamicProviderFns => {
}) => {
const { inputs, usernameTemplate, identity, dynamicSecret } = data;
const providerInputs = await validateProviderInputs(inputs as object);
- const requestConfig = $requestConfig(providerInputs);
-
- await blockLocalAndPrivateIpAddresses(requestConfig.baseURL);
const username = await generateUsername(usernameTemplate, {
decryptedDynamicSecretInputs: inputs,
@@ -96,93 +205,96 @@ export const MilvusProvider = (): TDynamicProviderFns => {
const password = generatePassword();
const roleName = deriveRoleName(username);
- let userCreated = false;
- let roleCreated = false;
+ const gatewayCallback = async (host: string, port: number) => {
+ const requestConfig = $requestConfig(providerInputs, host, port);
- try {
- await request.post("/v2/vectordb/users/create", { userName: username, password }, requestConfig);
- userCreated = true;
-
- if (providerInputs.privileges.length > 0) {
- await request.post("/v2/vectordb/roles/create", { roleName }, requestConfig);
- roleCreated = true;
-
- await Promise.all(
- providerInputs.privileges.map((privilege) =>
- request.post(
- "/v2/vectordb/roles/grant_privilege",
- {
- roleName,
- objectType: privilege.objectType,
- objectName: privilege.objectName,
- privilege: privilege.privilege,
- dbName: privilege.dbName ?? providerInputs.database
- },
- requestConfig
+ let userCreated = false;
+ let roleCreated = false;
+
+ try {
+ await request.post("/v2/vectordb/users/create", { userName: username, password }, requestConfig);
+ userCreated = true;
+
+ if (providerInputs.privileges.length > 0) {
+ await request.post("/v2/vectordb/roles/create", { roleName }, requestConfig);
+ roleCreated = true;
+
+ await Promise.all(
+ providerInputs.privileges.map((privilege) =>
+ request.post(
+ "/v2/vectordb/roles/grant_privilege",
+ {
+ roleName,
+ objectType: privilege.objectType,
+ objectName: privilege.objectName,
+ privilege: privilege.privilege,
+ dbName: privilege.dbName ?? providerInputs.database
+ },
+ requestConfig
+ )
)
- )
- );
+ );
- await request.post("/v2/vectordb/users/grant_role", { userName: username, roleName }, requestConfig);
- }
+ await request.post("/v2/vectordb/users/grant_role", { userName: username, roleName }, requestConfig);
+ }
- return {
- entityId: username,
- data: { DB_USERNAME: username, DB_PASSWORD: password }
- };
- } catch (err) {
- if (roleCreated) {
- try {
- await request.post("/v2/vectordb/roles/drop", { roleName }, requestConfig);
- } catch (cleanupErr) {
- logger.error(cleanupErr, `Failed to cleanup Milvus role [roleName=${roleName}]`);
+ return {
+ entityId: username,
+ data: { DB_USERNAME: username, DB_PASSWORD: password }
+ };
+ } catch (err) {
+ if (roleCreated) {
+ try {
+ await request.post("/v2/vectordb/roles/drop", { roleName }, requestConfig);
+ } catch (cleanupErr) {
+ logger.error(cleanupErr, `Failed to cleanup Milvus role [roleName=${roleName}]`);
+ }
}
- }
- if (userCreated) {
- try {
- await request.post("/v2/vectordb/users/drop", { userName: username }, requestConfig);
- } catch (cleanupErr) {
- logger.error(cleanupErr, `Failed to cleanup Milvus user [userName=${username}]`);
+ if (userCreated) {
+ try {
+ await request.post("/v2/vectordb/users/drop", { userName: username }, requestConfig);
+ } catch (cleanupErr) {
+ logger.error(cleanupErr, `Failed to cleanup Milvus user [userName=${username}]`);
+ }
}
+
+ const sanitizedErrorMessage = sanitizeString({
+ unsanitizedString: (err as Error)?.message,
+ tokens: [username, password, providerInputs.username, providerInputs.password, providerInputs.host]
+ });
+ throw new BadRequestError({ message: `Failed to create Milvus lease: ${sanitizedErrorMessage}` });
}
+ };
- const sanitizedErrorMessage = sanitizeString({
- unsanitizedString: (err as Error)?.message,
- tokens: [username, password, providerInputs.username, providerInputs.password, providerInputs.host]
- });
- throw new BadRequestError({ message: `Failed to create Milvus lease: ${sanitizedErrorMessage}` });
- }
+ return $runWithOptionalGateway(providerInputs, gatewayCallback);
};
const revoke = async (inputs: unknown, entityId: string) => {
const providerInputs = await validateProviderInputs(inputs as object);
- const requestConfig = $requestConfig(providerInputs);
const username = entityId;
const roleName = deriveRoleName(username);
- await blockLocalAndPrivateIpAddresses(requestConfig.baseURL);
+ const gatewayCallback = async (host: string, port: number) => {
+ const requestConfig = $requestConfig(providerInputs, host, port);
- try {
- try {
- await request.post("/v2/vectordb/users/revoke_role", { userName: username, roleName }, requestConfig);
- } catch (err) {
- logger.error(err, `Failed to revoke Milvus role from user [userName=${username}] [roleName=${roleName}]`);
- }
try {
- await request.post("/v2/vectordb/roles/drop", { roleName }, requestConfig);
+ const role = await describeRole(providerInputs, host, port, roleName);
+ if (role.code === 0 && role.data.length > 0) {
+ await request.post("/v2/vectordb/roles/drop", { roleName }, requestConfig);
+ }
+
+ await request.post("/v2/vectordb/users/drop", { userName: username }, requestConfig);
} catch (err) {
- logger.error(err, `Failed to drop Milvus role [roleName=${roleName}]`);
+ const sanitizedErrorMessage = sanitizeString({
+ unsanitizedString: (err as Error)?.message,
+ tokens: [username, providerInputs.username, providerInputs.password, providerInputs.host]
+ });
+ throw new BadRequestError({ message: `Failed to revoke Milvus lease: ${sanitizedErrorMessage}` });
}
+ };
- await request.post("/v2/vectordb/users/drop", { userName: username }, requestConfig);
- return { entityId };
- } catch (err) {
- const sanitizedErrorMessage = sanitizeString({
- unsanitizedString: (err as Error)?.message,
- tokens: [username, providerInputs.username, providerInputs.password, providerInputs.host]
- });
- throw new BadRequestError({ message: `Failed to revoke Milvus lease: ${sanitizedErrorMessage}` });
- }
+ await $runWithOptionalGateway(providerInputs, gatewayCallback);
+ return { entityId };
};
const renew = async (_inputs: unknown, entityId: string) => {
diff --git a/backend/src/ee/services/dynamic-secret/providers/models.ts b/backend/src/ee/services/dynamic-secret/providers/models.ts
index 94f5ca82f0..fe54098918 100644
--- a/backend/src/ee/services/dynamic-secret/providers/models.ts
+++ b/backend/src/ee/services/dynamic-secret/providers/models.ts
@@ -348,7 +348,7 @@ export const DynamicSecretMongoAtlasSchema = z.object({
export const DynamicSecretMongoDBSchema = z.object({
host: z.string().min(1).trim().toLowerCase(),
- port: z.number(),
+ port: z.number().optional().nullable(),
username: z.string().min(1).trim(),
password: z.string().min(1).trim(),
database: z.string().min(1).trim(),
@@ -753,7 +753,9 @@ export const DynamicSecretMilvusSchema = z.object({
"Privileges granted to an ephemeral role bound to the lease user. Leave empty to create the user with only the built-in public role."
),
ca: z.string().optional(),
- sslRejectUnauthorized: z.boolean().default(true)
+ sslRejectUnauthorized: z.boolean().default(true),
+ gatewayId: z.string().nullable().optional(),
+ gatewayPoolId: z.string().nullable().optional()
});
export enum DynamicSecretProviders {
diff --git a/frontend/src/hooks/api/dynamicSecret/types.ts b/frontend/src/hooks/api/dynamicSecret/types.ts
index 09db721bd2..66119a657b 100644
--- a/frontend/src/hooks/api/dynamicSecret/types.ts
+++ b/frontend/src/hooks/api/dynamicSecret/types.ts
@@ -496,6 +496,8 @@ export type TDynamicSecretProvider =
}>;
ca?: string;
sslRejectUnauthorized?: boolean;
+ gatewayId?: string | null;
+ gatewayPoolId?: string | null;
};
}
| {
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/MilvusInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/MilvusInputForm.tsx
index 3a787e2cb5..72ae6d18d3 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/MilvusInputForm.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/MilvusInputForm.tsx
@@ -6,6 +6,7 @@ import ms from "ms";
import { z } from "zod";
import { TtlFormLabel } from "@app/components/features";
+import { OrgPermissionCan } from "@app/components/permissions";
import {
Button,
FilterableSelect,
@@ -18,6 +19,11 @@ import {
Switch,
Tooltip
} from "@app/components/v2";
+import { GatewayPicker } from "@app/components/v3/platform/GatewayPicker";
+import {
+ OrgGatewayPermissionActions,
+ OrgPermissionSubjects
+} from "@app/context/OrgPermissionContext/types";
import { useCreateDynamicSecret } from "@app/hooks/api";
import { DynamicSecretProviders, MILVUS_OBJECT_TYPES } from "@app/hooks/api/dynamicSecret/types";
import { ProjectEnv } from "@app/hooks/api/types";
@@ -45,7 +51,9 @@ const formSchema = z.object({
)
.default([]),
ca: z.string().optional(),
- sslRejectUnauthorized: z.boolean().default(true)
+ sslRejectUnauthorized: z.boolean().default(true),
+ gatewayId: z.string().optional(),
+ gatewayPoolId: z.string().optional()
}),
defaultTTL: z.string().superRefine((val, ctx) => {
const valMs = ms(val);
@@ -92,7 +100,9 @@ export const MilvusInputForm = ({
const {
control,
formState: { isSubmitting },
- handleSubmit
+ handleSubmit,
+ setValue,
+ watch
} = useForm<TForm>({
resolver: zodResolver(formSchema),
defaultValues: {
@@ -115,6 +125,9 @@ export const MilvusInputForm = ({
name: "provider.privileges"
});
+ const providerGatewayId = watch("provider.gatewayId");
+ const providerGatewayPoolId = watch("provider.gatewayPoolId");
+
const createDynamicSecret = useCreateDynamicSecret();
const handleCreateDynamicSecret = async ({
@@ -201,6 +214,39 @@ export const MilvusInputForm = ({
<div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">
Configuration
</div>
+ <div>
+ <OrgPermissionCan
+ I={OrgGatewayPermissionActions.AttachGateways}
+ a={OrgPermissionSubjects.Gateway}
+ >
+ {(isAllowed) => (
+ <FormControl label="Gateway">
+ <Tooltip
+ isDisabled={isAllowed}
+ content="Restricted access. You don't have permission to attach gateways to resources."
+ >
+ <div>
+ <GatewayPicker
+ isDisabled={!isAllowed}
+ value={{
+ gatewayId: providerGatewayId ?? null,
+ gatewayPoolId: providerGatewayPoolId ?? null
+ }}
+ onChange={({ gatewayId: newGwId, gatewayPoolId: newPoolId }) => {
+ setValue("provider.gatewayId", newGwId ?? undefined, {
+ shouldDirty: true
+ });
+ setValue("provider.gatewayPoolId", newPoolId ?? undefined, {
+ shouldDirty: true
+ });
+ }}
+ />
+ </div>
+ </Tooltip>
+ </FormControl>
+ )}
+ </OrgPermissionCan>
+ </div>
<div className="flex flex-col">
<div className="flex items-start space-x-2">
<Controller
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretMilvusForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretMilvusForm.tsx
index 2827349200..6cb6e0381a 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretMilvusForm.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretMilvusForm.tsx
@@ -7,6 +7,7 @@ import { z } from "zod";
import { TtlFormLabel } from "@app/components/features";
import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
import {
Button,
FormControl,
@@ -18,6 +19,11 @@ import {
Switch,
Tooltip
} from "@app/components/v2";
+import { GatewayPicker } from "@app/components/v3/platform/GatewayPicker";
+import {
+ OrgGatewayPermissionActions,
+ OrgPermissionSubjects
+} from "@app/context/OrgPermissionContext/types";
import { useUpdateDynamicSecret } from "@app/hooks/api";
import {
DynamicSecretProviders,
@@ -57,7 +63,9 @@ const formSchema = z.object({
)
.default([]),
ca: z.string().optional(),
- sslRejectUnauthorized: z.boolean().optional()
+ sslRejectUnauthorized: z.boolean().optional(),
+ gatewayId: z.string().optional().nullable(),
+ gatewayPoolId: z.string().optional().nullable()
})
.partial(),
defaultTTL: z.string().superRefine((val, ctx) => {
@@ -110,7 +118,9 @@ export const EditDynamicSecretMilvusForm = ({
const {
control,
formState: { isSubmitting },
- handleSubmit
+ handleSubmit,
+ setValue,
+ watch
} = useForm<TForm>({
resolver: zodResolver(formSchema),
defaultValues: {
@@ -131,6 +141,9 @@ export const EditDynamicSecretMilvusForm = ({
name: "inputs.privileges"
});
+ const selectedGatewayId = watch("inputs.gatewayId");
+ const selectedGatewayPoolId = watch("inputs.gatewayPoolId");
+
const updateDynamicSecret = useUpdateDynamicSecret();
const handleUpdateDynamicSecret = async ({
@@ -157,7 +170,11 @@ export const EditDynamicSecretMilvusForm = ({
!usernameTemplate || usernameTemplate === "{{randomUsername}}"
? undefined
: usernameTemplate,
- inputs
+ inputs: {
+ ...inputs,
+ gatewayId: inputs.gatewayId ?? null,
+ gatewayPoolId: inputs.gatewayPoolId ?? null
+ }
}
});
@@ -227,6 +244,39 @@ export const EditDynamicSecretMilvusForm = ({
<div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">
Configuration
</div>
+ <div>
+ <OrgPermissionCan
+ I={OrgGatewayPermissionActions.AttachGateways}
+ a={OrgPermissionSubjects.Gateway}
+ >
+ {(isAllowed) => (
+ <FormControl label="Gateway">
+ <Tooltip
+ isDisabled={isAllowed}
+ content="Restricted access. You don't have permission to attach gateways to resources."
+ >
+ <div>
+ <GatewayPicker
+ isDisabled={!isAllowed}
+ value={{
+ gatewayId: selectedGatewayId ?? null,
+ gatewayPoolId: selectedGatewayPoolId ?? null
+ }}
+ onChange={({ gatewayId: newGwId, gatewayPoolId: newPoolId }) => {
+ setValue("inputs.gatewayId", newGwId ?? null, {
+ shouldDirty: true
+ });
+ setValue("inputs.gatewayPoolId", newPoolId ?? null, {
+ shouldDirty: true
+ });
+ }}
+ />
+ </div>
+ </Tooltip>
+ </FormControl>
+ )}
+ </OrgPermissionCan>
+ </div>
<div className="flex flex-col space-y-4">
<div className="flex items-start space-x-2">
<Controller