Skip to content

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

address comments

adilson869a23196615
diff --git a/backend/src/ee/services/dynamic-secret/providers/models.ts b/backend/src/ee/services/dynamic-secret/providers/models.ts
index 484c53b648..247e639e5a 100644
--- a/backend/src/ee/services/dynamic-secret/providers/models.ts
+++ b/backend/src/ee/services/dynamic-secret/providers/models.ts
@@ -847,7 +847,6 @@ export const DynamicSecretTailscaleSchema = z
.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({
@@ -899,12 +898,7 @@ export const DynamicSecretTailscaleSchema = z
})
])
.superRefine((data, ctx) => {
- // Mirrors the UI validation: Tailscale requires ACL tags on tailnet-owned auth keys created via OAuth.
- if (
- data.authType === TailscaleKeyAuthType.AuthKeys &&
- data.auth.method === TailscaleAuthMethod.OAuth &&
- data.tags.length === 0
- ) {
+ if (data.authType === TailscaleKeyAuthType.AuthKeys && data.tags.length === 0) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
path: ["tags"],
diff --git a/backend/src/ee/services/dynamic-secret/providers/tailscale.ts b/backend/src/ee/services/dynamic-secret/providers/tailscale.ts
index 8d3c851f03..7ca15e405c 100644
--- a/backend/src/ee/services/dynamic-secret/providers/tailscale.ts
+++ b/backend/src/ee/services/dynamic-secret/providers/tailscale.ts
@@ -103,7 +103,9 @@ export const TailscaleProvider = (): TDynamicProviderFns => {
devices: {
create: {
reusable: providerInputs.reusable,
- ephemeral: false,
+ // Force ephemeral so devices provisioned through a lease are removed from the
+ // tailnet automatically once offline. Revoking the key alone does not delete its devices.
+ ephemeral: true,
preauthorized: providerInputs.preauthorized,
tags: providerInputs.tags
}
diff --git a/docs/documentation/platform/dynamic-secrets/tailscale.mdx b/docs/documentation/platform/dynamic-secrets/tailscale.mdx
index 5273ce59a9..aebf693b5f 100644
--- a/docs/documentation/platform/dynamic-secrets/tailscale.mdx
+++ b/docs/documentation/platform/dynamic-secrets/tailscale.mdx
@@ -144,7 +144,7 @@ Infisical needs a credential that is allowed to create and revoke keys in your t
</ParamField>
<Note>
- All credentials are created with `ephemeral` set to `false` because they are managed by Infisical. This ensures that only one system is responsible for revoking the credentials, avoiding concurrency issues.
+ Auth keys are always created as `ephemeral`. Revoking a lease deletes the corresponding credential in your tailnet, but Tailscale does not remove the devices that already registered with it. Marking the devices ephemeral ensures Tailscale automatically removes them from the tailnet shortly after they go offline, so devices provisioned through a lease are cleaned up without manual intervention.
</Note>
</Step>
<Step title="Click `Submit`">
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
index 3f93303f6c..1b72c69976 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/TailscaleInputForm.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/TailscaleInputForm.tsx
@@ -22,6 +22,7 @@ import {
TDynamicSecretProvider
} from "@app/hooks/api/dynamicSecret/types";
import { ProjectEnv } from "@app/hooks/api/types";
+import { slugSchema } from "@app/lib/schemas";
type TailscaleInputs = Extract<
TDynamicSecretProvider,
@@ -92,7 +93,7 @@ const formSchema = z
if (!val) return;
validateTTL(val, ctx);
}),
- name: z.string().refine((val) => val.toLowerCase() === val, "Must be lowercase"),
+ name: slugSchema(),
environment: z.object({ name: z.string(), slug: z.string() })
})
.superRefine((val, ctx) => {
@@ -167,7 +168,7 @@ const buildInputs = (
audience: provider.audience || undefined
};
default:
- return assertNever(provider.authType);
+ return assertNever(provider);
}
};
@@ -307,7 +308,7 @@ export const TailscaleInputForm = ({
>
<Select
value={value}
- onValueChange={(val) => onChange(val)}
+ onValueChange={onChange}
className="w-full border border-mineshaft-500"
position="popper"
dropdownContainerClassName="max-w-none"
@@ -394,7 +395,7 @@ export const TailscaleInputForm = ({
>
<Select
value={value}
- onValueChange={(val) => onChange(val)}
+ onValueChange={onChange}
className="w-full border border-mineshaft-500"
position="popper"
dropdownContainerClassName="max-w-none"
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
index 62cdfcbbd2..516bb06291 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretTailscaleForm.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretTailscaleForm.tsx
@@ -129,6 +129,46 @@ const buildAuth = (auth: TForm["inputs"]["auth"]): TailscaleInputs["auth"] =>
clientSecret: auth.clientSecret
};
+const assertNever = (value: never): never => {
+ throw new Error(`Unhandled Tailscale auth type: ${String(value)}`);
+};
+
+const buildInputs = (inputs: TForm["inputs"], auth: TailscaleInputs["auth"]): TailscaleInputs => {
+ const base = {
+ auth,
+ tailnet: inputs.tailnet,
+ description: inputs.description || undefined,
+ tags: splitCsv(inputs.tags)
+ };
+
+ switch (inputs.authType) {
+ case TailscaleKeyAuthType.AuthKeys:
+ return {
+ ...base,
+ authType: inputs.authType,
+ reusable: inputs.reusable,
+ preauthorized: inputs.preauthorized
+ };
+ case TailscaleKeyAuthType.OAuthKeys:
+ return {
+ ...base,
+ authType: inputs.authType,
+ scopes: splitCsv(inputs.scopes)
+ };
+ case TailscaleKeyAuthType.FederatedKeys:
+ return {
+ ...base,
+ authType: inputs.authType,
+ scopes: splitCsv(inputs.scopes),
+ issuer: inputs.issuer,
+ subject: inputs.subject,
+ audience: inputs.audience || undefined
+ };
+ default:
+ return assertNever(inputs);
+ }
+};
+
const hydrateInputs = (rawInputs: TailscaleInputs): TForm["inputs"] => {
if (rawInputs.authType === TailscaleKeyAuthType.AuthKeys) {
return {
@@ -204,40 +244,7 @@ export const EditDynamicSecretTailscaleForm = ({
if (updateDynamicSecret.isPending) return;
const auth = buildAuth(inputs.auth);
-
- let builtInputs: TailscaleInputs;
- if (inputs.authType === TailscaleKeyAuthType.AuthKeys) {
- builtInputs = {
- authType: TailscaleKeyAuthType.AuthKeys,
- auth,
- tailnet: inputs.tailnet,
- description: inputs.description || undefined,
- tags: splitCsv(inputs.tags),
- reusable: inputs.reusable,
- preauthorized: inputs.preauthorized
- };
- } else if (inputs.authType === TailscaleKeyAuthType.OAuthKeys) {
- builtInputs = {
- authType: TailscaleKeyAuthType.OAuthKeys,
- auth,
- tailnet: inputs.tailnet,
- description: inputs.description || undefined,
- tags: splitCsv(inputs.tags),
- scopes: splitCsv(inputs.scopes)
- };
- } else {
- builtInputs = {
- authType: TailscaleKeyAuthType.FederatedKeys,
- auth,
- tailnet: inputs.tailnet,
- description: inputs.description || undefined,
- tags: splitCsv(inputs.tags),
- scopes: splitCsv(inputs.scopes),
- issuer: inputs.issuer,
- subject: inputs.subject,
- audience: inputs.audience || undefined
- };
- }
+ const builtInputs = buildInputs(inputs, auth);
await updateDynamicSecret.mutateAsync({
name: dynamicSecret.name,
@@ -322,7 +329,7 @@ export const EditDynamicSecretTailscaleForm = ({
>
<Select
value={value}
- onValueChange={(val) => onChange(val)}
+ onValueChange={onChange}
className="w-full border border-mineshaft-500"
position="popper"
dropdownContainerClassName="max-w-none"
@@ -346,6 +353,7 @@ export const EditDynamicSecretTailscaleForm = ({
isError={Boolean(error?.message)}
errorText={error?.message}
isRequired
+ helperText="Tailscale API access token with permission to create and revoke keys."
>
<SecretInput
{...field}
@@ -408,7 +416,7 @@ export const EditDynamicSecretTailscaleForm = ({
>
<Select
value={value}
- onValueChange={(val) => onChange(val)}
+ onValueChange={onChange}
className="w-full border border-mineshaft-500"
position="popper"
dropdownContainerClassName="max-w-none"
@@ -587,6 +595,7 @@ export const EditDynamicSecretTailscaleForm = ({
</Switch>
)}
/>
+
</div>
)}
</div>