Skip to content

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

add new dynamic secret for milvus

adilson795a721c8e9a
diff --git a/backend/src/ee/services/dynamic-secret/providers/index.ts b/backend/src/ee/services/dynamic-secret/providers/index.ts
index 10348a9c1a..cd41e10c4e 100644
--- a/backend/src/ee/services/dynamic-secret/providers/index.ts
+++ b/backend/src/ee/services/dynamic-secret/providers/index.ts
@@ -16,6 +16,7 @@ import { GcpIamProvider } from "./gcp-iam";
import { GithubProvider } from "./github";
import { KubernetesProvider } from "./kubernetes";
import { LdapProvider } from "./ldap";
+import { MilvusProvider } from "./milvus";
import { DynamicSecretProviders, TDynamicProviderFns } from "./models";
import { MongoAtlasProvider } from "./mongo-atlas";
import { MongoDBProvider } from "./mongo-db";
@@ -66,5 +67,6 @@ export const buildDynamicSecretProviders = ({
[DynamicSecretProviders.GcpIam]: GcpIamProvider(),
[DynamicSecretProviders.Github]: GithubProvider(),
[DynamicSecretProviders.Couchbase]: CouchbaseProvider(),
+ [DynamicSecretProviders.Milvus]: MilvusProvider(),
[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
new file mode 100644
index 0000000000..37d6bda737
--- /dev/null
+++ b/backend/src/ee/services/dynamic-secret/providers/milvus.ts
@@ -0,0 +1,190 @@
+import https from "node:https";
+
+import { customAlphabet } from "nanoid";
+import { z } from "zod";
+
+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 { logger } from "@app/lib/logger";
+
+import { ActorIdentityAttributes } from "../../dynamic-secret-lease/dynamic-secret-lease-types";
+import { verifyHostInputValidity } from "../dynamic-secret-fns";
+import { DynamicSecretMilvusSchema, TDynamicProviderFns } from "./models";
+import { generateUsername } from "./templateUtils";
+
+type TMilvusProviderInputs = z.infer<typeof DynamicSecretMilvusSchema>;
+
+const generatePassword = () => {
+ const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_!@*";
+ return customAlphabet(charset, 32)();
+};
+
+const buildBaseUrl = (host: string, port: number) => {
+ const hasScheme = host.startsWith("http://") || host.startsWith("https://");
+ const normalized = hasScheme ? host : `http://${host}`;
+ return `${normalized}:${port}`;
+};
+
+const deriveRoleName = (username: string) => `infisical_role_${username}`;
+
+export const MilvusProvider = (): TDynamicProviderFns => {
+ const validateProviderInputs = async (inputs: object) => {
+ const providerInputs = await DynamicSecretMilvusSchema.parseAsync(inputs);
+ const { hostname } = new URL(buildBaseUrl(providerInputs.host, providerInputs.port));
+ await verifyHostInputValidity({ host: hostname, isDynamicSecret: true });
+ return providerInputs;
+ };
+
+ const $requestConfig = (providerInputs: TMilvusProviderInputs) => ({
+ baseURL: buildBaseUrl(providerInputs.host, providerInputs.port),
+ headers: {
+ Authorization: `Bearer ${providerInputs.username}:${providerInputs.password}`,
+ "Content-Type": "application/json"
+ },
+ timeout: 30000,
+ maxRedirects: 0,
+ ...(providerInputs.ca && {
+ httpsAgent: new https.Agent({
+ ca: providerInputs.ca,
+ rejectUnauthorized: providerInputs.sslRejectUnauthorized
+ })
+ })
+ });
+
+ const validateConnection = async (inputs: unknown) => {
+ const providerInputs = await validateProviderInputs(inputs as object);
+ try {
+ await request.post(
+ "/v2/vectordb/users/describe",
+ { userName: providerInputs.username },
+ $requestConfig(providerInputs)
+ );
+ return true;
+ } 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}` });
+ }
+ };
+
+ const create = async (data: {
+ inputs: unknown;
+ usernameTemplate?: string | null;
+ identity: ActorIdentityAttributes;
+ dynamicSecret: TDynamicSecrets;
+ }) => {
+ const { inputs, usernameTemplate, identity, dynamicSecret } = data;
+ const providerInputs = await validateProviderInputs(inputs as object);
+ const requestConfig = $requestConfig(providerInputs);
+
+ const username = await generateUsername(usernameTemplate, {
+ decryptedDynamicSecretInputs: inputs,
+ dynamicSecret,
+ identity
+ });
+ const password = generatePassword();
+ const roleName = deriveRoleName(username);
+
+ 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_v2",
+ {
+ roleName,
+ objectType: privilege.objectType,
+ collectionName: privilege.objectName,
+ privilege: privilege.privilege,
+ dbName: privilege.dbName ?? providerInputs.database
+ },
+ 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}]`);
+ }
+ }
+ 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 revoke = async (inputs: unknown, entityId: string) => {
+ const providerInputs = await validateProviderInputs(inputs as object);
+ const requestConfig = $requestConfig(providerInputs);
+ const username = entityId;
+ const roleName = deriveRoleName(username);
+
+ 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);
+ } catch (err) {
+ logger.error(err, `Failed to drop Milvus role [roleName=${roleName}]`);
+ }
+
+ 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}` });
+ }
+ };
+
+ const renew = async (_inputs: unknown, entityId: string) => {
+ return { entityId };
+ };
+
+ return {
+ validateProviderInputs,
+ validateConnection,
+ create,
+ revoke,
+ renew
+ };
+};
diff --git a/backend/src/ee/services/dynamic-secret/providers/models.ts b/backend/src/ee/services/dynamic-secret/providers/models.ts
index 58b1de9249..11686c8237 100644
--- a/backend/src/ee/services/dynamic-secret/providers/models.ts
+++ b/backend/src/ee/services/dynamic-secret/providers/models.ts
@@ -719,6 +719,37 @@ export const DynamicSecretCouchbaseSchema = z.object({
})
});
+export const DynamicSecretMilvusSchema = z.object({
+ host: z.string().trim().min(1).describe("Milvus endpoint host, including the URL scheme (e.g. http://localhost)"),
+ port: z.number(),
+ username: z.string().trim().min(1).describe("Admin username used to manage Milvus users and roles"),
+ password: z.string().trim().min(1).describe("Admin password used to manage Milvus users and roles"),
+ database: z.string().trim().min(1).default("default").describe("Default Milvus database used for privilege grants"),
+ privileges: z
+ .array(
+ z.object({
+ objectType: z
+ .string()
+ .trim()
+ .min(1)
+ .describe('Milvus object type (e.g. "Collection", "Database", "Global", "User", "Cluster")'),
+ objectName: z.string().trim().min(1).default("*").describe('Name of the target object, or "*" to apply to all'),
+ privilege: z
+ .string()
+ .trim()
+ .min(1)
+ .describe('Milvus privilege name or built-in privilege group (e.g. "Search", "COLL_RO", "DB_Admin")'),
+ dbName: z.string().trim().min(1).optional().describe("Optional database override for this privilege")
+ })
+ )
+ .default([])
+ .describe(
+ "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)
+});
+
export enum DynamicSecretProviders {
SqlDatabase = "sql-database",
Clickhouse = "clickhouse",
@@ -743,6 +774,7 @@ export enum DynamicSecretProviders {
GcpIam = "gcp-iam",
Github = "github",
Couchbase = "couchbase",
+ Milvus = "milvus",
Ssh = "ssh"
}
@@ -782,6 +814,7 @@ export const DynamicSecretProviderSchema = z.discriminatedUnion("type", [
z.object({ type: z.literal(DynamicSecretProviders.GcpIam), inputs: DynamicSecretGcpIamSchema }),
z.object({ type: z.literal(DynamicSecretProviders.Github), inputs: DynamicSecretGithubSchema }),
z.object({ type: z.literal(DynamicSecretProviders.Couchbase), inputs: DynamicSecretCouchbaseSchema }),
+ z.object({ type: z.literal(DynamicSecretProviders.Milvus), inputs: DynamicSecretMilvusSchema }),
z.object({ type: z.literal(DynamicSecretProviders.Ssh), inputs: DynamicSecretSshSchema })
]);
diff --git a/docs/docs.json b/docs/docs.json
index 162235f515..43be086d97 100644
--- a/docs/docs.json
+++ b/docs/docs.json
@@ -513,6 +513,7 @@
"documentation/platform/dynamic-secrets/gcp-iam",
"documentation/platform/dynamic-secrets/github",
"documentation/platform/dynamic-secrets/ldap",
+ "documentation/platform/dynamic-secrets/milvus",
"documentation/platform/dynamic-secrets/mongo-atlas",
"documentation/platform/dynamic-secrets/mongo-db",
"documentation/platform/dynamic-secrets/mssql",
diff --git a/docs/documentation/platform/dynamic-secrets/milvus.mdx b/docs/documentation/platform/dynamic-secrets/milvus.mdx
new file mode 100644
index 0000000000..0419f0d888
--- /dev/null
+++ b/docs/documentation/platform/dynamic-secrets/milvus.mdx
@@ -0,0 +1,123 @@
+---
+title: "Milvus"
+description: "Learn how to dynamically generate Milvus user credentials with custom privileges."
+---
+
+import DynamicSecretUsernameTemplateParamField from "/snippets/documentation/platform/dynamic-secrets/dynamic-secret-username-template-field.mdx";
+
+The Infisical Milvus dynamic secret allows you to generate Milvus credentials on demand, with configurable privileges scoped to the lease.
+
+## Prerequisites
+
+1. Ensure that authentication and RBAC are enabled on your Milvus instance by setting `common.security.authorizationEnabled=true`.
+2. Have an admin user (defaults to `root` / `Milvus`) available to manage users, roles, and privileges via the [Milvus REST API](https://milvus.io/api-reference/restful/v2.5.x/About.md).
+
+## Set up Dynamic Secrets with Milvus
+
+<Steps>
+ <Step title="Open Secret Overview Dashboard">
+ Open the Secret Overview dashboard and select the environment in which you would like to add a dynamic secret.
+ </Step>
+ <Step title="Click on the 'Add Dynamic Secret' button">
+ ![Add Dynamic Secret Button](../../../images/platform/dynamic-secrets/add-dynamic-secret-button.png)
+ </Step>
+ <Step title="Select Milvus">
+ Choose Milvus from the list of available dynamic secret providers.
+ </Step>
+ <Step title="Provide the inputs for dynamic secret parameters">
+ <ParamField path="Secret Name" type="string" required>
+ Name by which you want the secret to be referenced
+ </ParamField>
+
+ <ParamField path="Default TTL" type="string" required>
+ Default time-to-live for a generated secret (it is possible to modify this value after a secret is generated)
+ </ParamField>
+
+ <ParamField path="Max TTL" type="string" required>
+ Maximum time-to-live for a generated secret.
+ </ParamField>
+
+ <ParamField path="Host" type="string" required>
+ Your Milvus endpoint. Include the URL scheme (`http://` or `https://`). _Example: `http://localhost`._ If the scheme is omitted, `http://` is assumed.
+ </ParamField>
+
+ <ParamField path="Port" type="number" required>
+ The port your Milvus REST API listens on. Defaults to `19530`.
+ </ParamField>
+
+ <ParamField path="Admin Username" type="string" required>
+ The admin username used to manage users, roles, and privileges (e.g. `root`).
+ </ParamField>
+
+ <ParamField path="Admin Password" type="string" required>
+ The password for the admin user.
+ </ParamField>
+
+ <ParamField path="Default Database" type="string" required>
+ Default Milvus database used as the `dbName` for granted privileges when not explicitly overridden per privilege. Defaults to `default`.
+ </ParamField>
+
+ <ParamField path="Privileges" type="array">
+ Privileges granted to an ephemeral role bound to the lease user. Leave empty to create a user with only the built-in `public` role.
+
+ Each privilege entry has:
+ - `Object Type` — Milvus object type (`Collection`, `Database`, `Global`, `Cluster`, or `User`).
+ - `Object Name` — Name of the target object (e.g. a collection name) or `*` to apply to all.
+ - `Privilege` — Milvus privilege name or built-in privilege group (e.g. `Search`, `Query`, `COLL_RO`, `DB_Admin`). See the [Milvus privilege reference](https://milvus.io/docs/grant_privileges.md) for the full list.
+ - `DB Name` — Optional override for the target database. Falls back to the provider's Default Database when blank.
+
+ **Examples:**
+ - Read-only on all collections: `{ Object Type: Collection, Object Name: *, Privilege: COLL_RO }`
+ - Full database admin: `{ Object Type: Database, Object Name: *, Privilege: DB_Admin }`
+ - Search on a specific collection: `{ Object Type: Collection, Object Name: my_collection, Privilege: Search }`
+ </ParamField>
+
+ <DynamicSecretUsernameTemplateParamField />
+
+ <ParamField path="CA Certificate" type="string">
+ Optional PEM-encoded CA certificate for verifying the Milvus server's TLS certificate. Required when Milvus uses a self-signed or private CA.
+ </ParamField>
+
+ </Step>
+ <Step title="Click `Submit`">
+ After submitting the form, you will see the Milvus dynamic secret created in the dashboard.
+
+ <Note>
+ Infisical validates the connection by calling the Milvus `/v2/vectordb/users/describe` endpoint. If validation fails, double-check the host, port, and admin credentials.
+ </Note>
+
+ </Step>
+ <Step title="Generate dynamic secrets">
+ Once configured, click `Generate` (or `New Lease`) on the dynamic secret to issue an on-demand credential.
+
+ Each lease creates a Milvus user with a random username and password. When you configure privileges, Infisical also creates an ephemeral role per lease, grants the configured privileges to it, and assigns the role to the user. On revoke, the user and role are deleted together.
+
+ ![Provision Lease](/images/platform/dynamic-secrets/provision-lease.png)
+
+ <Tip>
+ Ensure that the TTL for the lease falls within the maximum TTL defined when configuring the dynamic secret.
+ </Tip>
+
+ Once you click the `Submit` button, a new secret lease will be generated and the credentials from it will be shown to you.
+
+ ![Provision Lease](/images/platform/dynamic-secrets/lease-values.png)
+
+ </Step>
+</Steps>
+
+## Audit or Revoke Leases
+
+Once you have created one or more leases, you can access them by clicking on the dynamic secret item on the dashboard. From there you can view the expiration time or revoke a lease early.
+
+![Provision Lease](/images/platform/dynamic-secrets/lease-data.png)
+
+## Renew Leases
+
+To extend the life of a generated lease, click the **Renew** button.
+
+![Provision Lease](/images/platform/dynamic-secrets/dynamic-secret-lease-renew.png)
+
+<Warning>
+ Lease renewals cannot exceed the maximum TTL set when configuring the dynamic
+ secret.
+</Warning>
diff --git a/frontend/src/hooks/api/dynamicSecret/types.ts b/frontend/src/hooks/api/dynamicSecret/types.ts
index 2df02f1d32..09db721bd2 100644
--- a/frontend/src/hooks/api/dynamicSecret/types.ts
+++ b/frontend/src/hooks/api/dynamicSecret/types.ts
@@ -42,6 +42,7 @@ export enum DynamicSecretProviders {
Github = "github",
Couchbase = "couchbase",
Clickhouse = "clickhouse",
+ Milvus = "milvus",
Ssh = "ssh"
}
@@ -73,6 +74,14 @@ export enum DynamicSecretAwsIamCredentialType {
TemporaryCredentials = "temporary-credentials"
}
+export const MILVUS_OBJECT_TYPES = [
+ { label: "Collection", value: "Collection" },
+ { label: "Database", value: "Database" },
+ { label: "Global", value: "Global" },
+ { label: "Cluster", value: "Cluster" },
+ { label: "User", value: "User" }
+] as const;
+
export type TDynamicSecretProvider =
| {
type: DynamicSecretProviders.SqlDatabase;
@@ -471,6 +480,24 @@ export type TDynamicSecretProvider =
};
};
}
+ | {
+ type: DynamicSecretProviders.Milvus;
+ inputs: {
+ host: string;
+ port: number;
+ username: string;
+ password: string;
+ database?: string;
+ privileges: Array<{
+ objectType: string;
+ objectName: string;
+ privilege: string;
+ dbName?: string;
+ }>;
+ ca?: string;
+ sslRejectUnauthorized?: boolean;
+ };
+ }
| {
type: DynamicSecretProviders.Ssh;
inputs: {
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/CreateDynamicSecretForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/CreateDynamicSecretForm.tsx
index 56da897dfb..5d5dce9b9f 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/CreateDynamicSecretForm.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/CreateDynamicSecretForm.tsx
@@ -7,6 +7,7 @@ import {
SiElasticsearch,
SiFiles,
SiKubernetes,
+ SiMilvus,
SiMongodb,
SiRabbitmq,
SiSap,
@@ -36,6 +37,7 @@ import { GcpIamInputForm } from "./GcpIamInputForm";
import { GithubInputForm } from "./GithubInputForm";
import { KubernetesInputForm } from "./KubernetesInputForm";
import { LdapInputForm } from "./LdapInputForm";
+import { MilvusInputForm } from "./MilvusInputForm";
import { MongoAtlasInputForm } from "./MongoAtlasInputForm";
import { MongoDBDatabaseInputForm } from "./MongoDBInputForm";
import { RabbitMqInputForm } from "./RabbitMqInputForm";
@@ -173,6 +175,11 @@ const DYNAMIC_SECRET_LIST = [
provider: DynamicSecretProviders.Couchbase,
title: "Couchbase"
},
+ {
+ icon: <SiMilvus size="1.5rem" />,
+ provider: DynamicSecretProviders.Milvus,
+ title: "Milvus"
+ },
{
icon: <SiClickhouse size="1.5rem" />,
provider: DynamicSecretProviders.Clickhouse,
@@ -681,6 +688,25 @@ export const CreateDynamicSecretForm = ({
/>
</motion.div>
)}
+ {wizardStep === WizardSteps.ProviderInputs &&
+ selectedProvider === DynamicSecretProviders.Milvus && (
+ <motion.div
+ key="dynamic-milvus-step"
+ transition={{ duration: 0.1 }}
+ initial={{ opacity: 0, translateX: 30 }}
+ animate={{ opacity: 1, translateX: 0 }}
+ exit={{ opacity: 0, translateX: -30 }}
+ >
+ <MilvusInputForm
+ onCompleted={handleFormReset}
+ onCancel={handleFormReset}
+ projectSlug={projectSlug}
+ secretPath={secretPath}
+ environments={environments}
+ isSingleEnvironmentMode={isSingleEnvironmentMode}
+ />
+ </motion.div>
+ )}
{wizardStep === WizardSteps.ProviderInputs &&
selectedProvider === DynamicSecretProviders.Clickhouse && (
<motion.div
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
new file mode 100644
index 0000000000..7246afe21e
--- /dev/null
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/MilvusInputForm.tsx
@@ -0,0 +1,486 @@
+import { Controller, useFieldArray, useForm } from "react-hook-form";
+import { faPlus, faTrash } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { zodResolver } from "@hookform/resolvers/zod";
+import ms from "ms";
+import { z } from "zod";
+
+import { TtlFormLabel } from "@app/components/features";
+import {
+ Button,
+ FilterableSelect,
+ FormControl,
+ FormLabel,
+ IconButton,
+ Input,
+ SecretInput,
+ Select,
+ SelectItem
+} from "@app/components/v2";
+import { useCreateDynamicSecret } from "@app/hooks/api";
+import { DynamicSecretProviders, MILVUS_OBJECT_TYPES } from "@app/hooks/api/dynamicSecret/types";
+import { ProjectEnv } from "@app/hooks/api/types";
+import { slugSchema } from "@app/lib/schemas";
+
+const formSchema = z.object({
+ provider: z.object({
+ host: z.string().trim().min(1),
+ port: z.coerce.number(),
+ username: z.string().trim().min(1),
+ password: z.string().trim().min(1),
+ database: z.string().trim().min(1).default("default"),
+ privileges: z
+ .array(
+ z.object({
+ objectType: z.string().trim().min(1),
+ objectName: z.string().trim().min(1).default("*"),
+ privilege: z.string().trim().min(1),
+ dbName: z
+ .string()
+ .trim()
+ .optional()
+ .transform((val) => (val && val.length > 0 ? val : undefined))
+ })
+ )
+ .default([]),
+ ca: z.string().optional(),
+ sslRejectUnauthorized: z.boolean().optional()
+ }),
+ defaultTTL: z.string().superRefine((val, ctx) => {
+ const valMs = ms(val);
+ if (valMs < 60 * 1000)
+ ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });
+ if (valMs > ms("10y"))
+ ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });
+ }),
+ maxTTL: z
+ .string()
+ .optional()
+ .superRefine((val, ctx) => {
+ if (!val) return;
+ const valMs = ms(val);
+ if (valMs < 60 * 1000)
+ ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });
+ if (valMs > ms("10y"))
+ ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });
+ }),
+ name: slugSchema(),
+ environment: z.object({ name: z.string(), slug: z.string() }),
+ usernameTemplate: z.string().nullable().optional()
+});
+
+type TForm = z.infer<typeof formSchema>;
+
+type Props = {
+ onCompleted: () => void;
+ onCancel: () => void;
+ secretPath: string;
+ projectSlug: string;
+ environments: ProjectEnv[];
+ isSingleEnvironmentMode?: boolean;
+};
+
+export const MilvusInputForm = ({
+ onCompleted,
+ onCancel,
+ environments,
+ secretPath,
+ projectSlug,
+ isSingleEnvironmentMode
+}: Props) => {
+ const {
+ control,
+ formState: { isSubmitting },
+ handleSubmit
+ } = useForm<TForm>({
+ resolver: zodResolver(formSchema),
+ defaultValues: {
+ provider: {
+ host: "http://localhost",
+ port: 19530,
+ username: "root",
+ password: "",
+ database: "default",
+ privileges: []
+ },
+ environment: isSingleEnvironmentMode ? environments[0] : undefined,
+ usernameTemplate: "{{randomUsername}}"
+ }
+ });
+
+ const privilegeFields = useFieldArray({
+ control,
+ name: "provider.privileges"
+ });
+
+ const createDynamicSecret = useCreateDynamicSecret();
+
+ const handleCreateDynamicSecret = async ({
+ name,
+ maxTTL,
+ provider,
+ defaultTTL,
+ environment,
+ usernameTemplate
+ }: TForm) => {
+ if (createDynamicSecret.isPending) return;
+
+ const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
+
+ await createDynamicSecret.mutateAsync({
+ provider: { type: DynamicSecretProviders.Milvus, inputs: provider },
+ maxTTL,
+ name,
+ path: secretPath,
+ defaultTTL,
+ projectSlug,
+ environmentSlug: environment.slug,
+ usernameTemplate:
+ !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate
+ });
+ onCompleted();
+ };
+
+ return (
+ <div>
+ <form onSubmit={handleSubmit(handleCreateDynamicSecret)} autoComplete="off">
+ <div>
+ <div className="flex items-center space-x-2">
+ <div className="grow">
+ <Controller
+ control={control}
+ defaultValue=""
+ name="name"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Secret Name"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="dynamic-secret" />
+ </FormControl>
+ )}
+ />
+ </div>
+ <div className="w-32">
+ <Controller
+ control={control}
+ name="defaultTTL"
+ defaultValue="1h"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label={<TtlFormLabel label="Default TTL" />}
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <Input {...field} />
+ </FormControl>
+ )}
+ />
+ </div>
+ <div className="w-32">
+ <Controller
+ control={control}
+ name="maxTTL"
+ defaultValue="24h"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label={<TtlFormLabel label="Max TTL" />}
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <Input {...field} />
+ </FormControl>
+ )}
+ />
+ </div>
+ </div>
+ <div>
+ <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">
+ Configuration
+ </div>
+ <div className="flex flex-col">
+ <div className="flex items-center space-x-2">
+ <Controller
+ control={control}
+ name="provider.host"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Host"
+ className="grow"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ helperText="Include the URL scheme (http:// or https://). Defaults to http if omitted."
+ >
+ <Input {...field} placeholder="http://localhost" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="provider.port"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Port"
+ className="w-32"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <Input {...field} type="number" placeholder="19530" />
+ </FormControl>
+ )}
+ />
+ </div>
+ <div className="flex items-center space-x-2">
+ <Controller
+ control={control}
+ name="provider.username"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Admin Username"
+ className="grow"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="root" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="provider.password"
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl
+ label="Admin Password"
+ className="grow"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <SecretInput
+ containerClassName="text-gray-400 group-focus-within:border-primary-400/50! border border-mineshaft-500 bg-mineshaft-900 px-2.5 py-1.5"
+ value={value}
+ valueAlwaysHidden
+ rows={1}
+ wrap="hard"
+ onChange={(e) => onChange(e.target.value)}
+ />
+ </FormControl>
+ )}
+ />
+ </div>
+ <Controller
+ control={control}
+ name="provider.database"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Default Database"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ helperText="Used as the dbName for granted privileges when not explicitly overridden."
+ >
+ <Input {...field} placeholder="default" />
+ </FormControl>
+ )}
+ />
+ <FormLabel
+ label="Privileges"
+ isOptional
+ className="mb-2"
+ tooltipClassName="max-w-md whitespace-pre-line"
+ tooltipText={
+ "Privileges granted to an ephemeral role assigned to the lease user. " +
+ "Leave empty to create a user with only the built-in public role. " +
+ "See https://milvus.io/docs/grant_privileges.md for the full list."
+ }
+ />
+ <div className="mb-3 flex flex-col space-y-2">
+ {privilegeFields.fields.map(({ id: privilegeFieldId }, i) => (
+ <div key={privilegeFieldId} className="flex items-end space-x-2">
+ <div className="w-36">
+ {i === 0 && <span className="text-xs text-mineshaft-400">Object Type</span>}
+ <Controller
+ control={control}
+ name={`provider.privileges.${i}.objectType`}
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ className="mb-0"
+ >
+ <Select
+ value={field.value}
+ onValueChange={(value) => field.onChange(value)}
+ className="w-full"
+ >
+ {MILVUS_OBJECT_TYPES.map((option) => (
+ <SelectItem
+ value={option.value}
+ key={`milvus-object-type-${option.value}`}
+ >
+ {option.label}
+ </SelectItem>
+ ))}
+ </Select>
+ </FormControl>
+ )}
+ />
+ </div>
+ <div className="grow">
+ {i === 0 && <span className="text-xs text-mineshaft-400">Object Name</span>}
+ <Controller
+ control={control}
+ name={`provider.privileges.${i}.objectName`}
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ className="mb-0"
+ >
+ <Input {...field} placeholder="*" />
+ </FormControl>
+ )}
+ />
+ </div>
+ <div className="grow">
+ {i === 0 && <span className="text-xs text-mineshaft-400">Privilege</span>}
+ <Controller
+ control={control}
+ name={`provider.privileges.${i}.privilege`}
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ className="mb-0"
+ >
+ <Input {...field} placeholder="Search" />
+ </FormControl>
+ )}
+ />
+ </div>
+ <div className="grow">
+ {i === 0 && (
+ <FormLabel
+ label="DB Name"
+ isOptional
+ className="text-xs text-mineshaft-400"
+ />
+ )}
+ <Controller
+ control={control}
+ name={`provider.privileges.${i}.dbName`}
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ className="mb-0"
+ >
+ <Input
+ value={field.value || ""}
+ onChange={(e) => field.onChange(e.target.value)}
+ placeholder="default"
+ />
+ </FormControl>
+ )}
+ />
+ </div>
+ <IconButton
+ ariaLabel="Remove privilege"
+ className="bottom-0.5 h-9"
+ variant="outline_bg"
+ onClick={() => privilegeFields.remove(i)}
+ >
+ <FontAwesomeIcon icon={faTrash} />
+ </IconButton>
+ </div>
+ ))}
+ <div>
+ <Button
+ type="button"
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ size="xs"
+ variant="outline_bg"
+ onClick={() =>
+ privilegeFields.append({
+ objectType: "Collection",
+ objectName: "*",
+ privilege: "",
+ dbName: undefined
+ })
+ }
+ >
+ Add Privilege
+ </Button>
+ </div>
+ </div>
+ <Controller
+ control={control}
+ name="usernameTemplate"
+ defaultValue=""
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Username Template"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <Input
+ {...field}
+ value={field.value || undefined}
+ className="border-mineshaft-600 bg-mineshaft-900 text-sm"
+ placeholder="{{randomUsername}}"
+ />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="provider.ca"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="CA Certificate"
+ isOptional
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ helperText="PEM-encoded CA certificate for verifying the Milvus server's TLS certificate."
+ >
+ <Input {...field} value={field.value || ""} />
+ </FormControl>
+ )}
+ />
+ {!isSingleEnvironmentMode && (
+ <Controller
+ control={control}
+ name="environment"
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl
+ label="Environment"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <FilterableSelect
+ options={environments}
+ value={value}
+ onChange={onChange}
+ placeholder="Select the environment to create secret in..."
+ getOptionLabel={(option) => option.name}
+ getOptionValue={(option) => option.slug}
+ menuPlacement="top"
+ />
+ </FormControl>
+ )}
+ />
+ )}
+ </div>
+ </div>
+ </div>
+ <div className="mt-4 flex items-center space-x-4">
+ <Button type="submit" isLoading={isSubmitting}>
+ Submit
+ </Button>
+ <Button variant="outline_bg" onClick={onCancel}>
+ Cancel
+ </Button>
+ </div>
+ </form>
+ </div>
+ );
+};
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretForm.tsx
index 7974af258c..b146ffb2c7 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretForm.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretForm.tsx
@@ -17,6 +17,7 @@ import { EditDynamicSecretGcpIamForm } from "./EditDynamicSecretGcpIamForm";
import { EditDynamicSecretGithubForm } from "./EditDynamicSecretGithubForm";
import { EditDynamicSecretKubernetesForm } from "./EditDynamicSecretKubernetesForm";
import { EditDynamicSecretLdapForm } from "./EditDynamicSecretLdapForm";
+import { EditDynamicSecretMilvusForm } from "./EditDynamicSecretMilvusForm";
import { EditDynamicSecretMongoAtlasForm } from "./EditDynamicSecretMongoAtlasForm";
import { EditDynamicSecretMongoDBForm } from "./EditDynamicSecretMongoDBForm";
import { EditDynamicSecretRabbitMqForm } from "./EditDynamicSecretRabbitMqForm";
@@ -424,6 +425,23 @@ export const EditDynamicSecretForm = ({
/>
</motion.div>
)}
+ {dynamicSecretDetails?.type === DynamicSecretProviders.Milvus && (
+ <motion.div
+ key="milvus-edit"
+ transition={{ duration: 0.1 }}
+ initial={{ opacity: 0, translateX: 30 }}
+ animate={{ opacity: 1, translateX: 0 }}
+ exit={{ opacity: 0, translateX: -30 }}
+ >
+ <EditDynamicSecretMilvusForm
+ onClose={onClose}
+ projectSlug={projectSlug}
+ secretPath={secretPath}
+ dynamicSecret={dynamicSecretDetails}
+ environment={environment}
+ />
+ </motion.div>
+ )}
{dynamicSecretDetails?.type === DynamicSecretProviders.Couchbase && (
<motion.div
key="couchbase-edit"
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
new file mode 100644
index 0000000000..2dbe80346b
--- /dev/null
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretMilvusForm.tsx
@@ -0,0 +1,476 @@
+import { Controller, useFieldArray, useForm } from "react-hook-form";
+import { faPlus, faTrash } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { zodResolver } from "@hookform/resolvers/zod";
+import ms from "ms";
+import { z } from "zod";
+
+import { TtlFormLabel } from "@app/components/features";
+import { createNotification } from "@app/components/notifications";
+import {
+ Button,
+ FormControl,
+ FormLabel,
+ IconButton,
+ Input,
+ SecretInput,
+ Select,
+ SelectItem
+} from "@app/components/v2";
+import { useUpdateDynamicSecret } from "@app/hooks/api";
+import { MILVUS_OBJECT_TYPES, TDynamicSecret } from "@app/hooks/api/dynamicSecret/types";
+import { slugSchema } from "@app/lib/schemas";
+
+import { MetadataForm } from "../MetadataForm";
+
+const formSchema = z.object({
+ inputs: z
+ .object({
+ host: z.string().trim().min(1),
+ port: z.coerce.number(),
+ username: z.string().trim().min(1),
+ password: z.string().trim().min(1),
+ database: z.string().trim().min(1).default("default"),
+ privileges: z
+ .array(
+ z.object({
+ objectType: z.string().trim().min(1),
+ objectName: z.string().trim().min(1).default("*"),
+ privilege: z.string().trim().min(1),
+ dbName: z
+ .string()
+ .trim()
+ .optional()
+ .transform((val) => (val && val.length > 0 ? val : undefined))
+ })
+ )
+ .default([]),
+ ca: z.string().optional(),
+ sslRejectUnauthorized: z.boolean().optional()
+ })
+ .partial(),
+ defaultTTL: z.string().superRefine((val, ctx) => {
+ const valMs = ms(val);
+ if (valMs < 60 * 1000)
+ ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });
+ if (valMs > ms("10y"))
+ ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });
+ }),
+ maxTTL: z
+ .string()
+ .optional()
+ .superRefine((val, ctx) => {
+ if (!val) return;
+ const valMs = ms(val);
+ if (valMs < 60 * 1000)
+ ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });
+ if (valMs > ms("10y"))
+ ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });
+ })
+ .nullable(),
+ newName: slugSchema().optional(),
+ metadata: z
+ .object({
+ key: z.string().trim().min(1),
+ value: z.string().trim().default("")
+ })
+ .array()
+ .optional(),
+ usernameTemplate: z.string().trim().nullable().optional()
+});
+
+type TForm = z.infer<typeof formSchema>;
+
+type Props = {
+ onClose: () => void;
+ dynamicSecret: TDynamicSecret & { inputs: unknown };
+ secretPath: string;
+ projectSlug: string;
+ environment: string;
+};
+
+export const EditDynamicSecretMilvusForm = ({
+ onClose,
+ dynamicSecret,
+ secretPath,
+ environment,
+ projectSlug
+}: Props) => {
+ const {
+ control,
+ formState: { isSubmitting },
+ handleSubmit
+ } = useForm<TForm>({
+ resolver: zodResolver(formSchema),
+ defaultValues: {
+ defaultTTL: dynamicSecret.defaultTTL,
+ maxTTL: dynamicSecret.maxTTL || undefined,
+ newName: dynamicSecret.name,
+ metadata: dynamicSecret.metadata,
+ usernameTemplate: dynamicSecret.usernameTemplate,
+ inputs: {
+ ...(dynamicSecret.inputs as any),
+ privileges: (dynamicSecret.inputs as any)?.privileges ?? []
+ }
+ }
+ });
+
+ const privilegeFields = useFieldArray({
+ control,
+ name: "inputs.privileges"
+ });
+
+ const updateDynamicSecret = useUpdateDynamicSecret();
+
+ const handleUpdateDynamicSecret = async ({
+ inputs,
+ newName,
+ defaultTTL,
+ maxTTL,
+ metadata,
+ usernameTemplate
+ }: TForm) => {
+ if (updateDynamicSecret.isPending) return;
+
+ await updateDynamicSecret.mutateAsync({
+ name: dynamicSecret.name,
+ path: secretPath,
+ projectSlug,
+ environmentSlug: environment,
+ data: {
+ defaultTTL,
+ maxTTL: maxTTL || undefined,
+ newName: newName === dynamicSecret.name ? undefined : newName,
+ metadata,
+ usernameTemplate:
+ !usernameTemplate || usernameTemplate === "{{randomUsername}}"
+ ? undefined
+ : usernameTemplate,
+ inputs
+ }
+ });
+
+ createNotification({
+ type: "success",
+ text: "Successfully updated dynamic secret"
+ });
+
+ onClose();
+ };
+
+ return (
+ <div>
+ <form onSubmit={handleSubmit(handleUpdateDynamicSecret)} autoComplete="off">
+ <div>
+ <div className="flex items-center space-x-2">
+ <div className="grow">
+ <Controller
+ control={control}
+ name="newName"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Secret Name"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="dynamic-secret" />
+ </FormControl>
+ )}
+ />
+ </div>
+ <div className="w-32">
+ <Controller
+ control={control}
+ name="defaultTTL"
+ defaultValue="1h"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label={<TtlFormLabel label="Default TTL" />}
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <Input {...field} />
+ </FormControl>
+ )}
+ />
+ </div>
+ <div className="w-32">
+ <Controller
+ control={control}
+ name="maxTTL"
+ defaultValue="24h"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label={<TtlFormLabel label="Max TTL" />}
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <Input {...field} value={field.value || ""} />
+ </FormControl>
+ )}
+ />
+ </div>
+ </div>
+ <MetadataForm control={control} />
+ <div>
+ <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">
+ Configuration
+ </div>
+ <div className="flex flex-col space-y-4">
+ <div className="flex items-center space-x-2">
+ <Controller
+ control={control}
+ name="inputs.host"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Host"
+ className="grow"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="http://localhost" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="inputs.port"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Port"
+ className="w-32"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <Input {...field} type="number" placeholder="19530" />
+ </FormControl>
+ )}
+ />
+ </div>
+ <div className="flex items-center space-x-2">
+ <Controller
+ control={control}
+ name="inputs.username"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Username"
+ className="grow"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <Input {...field} />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="inputs.password"
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl
+ label="Password"
+ className="grow"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <SecretInput
+ containerClassName="text-gray-400 group-focus-within:border-primary-400/50! border border-mineshaft-500 bg-mineshaft-900 px-2.5 py-1.5"
+ value={value || ""}
+ valueAlwaysHidden
+ rows={1}
+ wrap="hard"
+ onChange={(e) => onChange(e.target.value)}
+ />
+ </FormControl>
+ )}
+ />
+ </div>
+ <Controller
+ control={control}
+ name="inputs.database"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Default Database"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ helperText="Used as the dbName for granted privileges when not explicitly overridden."
+ >
+ <Input {...field} placeholder="default" />
+ </FormControl>
+ )}
+ />
+ <FormLabel
+ label="Privileges"
+ isOptional
+ className="mb-2"
+ tooltipClassName="max-w-md whitespace-pre-line"
+ tooltipText={
+ "Privileges granted to an ephemeral role assigned to the lease user. " +
+ "Leave empty to create a user with only the built-in public role."
+ }
+ />
+ <div className="mb-3 flex flex-col space-y-2">
+ {privilegeFields.fields.map(({ id: privilegeFieldId }, i) => (
+ <div key={privilegeFieldId} className="flex items-end space-x-2">
+ <div className="w-36">
+ {i === 0 && <span className="text-xs text-mineshaft-400">Object Type</span>}
+ <Controller
+ control={control}
+ name={`inputs.privileges.${i}.objectType`}
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ className="mb-0"
+ >
+ <Select
+ value={field.value}
+ onValueChange={(value) => field.onChange(value)}
+ className="w-full"
+ >
+ {MILVUS_OBJECT_TYPES.map((option) => (
+ <SelectItem
+ value={option.value}
+ key={`milvus-edit-object-type-${option.value}`}
+ >
+ {option.label}
+ </SelectItem>
+ ))}
+ </Select>
+ </FormControl>
+ )}
+ />
+ </div>
+ <div className="grow">
+ {i === 0 && <span className="text-xs text-mineshaft-400">Object Name</span>}
+ <Controller
+ control={control}
+ name={`inputs.privileges.${i}.objectName`}
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ className="mb-0"
+ >
+ <Input {...field} placeholder="*" />
+ </FormControl>
+ )}
+ />
+ </div>
+ <div className="grow">
+ {i === 0 && <span className="text-xs text-mineshaft-400">Privilege</span>}
+ <Controller
+ control={control}
+ name={`inputs.privileges.${i}.privilege`}
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ className="mb-0"
+ >
+ <Input {...field} placeholder="Search" />
+ </FormControl>
+ )}
+ />
+ </div>
+ <div className="grow">
+ {i === 0 && (
+ <FormLabel
+ label="DB Name"
+ isOptional
+ className="text-xs text-mineshaft-400"
+ />
+ )}
+ <Controller
+ control={control}
+ name={`inputs.privileges.${i}.dbName`}
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ className="mb-0"
+ >
+ <Input
+ value={field.value || ""}
+ onChange={(e) => field.onChange(e.target.value)}
+ placeholder="default"
+ />
+ </FormControl>
+ )}
+ />
+ </div>
+ <IconButton
+ ariaLabel="Remove privilege"
+ className="bottom-0.5 h-9"
+ variant="outline_bg"
+ onClick={() => privilegeFields.remove(i)}
+ >
+ <FontAwesomeIcon icon={faTrash} />
+ </IconButton>
+ </div>
+ ))}
+ <div>
+ <Button
+ type="button"
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ size="xs"
+ variant="outline_bg"
+ onClick={() =>
+ privilegeFields.append({
+ objectType: "Collection",
+ objectName: "*",
+ privilege: "",
+ dbName: undefined
+ })
+ }
+ >
+ Add Privilege
+ </Button>
+ </div>
+ </div>
+ <Controller
+ control={control}
+ name="usernameTemplate"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Username Template"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <Input
+ {...field}
+ value={field.value || ""}
+ className="border-mineshaft-600 bg-mineshaft-900 text-sm"
+ placeholder="{{randomUsername}}"
+ />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="inputs.ca"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="CA Certificate"
+ isOptional
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <Input {...field} value={field.value || ""} />
+ </FormControl>
+ )}
+ />
+ </div>
+ </div>
+ </div>
+ <div className="mt-4 flex items-center space-x-4">
+ <Button type="submit" isLoading={isSubmitting}>
+ Submit
+ </Button>
+ <Button variant="outline_bg" onClick={onClose}>
+ Cancel
+ </Button>
+ </div>
+ </form>
+ </div>
+ );
+};