Skip to content

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

feat: add support for API key

adilson063816aa75a6
diff --git a/backend/src/ee/services/dynamic-secret/providers/index.ts b/backend/src/ee/services/dynamic-secret/providers/index.ts
index ed7f99c22c..bdb9eeadb0 100644
--- a/backend/src/ee/services/dynamic-secret/providers/index.ts
+++ b/backend/src/ee/services/dynamic-secret/providers/index.ts
@@ -27,6 +27,7 @@ import { SapAseProvider } from "./sap-ase";
import { SapHanaProvider } from "./sap-hana";
import { SqlDatabaseProvider } from "./sql-database";
import { SshProvider } from "./ssh";
+import { TailscaleProvider } from "./tailscale";
import { TotpProvider } from "./totp";
import { VerticaProvider } from "./vertica";
@@ -70,5 +71,6 @@ export const buildDynamicSecretProviders = ({
[DynamicSecretProviders.Couchbase]: CouchbaseProvider(),
[DynamicSecretProviders.Milvus]: MilvusProvider({ gatewayService, gatewayV2Service, gatewayPoolService }),
[DynamicSecretProviders.Ssh]: SshProvider(),
- [DynamicSecretProviders.IbmApiConnect]: IbmApiConnectProvider()
+ [DynamicSecretProviders.IbmApiConnect]: IbmApiConnectProvider(),
+ [DynamicSecretProviders.Tailscale]: TailscaleProvider()
});
diff --git a/backend/src/ee/services/dynamic-secret/providers/models.ts b/backend/src/ee/services/dynamic-secret/providers/models.ts
index 461a0091f7..e3414f0027 100644
--- a/backend/src/ee/services/dynamic-secret/providers/models.ts
+++ b/backend/src/ee/services/dynamic-secret/providers/models.ts
@@ -790,7 +790,8 @@ export enum DynamicSecretProviders {
Couchbase = "couchbase",
Milvus = "milvus",
Ssh = "ssh",
- IbmApiConnect = "ibm-api-connect"
+ IbmApiConnect = "ibm-api-connect",
+ Tailscale = "tailscale"
}
export const DynamicSecretIbmApiConnectSchema = z.object({
@@ -806,6 +807,56 @@ export const DynamicSecretIbmApiConnectSchema = z.object({
gatewayPoolId: z.string().nullable().optional()
});
+export enum TailscaleKeyAuthType {
+ AuthKeys = "auth_keys",
+ OAuthKeys = "oauth_keys"
+}
+
+export const DynamicSecretTailscaleSchema = z.discriminatedUnion("authType", [
+ z.object({
+ authType: z.literal(TailscaleKeyAuthType.AuthKeys),
+ apiKey: z
+ .string()
+ .trim()
+ .min(1)
+ .describe("Tailscale API access token or OAuth access token used to create and revoke keys."),
+ tailnet: z
+ .string()
+ .trim()
+ .min(1)
+ .default("-")
+ .describe("Tailnet identifier. Use '-' for the token owner's default tailnet."),
+ description: z.string().trim().max(50).optional().describe("Description applied to the created key."),
+ tags: z
+ .array(z.string().trim().min(1))
+ .default([])
+ .describe("ACL tags to attach to devices (e.g. tag:ci). Required when authenticating with an OAuth token."),
+ reusable: z.boolean().default(false).describe("Whether the auth key can register multiple devices."),
+ ephemeral: z.boolean().default(false).describe("Whether devices registered with the key are ephemeral."),
+ preauthorized: z.boolean().default(false).describe("Whether devices registered with the key are pre-authorized.")
+ }),
+ z.object({
+ authType: z.literal(TailscaleKeyAuthType.OAuthKeys),
+ apiKey: z
+ .string()
+ .trim()
+ .min(1)
+ .describe("Tailscale API access token or OAuth access token used to create and revoke keys."),
+ tailnet: z
+ .string()
+ .trim()
+ .min(1)
+ .default("-")
+ .describe("Tailnet identifier. Use '-' for the token owner's default tailnet."),
+ description: z.string().trim().max(50).optional().describe("Description applied to the created OAuth client."),
+ tags: z
+ .array(z.string().trim().min(1))
+ .default([])
+ .describe("ACL tags to attach (e.g. tag:ci). Required if scopes include devices:core or auth_keys."),
+ scopes: z.array(z.string().trim().min(1)).min(1).describe("OAuth scopes granted to the client.")
+ })
+]);
+
export const DynamicSecretSshSchema = z.object({
principals: z.array(z.string().trim().min(1)).min(1),
keyAlgorithm: z.nativeEnum(SshCertKeyAlgorithm).default(SshCertKeyAlgorithm.ED25519)
@@ -847,7 +898,8 @@ export const DynamicSecretProviderSchema = z.discriminatedUnion("type", [
z.object({
type: z.literal(DynamicSecretProviders.IbmApiConnect),
inputs: DynamicSecretIbmApiConnectSchema
- })
+ }),
+ z.object({ type: z.literal(DynamicSecretProviders.Tailscale), inputs: DynamicSecretTailscaleSchema })
]);
// Extended metadata passed to a provider's create() call. When the project
diff --git a/backend/src/ee/services/dynamic-secret/providers/tailscale.ts b/backend/src/ee/services/dynamic-secret/providers/tailscale.ts
new file mode 100644
index 0000000000..a4913dffb3
--- /dev/null
+++ b/backend/src/ee/services/dynamic-secret/providers/tailscale.ts
@@ -0,0 +1,128 @@
+import { BadRequestError } from "@app/lib/errors";
+import { sanitizeString } from "@app/lib/fn";
+import { safeRequest } from "@app/lib/validator";
+
+import { DynamicSecretTailscaleSchema, TailscaleKeyAuthType, TDynamicProviderFns } from "./models";
+
+const TAILSCALE_API_BASE_URL = "https://api.tailscale.com/api/v2";
+
+type TTailscaleKeyResponse = {
+ id: string;
+ key: string;
+};
+
+export const TailscaleProvider = (): TDynamicProviderFns => {
+ const validateProviderInputs = async (inputs: object) => {
+ const providerInputs = await DynamicSecretTailscaleSchema.parseAsync(inputs);
+ return providerInputs;
+ };
+
+ const $requestConfig = (apiKey: string) => ({
+ headers: {
+ Authorization: `Bearer ${apiKey}`,
+ "Content-Type": "application/json"
+ },
+ timeout: 30000,
+ maxRedirects: 0
+ });
+
+ const validateConnection = async (inputs: unknown) => {
+ const providerInputs = await validateProviderInputs(inputs as object);
+
+ try {
+ await safeRequest.get(
+ `${TAILSCALE_API_BASE_URL}/tailnet/${encodeURIComponent(providerInputs.tailnet)}/keys?all=true`,
+ $requestConfig(providerInputs.apiKey)
+ );
+ return true;
+ } catch (err) {
+ const sanitizedErrorMessage = sanitizeString({
+ unsanitizedString: (err as Error)?.message,
+ tokens: [providerInputs.apiKey]
+ });
+ throw new BadRequestError({ message: `Failed to connect with Tailscale: ${sanitizedErrorMessage}` });
+ }
+ };
+
+ const create = async (data: { inputs: unknown; expireAt: number }) => {
+ const { inputs, expireAt } = data;
+ const providerInputs = await validateProviderInputs(inputs as object);
+
+ const url = `${TAILSCALE_API_BASE_URL}/tailnet/${encodeURIComponent(providerInputs.tailnet)}/keys`;
+
+ let body: Record<string, unknown>;
+ if (providerInputs.authType === TailscaleKeyAuthType.AuthKeys) {
+ // Tailscale expires auth keys after expirySeconds; align it with the lease TTL as defense-in-depth.
+ const expirySeconds = Math.max(Math.floor(expireAt / 1000) - Math.floor(Date.now() / 1000), 0);
+ body = {
+ keyType: "auth",
+ description: providerInputs.description,
+ expirySeconds,
+ capabilities: {
+ devices: {
+ create: {
+ reusable: providerInputs.reusable,
+ ephemeral: false,
+ preauthorized: providerInputs.preauthorized,
+ tags: providerInputs.tags
+ }
+ }
+ }
+ };
+ } else {
+ body = {
+ keyType: "client",
+ description: providerInputs.description,
+ scopes: providerInputs.scopes,
+ tags: providerInputs.tags
+ };
+ }
+
+ try {
+ const response = await safeRequest.post<TTailscaleKeyResponse>(url, body, $requestConfig(providerInputs.apiKey));
+ const { id, key } = response.data;
+
+ if (providerInputs.authType === TailscaleKeyAuthType.AuthKeys) {
+ return { entityId: id, data: { AUTH_KEY: key, KEY_ID: id } };
+ }
+
+ return { entityId: id, data: { CLIENT_ID: id, CLIENT_SECRET: key } };
+ } catch (err) {
+ const sanitizedErrorMessage = sanitizeString({
+ unsanitizedString: (err as Error)?.message,
+ tokens: [providerInputs.apiKey]
+ });
+ throw new BadRequestError({ message: `Failed to create Tailscale key: ${sanitizedErrorMessage}` });
+ }
+ };
+
+ const revoke = async (inputs: unknown, entityId: string) => {
+ const providerInputs = await validateProviderInputs(inputs as object);
+
+ const url = `${TAILSCALE_API_BASE_URL}/tailnet/${encodeURIComponent(providerInputs.tailnet)}/keys/${encodeURIComponent(entityId)}`;
+
+ try {
+ await safeRequest.delete(url, $requestConfig(providerInputs.apiKey));
+ return { entityId };
+ } catch (err) {
+ const sanitizedErrorMessage = sanitizeString({
+ unsanitizedString: (err as Error)?.message,
+ tokens: [providerInputs.apiKey]
+ });
+ throw new BadRequestError({ message: `Failed to revoke Tailscale key: ${sanitizedErrorMessage}` });
+ }
+ };
+
+ const renew = async () => {
+ // Tailscale keys are immutable and cannot be extended once created.
+ throw new BadRequestError({ message: "Tailscale dynamic secret does not support renewal" });
+ };
+
+ return {
+ validateProviderInputs,
+ validateConnection,
+ create,
+ revoke,
+ renew
+ };
+};
diff --git a/frontend/src/hooks/api/dynamicSecret/types.ts b/frontend/src/hooks/api/dynamicSecret/types.ts
index 2fe4b72813..a4c5a69da0 100644
--- a/frontend/src/hooks/api/dynamicSecret/types.ts
+++ b/frontend/src/hooks/api/dynamicSecret/types.ts
@@ -44,7 +44,13 @@ export enum DynamicSecretProviders {
Clickhouse = "clickhouse",
Milvus = "milvus",
Ssh = "ssh",
- IbmApiConnect = "ibm-api-connect"
+ IbmApiConnect = "ibm-api-connect",
+ Tailscale = "tailscale"
+}
+
+export enum TailscaleKeyAuthType {
+ AuthKeys = "auth_keys",
+ OAuthKeys = "oauth_keys"
}
export enum KubernetesDynamicSecretCredentialType {
@@ -523,6 +529,27 @@ export type TDynamicSecretProvider =
gatewayId?: string;
gatewayPoolId?: string;
};
+ }
+ | {
+ type: DynamicSecretProviders.Tailscale;
+ inputs:
+ | {
+ authType: TailscaleKeyAuthType.AuthKeys;
+ apiKey: string;
+ tailnet: string;
+ description?: string;
+ tags: string[];
+ reusable: boolean;
+ preauthorized: boolean;
+ }
+ | {
+ authType: TailscaleKeyAuthType.OAuthKeys;
+ apiKey: string;
+ tailnet: string;
+ description?: string;
+ tags: string[];
+ scopes: string[];
+ };
};
export type TCreateDynamicSecretDTO = {
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/DynamicSecretTableRow/DynamicSecretTableRow.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/DynamicSecretTableRow/DynamicSecretTableRow.tsx
index 0e2c1296fa..bcde8864c4 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/DynamicSecretTableRow/DynamicSecretTableRow.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/DynamicSecretTableRow/DynamicSecretTableRow.tsx
@@ -61,7 +61,8 @@ const DYNAMIC_SECRET_PROVIDER_NAMES: Record<DynamicSecretProviders, string> = {
[DynamicSecretProviders.Couchbase]: "Couchbase",
[DynamicSecretProviders.Milvus]: "Milvus",
[DynamicSecretProviders.Ssh]: "SSH",
- [DynamicSecretProviders.IbmApiConnect]: "IBM API Connect"
+ [DynamicSecretProviders.IbmApiConnect]: "IBM API Connect",
+ [DynamicSecretProviders.Tailscale]: "Tailscale"
};
type DynamicSecretWithEnv = TDynamicSecret & { environment: string };
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 1f80f19706..ee6271b0f2 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
@@ -11,7 +11,8 @@ import {
SiMongodb,
SiRabbitmq,
SiSap,
- SiSnowflake
+ SiSnowflake,
+ SiTailscale
} from "react-icons/si";
import { VscAzure } from "react-icons/vsc";
import { faAws, faGithub, faGoogle } from "@fortawesome/free-brands-svg-icons";
@@ -48,6 +49,7 @@ import { SapHanaInputForm } from "./SapHanaInputForm";
import { SnowflakeInputForm } from "./SnowflakeInputForm";
import { SqlDatabaseInputForm } from "./SqlDatabaseInputForm";
import { SshInputForm } from "./SshInputForm";
+import { TailscaleInputForm } from "./TailscaleInputForm";
import { TotpInputForm } from "./TotpInputForm";
import { VerticaInputForm } from "./VerticaInputForm";
@@ -195,6 +197,11 @@ const DYNAMIC_SECRET_LIST = [
icon: <FontAwesomeIcon icon={faGlobe} size="lg" />,
provider: DynamicSecretProviders.IbmApiConnect,
title: "IBM API Connect"
+ },
+ {
+ icon: <SiTailscale size="1.5rem" />,
+ provider: DynamicSecretProviders.Tailscale,
+ title: "Tailscale"
}
];
@@ -770,6 +777,25 @@ export const CreateDynamicSecretForm = ({
/>
</motion.div>
)}
+ {wizardStep === WizardSteps.ProviderInputs &&
+ selectedProvider === DynamicSecretProviders.Tailscale && (
+ <motion.div
+ key="dynamic-tailscale-step"
+ transition={{ duration: 0.1 }}
+ initial={{ opacity: 0, translateX: 30 }}
+ animate={{ opacity: 1, translateX: 0 }}
+ exit={{ opacity: 0, translateX: -30 }}
+ >
+ <TailscaleInputForm
+ onCompleted={handleFormReset}
+ onCancel={handleFormReset}
+ projectSlug={projectSlug}
+ secretPath={secretPath}
+ environments={environments}
+ isSingleEnvironmentMode={isSingleEnvironmentMode}
+ />
+ </motion.div>
+ )}
</AnimatePresence>
</ModalContent>
</Modal>
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/TailscaleInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/TailscaleInputForm.tsx
new file mode 100644
index 0000000000..46c9c8db43
--- /dev/null
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/TailscaleInputForm.tsx
@@ -0,0 +1,407 @@
+import { Controller, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import ms from "ms";
+import { z } from "zod";
+
+import { TtlFormLabel } from "@app/components/features";
+import {
+ Button,
+ FilterableSelect,
+ FormControl,
+ Input,
+ SecretInput,
+ Select,
+ SelectItem,
+ Switch
+} from "@app/components/v2";
+import { useCreateDynamicSecret } from "@app/hooks/api";
+import {
+ DynamicSecretProviders,
+ TailscaleKeyAuthType,
+ TDynamicSecretProvider
+} from "@app/hooks/api/dynamicSecret/types";
+import { ProjectEnv } from "@app/hooks/api/types";
+
+type TailscaleInputs = Extract<
+ TDynamicSecretProvider,
+ { type: DynamicSecretProviders.Tailscale }
+>["inputs"];
+
+const validateTTL = (val: string, ctx: z.RefinementCtx) => {
+ const valMs = ms(val);
+ if (valMs < 60 * 1000)
+ ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be greater than 1 minute" });
+ if (valMs > ms("90d"))
+ ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 90 days" });
+};
+
+const formSchema = z.object({
+ provider: z.discriminatedUnion("authType", [
+ z.object({
+ authType: z.literal(TailscaleKeyAuthType.AuthKeys),
+ apiKey: z.string().trim().min(1, "API key is required"),
+ tailnet: z.string().trim().min(1, "Tailnet is required"),
+ description: z.string().trim().max(50).optional(),
+ tags: z.string().trim().optional(),
+ reusable: z.boolean().default(false),
+ preauthorized: z.boolean().default(false)
+ }),
+ z.object({
+ authType: z.literal(TailscaleKeyAuthType.OAuthKeys),
+ apiKey: z.string().trim().min(1, "API key is required"),
+ tailnet: z.string().trim().min(1, "Tailnet is required"),
+ description: z.string().trim().max(50).optional(),
+ tags: z.string().trim().optional(),
+ scopes: z.string().trim().min(1, "At least one scope is required")
+ })
+ ]),
+ defaultTTL: z.string().superRefine(validateTTL),
+ maxTTL: z
+ .string()
+ .optional()
+ .superRefine((val, ctx) => {
+ if (!val) return;
+ validateTTL(val, ctx);
+ }),
+ name: z.string().refine((val) => val.toLowerCase() === val, "Must be lowercase"),
+ environment: z.object({ name: z.string(), slug: z.string() })
+});
+type TForm = z.infer<typeof formSchema>;
+
+const splitCsv = (val?: string) =>
+ val
+ ? val
+ .split(",")
+ .map((entry) => entry.trim())
+ .filter(Boolean)
+ : [];
+
+type Props = {
+ onCompleted: () => void;
+ onCancel: () => void;
+ secretPath: string;
+ projectSlug: string;
+ environments: ProjectEnv[];
+ isSingleEnvironmentMode?: boolean;
+};
+
+export const TailscaleInputForm = ({
+ onCompleted,
+ onCancel,
+ environments,
+ secretPath,
+ projectSlug,
+ isSingleEnvironmentMode
+}: Props) => {
+ const {
+ control,
+ formState: { isSubmitting },
+ handleSubmit,
+ watch
+ } = useForm<TForm>({
+ resolver: zodResolver(formSchema),
+ defaultValues: {
+ environment: isSingleEnvironmentMode && environments.length > 0 ? environments[0] : undefined,
+ provider: {
+ authType: TailscaleKeyAuthType.AuthKeys,
+ tailnet: "-",
+ reusable: false,
+ preauthorized: false
+ }
+ }
+ });
+
+ const createDynamicSecret = useCreateDynamicSecret();
+ const authType = watch("provider.authType");
+
+ const handleCreateDynamicSecret = async ({
+ name,
+ maxTTL,
+ provider,
+ defaultTTL,
+ environment
+ }: TForm) => {
+ if (createDynamicSecret.isPending) return;
+
+ const inputs: TailscaleInputs =
+ provider.authType === TailscaleKeyAuthType.AuthKeys
+ ? {
+ authType: TailscaleKeyAuthType.AuthKeys,
+ apiKey: provider.apiKey,
+ tailnet: provider.tailnet,
+ description: provider.description || undefined,
+ tags: splitCsv(provider.tags),
+ reusable: provider.reusable,
+ preauthorized: provider.preauthorized
+ }
+ : {
+ authType: TailscaleKeyAuthType.OAuthKeys,
+ apiKey: provider.apiKey,
+ tailnet: provider.tailnet,
+ description: provider.description || undefined,
+ tags: splitCsv(provider.tags),
+ scopes: splitCsv(provider.scopes)
+ };
+
+ await createDynamicSecret.mutateAsync({
+ provider: { type: DynamicSecretProviders.Tailscale, inputs },
+ maxTTL,
+ name,
+ path: secretPath,
+ defaultTTL,
+ projectSlug,
+ environmentSlug: environment.slug
+ });
+ 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">
+ <Controller
+ name="provider.authType"
+ control={control}
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl
+ errorText={error?.message}
+ isError={Boolean(error?.message)}
+ label="Key Type"
+ >
+ <Select
+ value={value}
+ onValueChange={(val) => onChange(val)}
+ className="w-full border border-mineshaft-500"
+ position="popper"
+ dropdownContainerClassName="max-w-none"
+ >
+ <SelectItem value={TailscaleKeyAuthType.AuthKeys}>Auth Key</SelectItem>
+ <SelectItem value={TailscaleKeyAuthType.OAuthKeys}>OAuth Client</SelectItem>
+ </Select>
+ </FormControl>
+ )}
+ />
+
+ <Controller
+ control={control}
+ name="provider.apiKey"
+ defaultValue=""
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="API Key"
+ className="grow"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ isRequired
+ helperText="Tailscale API access token or OAuth access token with permission to create and revoke keys."
+ >
+ <SecretInput
+ {...field}
+ containerClassName="text-gray-400 group-focus-within:border-primary-400/50! border border-mineshaft-500 bg-mineshaft-900 px-2.5 py-1.5"
+ />
+ </FormControl>
+ )}
+ />
+
+ <Controller
+ control={control}
+ name="provider.tailnet"
+ defaultValue="-"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Tailnet"
+ className="grow"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ isRequired
+ helperText="Use '-' for the token owner's default tailnet, or provide a tailnet name (e.g. example.com)."
+ >
+ <Input {...field} placeholder="-" />
+ </FormControl>
+ )}
+ />
+
+ <Controller
+ control={control}
+ name="provider.description"
+ defaultValue=""
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Description"
+ className="grow"
+ isOptional
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="Created by Infisical" />
+ </FormControl>
+ )}
+ />
+
+ <Controller
+ control={control}
+ name="provider.tags"
+ defaultValue=""
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Tags"
+ className="grow"
+ isOptional
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ helperText="Comma-separated ACL tags (e.g. tag:ci, tag:prod). Required when authenticating with an OAuth token."
+ >
+ <Input {...field} placeholder="tag:ci, tag:prod" />
+ </FormControl>
+ )}
+ />
+
+ {authType === TailscaleKeyAuthType.OAuthKeys && (
+ <Controller
+ control={control}
+ name="provider.scopes"
+ defaultValue=""
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Scopes"
+ className="grow"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ isRequired
+ helperText="Comma-separated OAuth scopes (e.g. devices:core, auth_keys)."
+ >
+ <Input {...field} placeholder="devices:core, auth_keys" />
+ </FormControl>
+ )}
+ />
+ )}
+
+ {authType === TailscaleKeyAuthType.AuthKeys && (
+ <div className="flex flex-col gap-3 pt-1 pb-2">
+ <Controller
+ control={control}
+ name="provider.reusable"
+ render={({ field: { value, onChange } }) => (
+ <Switch
+ className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"
+ id="tailscale-reusable"
+ thumbClassName="bg-mineshaft-800"
+ isChecked={value}
+ onCheckedChange={onChange}
+ >
+ <p className="w-full">Reusable</p>
+ </Switch>
+ )}
+ />
+ <Controller
+ control={control}
+ name="provider.preauthorized"
+ render={({ field: { value, onChange } }) => (
+ <Switch
+ className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"
+ id="tailscale-preauthorized"
+ thumbClassName="bg-mineshaft-800"
+ isChecked={value}
+ onCheckedChange={onChange}
+ >
+ <p className="w-full">Pre-authorized</p>
+ </Switch>
+ )}
+ />
+ </div>
+ )}
+
+ {!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/CreateDynamicSecretLease.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/CreateDynamicSecretLease.tsx
index 363006963c..949caf4612 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/CreateDynamicSecretLease.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/CreateDynamicSecretLease.tsx
@@ -431,6 +431,37 @@ const renderOutputForm = (
);
}
+ if (provider === DynamicSecretProviders.Tailscale) {
+ const { AUTH_KEY, CLIENT_ID, CLIENT_SECRET } = data as {
+ AUTH_KEY?: string;
+ CLIENT_ID?: string;
+ CLIENT_SECRET?: string;
+ };
+
+ if (AUTH_KEY) {
+ return (
+ <div>
+ <OutputDisplay
+ label="Auth Key"
+ value={AUTH_KEY}
+ helperText="Important: Copy these credentials now. You will not be able to see them again after you close the modal."
+ />
+ </div>
+ );
+ }
+
+ return (
+ <div>
+ <OutputDisplay label="Client ID" value={CLIENT_ID ?? ""} />
+ <OutputDisplay
+ label="Client Secret"
+ value={CLIENT_SECRET ?? ""}
+ helperText="Important: Copy these credentials now. You will not be able to see them again after you close the modal."
+ />
+ </div>
+ );
+ }
+
return null;
};
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/DynamicSecretLease.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/DynamicSecretLease.tsx
index 9130bfe973..7d8d84e1cc 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/DynamicSecretLease.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/DynamicSecretLease.tsx
@@ -44,7 +44,11 @@ type Props = {
onClose: () => void;
};
-const DYNAMIC_SECRETS_WITHOUT_RENEWAL = [DynamicSecretProviders.Github, DynamicSecretProviders.Ssh];
+const DYNAMIC_SECRETS_WITHOUT_RENEWAL = [
+ DynamicSecretProviders.Github,
+ DynamicSecretProviders.Ssh,
+ DynamicSecretProviders.Tailscale
+];
export const DynamicSecretLease = ({
projectSlug,
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 b11ab4fb40..f85e04c540 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
@@ -28,6 +28,7 @@ import { EditDynamicSecretSapHanaForm } from "./EditDynamicSecretSapHanaForm";
import { EditDynamicSecretSnowflakeForm } from "./EditDynamicSecretSnowflakeForm";
import { EditDynamicSecretSqlProviderForm } from "./EditDynamicSecretSqlProviderForm";
import { EditDynamicSecretSshForm } from "./EditDynamicSecretSshForm";
+import { EditDynamicSecretTailscaleForm } from "./EditDynamicSecretTailscaleForm";
import { EditDynamicSecretTotpForm } from "./EditDynamicSecretTotpForm";
import { EditDynamicSecretVerticaForm } from "./EditDynamicSecretVertica";
@@ -511,6 +512,23 @@ export const EditDynamicSecretForm = ({
/>
</motion.div>
)}
+ {dynamicSecretDetails?.type === DynamicSecretProviders.Tailscale && (
+ <motion.div
+ key="tailscale-edit"
+ transition={{ duration: 0.1 }}
+ initial={{ opacity: 0, translateX: 30 }}
+ animate={{ opacity: 1, translateX: 0 }}
+ exit={{ opacity: 0, translateX: -30 }}
+ >
+ <EditDynamicSecretTailscaleForm
+ onClose={onClose}
+ projectSlug={projectSlug}
+ secretPath={secretPath}
+ dynamicSecret={dynamicSecretDetails}
+ environment={environment}
+ />
+ </motion.div>
+ )}
</AnimatePresence>
);
};
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretTailscaleForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretTailscaleForm.tsx
new file mode 100644
index 0000000000..01f8d924e4
--- /dev/null
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretTailscaleForm.tsx
@@ -0,0 +1,394 @@
+import { Controller, useForm } from "react-hook-form";
+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,
+ Input,
+ SecretInput,
+ Select,
+ SelectItem,
+ Switch
+} from "@app/components/v2";
+import { useUpdateDynamicSecret } from "@app/hooks/api";
+import {
+ DynamicSecretProviders,
+ TailscaleKeyAuthType,
+ TDynamicSecret,
+ TDynamicSecretProvider
+} from "@app/hooks/api/dynamicSecret/types";
+import { slugSchema } from "@app/lib/schemas";
+
+type TailscaleInputs = Extract<
+ TDynamicSecretProvider,
+ { type: DynamicSecretProviders.Tailscale }
+>["inputs"];
+
+const validateTTL = (val: string, ctx: z.RefinementCtx) => {
+ const valMs = ms(val);
+ if (valMs < 60 * 1000)
+ ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be greater than 1 minute" });
+ if (valMs > ms("90d"))
+ ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 90 days" });
+};
+
+const formSchema = z.object({
+ inputs: z.discriminatedUnion("authType", [
+ z.object({
+ authType: z.literal(TailscaleKeyAuthType.AuthKeys),
+ apiKey: z.string().trim().min(1, "API key is required"),
+ tailnet: z.string().trim().min(1, "Tailnet is required"),
+ description: z.string().trim().max(50).optional(),
+ tags: z.string().trim().optional(),
+ reusable: z.boolean().default(false),
+ preauthorized: z.boolean().default(false)
+ }),
+ z.object({
+ authType: z.literal(TailscaleKeyAuthType.OAuthKeys),
+ apiKey: z.string().trim().min(1, "API key is required"),
+ tailnet: z.string().trim().min(1, "Tailnet is required"),
+ description: z.string().trim().max(50).optional(),
+ tags: z.string().trim().optional(),
+ scopes: z.string().trim().min(1, "At least one scope is required")
+ })
+ ]),
+ defaultTTL: z.string().superRefine(validateTTL),
+ maxTTL: z
+ .string()
+ .optional()
+ .superRefine((val, ctx) => {
+ if (!val) return;
+ validateTTL(val, ctx);
+ })
+ .nullable(),
+ newName: slugSchema().optional()
+});
+type TForm = z.infer<typeof formSchema>;
+
+const splitCsv = (val?: string) =>
+ val
+ ? val
+ .split(",")
+ .map((entry) => entry.trim())
+ .filter(Boolean)
+ : [];
+
+const hydrateInputs = (rawInputs: TailscaleInputs): TForm["inputs"] => {
+ if (rawInputs.authType === TailscaleKeyAuthType.AuthKeys) {
+ return {
+ authType: TailscaleKeyAuthType.AuthKeys,
+ apiKey: rawInputs.apiKey,
+ tailnet: rawInputs.tailnet,
+ description: rawInputs.description,
+ tags: (rawInputs.tags ?? []).join(", "),
+ reusable: rawInputs.reusable,
+ preauthorized: rawInputs.preauthorized
+ };
+ }
+ return {
+ authType: TailscaleKeyAuthType.OAuthKeys,
+ apiKey: rawInputs.apiKey,
+ tailnet: rawInputs.tailnet,
+ description: rawInputs.description,
+ tags: (rawInputs.tags ?? []).join(", "),
+ scopes: (rawInputs.scopes ?? []).join(", ")
+ };
+};
+
+type Props = {
+ onClose: () => void;
+ dynamicSecret: TDynamicSecret & { inputs: unknown };
+ secretPath: string;
+ environment: string;
+ projectSlug: string;
+};
+
+export const EditDynamicSecretTailscaleForm = ({
+ onClose,
+ dynamicSecret,
+ secretPath,
+ environment,
+ projectSlug
+}: Props) => {
+ const {
+ control,
+ watch,
+ formState: { isSubmitting },
+ handleSubmit
+ } = useForm<TForm>({
+ resolver: zodResolver(formSchema),
+ values: {
+ defaultTTL: dynamicSecret.defaultTTL,
+ maxTTL: dynamicSecret.maxTTL,
+ newName: dynamicSecret.name,
+ inputs: hydrateInputs(dynamicSecret.inputs as TailscaleInputs)
+ }
+ });
+
+ const updateDynamicSecret = useUpdateDynamicSecret();
+ const authType = watch("inputs.authType");
+
+ const handleUpdateDynamicSecret = async ({ inputs, maxTTL, defaultTTL, newName }: TForm) => {
+ if (updateDynamicSecret.isPending) return;
+
+ const builtInputs: TailscaleInputs =
+ inputs.authType === TailscaleKeyAuthType.AuthKeys
+ ? {
+ authType: TailscaleKeyAuthType.AuthKeys,
+ apiKey: inputs.apiKey,
+ tailnet: inputs.tailnet,
+ description: inputs.description || undefined,
+ tags: splitCsv(inputs.tags),
+ reusable: inputs.reusable,
+ preauthorized: inputs.preauthorized
+ }
+ : {
+ authType: TailscaleKeyAuthType.OAuthKeys,
+ apiKey: inputs.apiKey,
+ tailnet: inputs.tailnet,
+ description: inputs.description || undefined,
+ tags: splitCsv(inputs.tags),
+ scopes: splitCsv(inputs.scopes)
+ };
+
+ await updateDynamicSecret.mutateAsync({
+ name: dynamicSecret.name,
+ path: secretPath,
+ projectSlug,
+ environmentSlug: environment,
+ data: {
+ maxTTL: maxTTL || undefined,
+ defaultTTL,
+ inputs: builtInputs,
+ newName: newName === dynamicSecret.name ? undefined : newName
+ }
+ });
+ onClose();
+ createNotification({
+ type: "success",
+ text: "Successfully updated dynamic secret"
+ });
+ };
+
+ return (
+ <div>
+ <form onSubmit={handleSubmit(handleUpdateDynamicSecret)} autoComplete="off">
+ <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"
+ 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"
+ 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>
+ <div>
+ <div className="mb-4 border-b border-b-mineshaft-600 pb-2">Configuration</div>
+ <div className="flex flex-col">
+ <Controller
+ name="inputs.authType"
+ control={control}
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl
+ errorText={error?.message}
+ isError={Boolean(error?.message)}
+ label="Key Type"
+ >
+ <Select
+ value={value}
+ onValueChange={(val) => onChange(val)}
+ className="w-full border border-mineshaft-500"
+ position="popper"
+ dropdownContainerClassName="max-w-none"
+ >
+ <SelectItem value={TailscaleKeyAuthType.AuthKeys}>Auth Key</SelectItem>
+ <SelectItem value={TailscaleKeyAuthType.OAuthKeys}>OAuth Client</SelectItem>
+ </Select>
+ </FormControl>
+ )}
+ />
+
+ <Controller
+ control={control}
+ name="inputs.apiKey"
+ defaultValue=""
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="API Key"
+ className="grow"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ isRequired
+ >
+ <SecretInput
+ {...field}
+ containerClassName="text-gray-400 group-focus-within:border-primary-400/50! border border-mineshaft-500 bg-mineshaft-900 px-2.5 py-1.5"
+ />
+ </FormControl>
+ )}
+ />
+
+ <Controller
+ control={control}
+ name="inputs.tailnet"
+ defaultValue="-"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Tailnet"
+ className="grow"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ isRequired
+ helperText="Use '-' for the token owner's default tailnet, or provide a tailnet name (e.g. example.com)."
+ >
+ <Input {...field} placeholder="-" />
+ </FormControl>
+ )}
+ />
+
+ <Controller
+ control={control}
+ name="inputs.description"
+ defaultValue=""
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Description"
+ className="grow"
+ isOptional
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="Created by Infisical" />
+ </FormControl>
+ )}
+ />
+
+ <Controller
+ control={control}
+ name="inputs.tags"
+ defaultValue=""
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Tags"
+ className="grow"
+ isOptional
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ helperText="Comma-separated ACL tags (e.g. tag:ci, tag:prod). Required when authenticating with an OAuth token."
+ >
+ <Input {...field} placeholder="tag:ci, tag:prod" />
+ </FormControl>
+ )}
+ />
+
+ {authType === TailscaleKeyAuthType.OAuthKeys && (
+ <Controller
+ control={control}
+ name="inputs.scopes"
+ defaultValue=""
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Scopes"
+ className="grow"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ isRequired
+ helperText="Comma-separated OAuth scopes (e.g. devices:core, auth_keys)."
+ >
+ <Input {...field} placeholder="devices:core, auth_keys" />
+ </FormControl>
+ )}
+ />
+ )}
+
+ {authType === TailscaleKeyAuthType.AuthKeys && (
+ <div className="flex flex-col gap-3 pt-1 pb-2">
+ <Controller
+ control={control}
+ name="inputs.reusable"
+ render={({ field: { value, onChange } }) => (
+ <Switch
+ className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"
+ id="tailscale-edit-reusable"
+ thumbClassName="bg-mineshaft-800"
+ isChecked={value}
+ onCheckedChange={onChange}
+ >
+ <p className="w-full">Reusable</p>
+ </Switch>
+ )}
+ />
+
+ <Controller
+ control={control}
+ name="inputs.preauthorized"
+ render={({ field: { value, onChange } }) => (
+ <Switch
+ className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"
+ id="tailscale-edit-preauthorized"
+ thumbClassName="bg-mineshaft-800"
+ isChecked={value}
+ onCheckedChange={onChange}
+ >
+ <p className="w-full">Pre-authorized</p>
+ </Switch>
+ )}
+ />
+ </div>
+ )}
+ </div>
+ </div>
+ <div className="mt-4 flex items-center space-x-4">
+ <Button type="submit" isLoading={isSubmitting}>
+ Save
+ </Button>
+ <Button variant="outline_bg" onClick={onClose}>
+ Cancel
+ </Button>
+ </div>
+ </form>
+ </div>
+ );
+};