From e4671f7d3f4cb0896d855f74c2c51d60a4ec2a67 Mon Sep 17 00:00:00 2001 From: hugocasa Date: Mon, 9 Nov 2026 17:45:03 +0100 Subject: [PATCH] feat: optional Vault AppRole secret_id setting, env var as fallback (#12276) * feat: add an optional Vault AppRole secret_id setting Co-Authored-By: Claude Opus 5.5 * fix: mask the AppRole secret_id in the instance settings YAML view Co-Authored-By: Claude Opus 5.5 * fix: align secret storage panels with the form guidelines Co-Authored-By: Claude Opus 5.5 * fix: use the card styles from the brand guidelines in the secret storage panels Co-Authored-By: Claude Opus 5.5 * chore: update ee-repo-ref to 747a8896c7bd2490063ccfe0c0796aa14b57ab67 This commit updates the EE repository reference after PR #966 was merged in windmill-ee-private. Previous ee-repo-ref: 450e839407e53540186523170127e5b17d110c5c New ee-repo-ref: 747a8896c7bd2490063ccfe0c0796aa14b57ab67 Automated by sync-ee-ref workflow. --------- Co-authored-by: Claude Opus 5.5 Co-authored-by: windmill-internal-app[bot] Co-authored-by: Ruben Fiszel --- backend/ee-repo-ref.txt | 2 +- backend/windmill-api/openapi.yaml | 5 +- .../windmill-common/src/instance_config.rs | 3 +- .../windmill-common/src/secret_backend/mod.rs | 9 +- .../src/secret_backend/tests.rs | 1 + .../tests/secret_backend_integration.rs | 2 + .../tests/secret_backend_migration.rs | 1 + .../src/lib/components/instanceSettings.ts | 4 +- .../ExternalSecretsConfig.svelte | 155 ++++++---- .../HttpStoreSecretBackendConfig.svelte | 36 +-- .../SecretBackendConfig.svelte | 266 ++++++++++-------- 11 files changed, 280 insertions(+), 204 deletions(-) diff --git a/backend/ee-repo-ref.txt b/backend/ee-repo-ref.txt index 73a5c27013..00a234ede3 100644 --- a/backend/ee-repo-ref.txt +++ b/backend/ee-repo-ref.txt @@ -1 +1 @@ -276f5f5cacc259bad1dc138430ae03c53d3db43d +747a8896c7bd2490063ccfe0c0796aa14b57ab67 diff --git a/backend/windmill-api/openapi.yaml b/backend/windmill-api/openapi.yaml index 970c7bedf4..9541ca3374 100644 --- a/backend/windmill-api/openapi.yaml +++ b/backend/windmill-api/openapi.yaml @@ -30387,7 +30387,10 @@ components: description: Mount path for the JWT auth method in Vault (optional, defaults to "jwt"). Set this when the JWT auth method is mounted at a non-default path, e.g. via `vault auth enable -path= jwt`. approle_role_id: type: string - description: AppRole role_id (optional). When set and no static token is given, Windmill logs in with AppRole; the secret_id is read from the `VAULT_APPROLE_SECRET_ID` environment variable of servers and workers. + description: AppRole role_id (optional). When set and no static token is given, Windmill logs in with AppRole. + approle_secret_id: + type: string + description: AppRole secret_id (optional). When empty, the `VAULT_APPROLE_SECRET_ID` environment variable of servers and workers is used; when that is unset too, no secret_id is sent (a role with `bind_secret_id=false`). approle_mount_path: type: string description: Mount path of the AppRole auth method (optional, defaults to "approle"). diff --git a/backend/windmill-common/src/instance_config.rs b/backend/windmill-common/src/instance_config.rs index 5413d5bdc0..93eb046a37 100644 --- a/backend/windmill-common/src/instance_config.rs +++ b/backend/windmill-common/src/instance_config.rs @@ -1206,6 +1206,7 @@ const NESTED_SENSITIVE_FIELDS: &[(&str, &[&str])] = &[ "secret_backend", &[ "token", + "approle_secret_id", "client_secret", "secret_access_key", "auth", @@ -1245,7 +1246,7 @@ fn mask_nested_sensitive(key: &str, value: &serde_json::Value) -> serde_json::Va // Settings that are maps-of-objects where each child has a sensitive sub-field. const NESTED_MAP_SENSITIVE: &[(&str, &[&str])] = &[ ("oauths", &["secret", "signing_secret"]), - ("external_secrets", &["token"]), + ("external_secrets", &["token", "approle_secret_id"]), ]; for &(parent_key, child_fields) in NESTED_MAP_SENSITIVE { if key == parent_key { diff --git a/backend/windmill-common/src/secret_backend/mod.rs b/backend/windmill-common/src/secret_backend/mod.rs index a721f0fb39..a52269e3c8 100644 --- a/backend/windmill-common/src/secret_backend/mod.rs +++ b/backend/windmill-common/src/secret_backend/mod.rs @@ -161,11 +161,14 @@ pub struct VaultSettings { #[serde(skip_serializing_if = "Option::is_none")] pub jwt_mount_path: Option, /// AppRole role_id. When set (and no static token), Windmill logs in with - /// AppRole; the secret_id is read from the `VAULT_APPROLE_SECRET_ID` - /// environment variable of servers and workers, never from settings, and - /// is omitted when unset (a role with `bind_secret_id=false`). + /// AppRole. #[serde(skip_serializing_if = "Option::is_none")] pub approle_role_id: Option, + /// AppRole secret_id. When empty, the `VAULT_APPROLE_SECRET_ID` environment + /// variable of servers and workers is used, and when that is unset too the + /// login sends none (a role with `bind_secret_id=false`). + #[serde(skip_serializing_if = "Option::is_none")] + pub approle_secret_id: Option, /// Mount path of the AppRole auth method (defaults to "approle"). #[serde(skip_serializing_if = "Option::is_none")] pub approle_mount_path: Option, diff --git a/backend/windmill-common/src/secret_backend/tests.rs b/backend/windmill-common/src/secret_backend/tests.rs index d749e8f27e..09991ee86b 100644 --- a/backend/windmill-common/src/secret_backend/tests.rs +++ b/backend/windmill-common/src/secret_backend/tests.rs @@ -29,6 +29,7 @@ mod tests { jwt_role: Some("windmill-secrets".to_string()), jwt_mount_path: None, approle_role_id: None, + approle_secret_id: None, approle_mount_path: None, namespace: None, token: Some("test-root-token".to_string()), diff --git a/backend/windmill-common/tests/secret_backend_integration.rs b/backend/windmill-common/tests/secret_backend_integration.rs index 1a861a297c..d0c274c4c0 100644 --- a/backend/windmill-common/tests/secret_backend_integration.rs +++ b/backend/windmill-common/tests/secret_backend_integration.rs @@ -80,6 +80,7 @@ mod tests { jwt_role: None, // Static token mode jwt_mount_path: None, approle_role_id: None, + approle_secret_id: None, approle_mount_path: None, namespace: None, token: Some( @@ -99,6 +100,7 @@ mod tests { jwt_role: Some("windmill-secrets".to_string()), // JWT mode jwt_mount_path: None, approle_role_id: None, + approle_secret_id: None, approle_mount_path: None, namespace: None, token: None, // No static token - use JWT diff --git a/backend/windmill-common/tests/secret_backend_migration.rs b/backend/windmill-common/tests/secret_backend_migration.rs index 2a6981794c..d550507887 100644 --- a/backend/windmill-common/tests/secret_backend_migration.rs +++ b/backend/windmill-common/tests/secret_backend_migration.rs @@ -38,6 +38,7 @@ fn test_vault_settings() -> VaultSettings { jwt_role: Some("windmill-secrets".to_string()), jwt_mount_path: None, approle_role_id: None, + approle_secret_id: None, approle_mount_path: None, namespace: None, token: Some(std::env::var("VAULT_TOKEN").unwrap_or_else(|_| "test-root-token".to_string())), diff --git a/frontend/src/lib/components/instanceSettings.ts b/frontend/src/lib/components/instanceSettings.ts index 2b481b9a0b..e9254a814f 100644 --- a/frontend/src/lib/components/instanceSettings.ts +++ b/frontend/src/lib/components/instanceSettings.ts @@ -1799,13 +1799,13 @@ export const sensitiveKeys: Set = new Set([ // Each entry maps a top-level key to its sensitive sub-field names. export const nestedSensitiveFields: Record = { smtp_settings: ['smtp_password'], - secret_backend: ['token', 'client_secret', 'secret_access_key'], + secret_backend: ['token', 'approle_secret_id', 'client_secret', 'secret_access_key'], object_store_cache_config: ['secret_key', 'serviceAccountKey', 'accessKey'], custom_instance_pg_databases: ['user_pwd'], external_instance_pg: ['password'], rsa_keys: ['private_key'], github_enterprise_app: ['private_key'], - external_secrets: ['vault.token'] + external_secrets: ['vault.token', 'vault.approle_secret_id'] } // A field may name one nested level, `parent.child`. diff --git a/frontend/src/lib/components/instanceSettings/ExternalSecretsConfig.svelte b/frontend/src/lib/components/instanceSettings/ExternalSecretsConfig.svelte index b082fd373f..052cf4caca 100644 --- a/frontend/src/lib/components/instanceSettings/ExternalSecretsConfig.svelte +++ b/frontend/src/lib/components/instanceSettings/ExternalSecretsConfig.svelte @@ -13,6 +13,7 @@ import EEOnly from '../EEOnly.svelte' import MultiSelect from '../select/MultiSelect.svelte' import { resource } from 'runed' + import Tooltip from '../meltComponents/Tooltip.svelte' interface Props { values: Writable> @@ -71,12 +72,17 @@ function setAuthMethod(method: string | undefined) { if (!vault || !method) return - const { token: _t, approle_role_id: _a, jwt_role: _j, ...rest } = vault + const { token: _t, approle_role_id: _a, approle_secret_id: _s, jwt_role: _j, ...rest } = vault update({ vault: { ...rest, ...(method === 'token' ? { token: vault.token ?? '' } : {}), - ...(method === 'approle' ? { approle_role_id: vault.approle_role_id ?? '' } : {}), + ...(method === 'approle' + ? { + approle_role_id: vault.approle_role_id ?? '', + approle_secret_id: vault.approle_secret_id + } + : {}), ...(method === 'jwt' ? { jwt_role: vault.jwt_role ?? 'windmill-secrets' } : {}) } }) @@ -106,7 +112,7 @@ {#if !$enterpriseLicense} External secret references require Enterprise Edition {/if} - + A secret variable can reference an existing secret, as $external:vault://<path>#<key>, or the whole secret as JSON without #<key>, instead of holding its value. The value is read from Vault each time @@ -118,7 +124,7 @@ {#if backendVault} -
+
Vault connection {#snippet children({ item })} @@ -139,7 +145,7 @@ {/snippet} {#if !vault} - + References are read from {backendVault.address || 'the Vault address above'} with the secret backend's authentication. @@ -157,7 +163,7 @@ {/if} {#if vault} -
+
-
+
Authentication method setAuthMethod(v)}> {#snippet children({ item })} @@ -200,55 +206,88 @@
{#if authMethod === 'approle'} -
- - vault?.approle_role_id ?? '', - (v) => update({ vault: { ...vault, approle_role_id: v ?? '' } }) - } - /> - - The secret_id is read from the VAULT_APPROLE_SECRET_ID environment variable - of every server and worker, so it is never stored in Windmill. Leave it unset for a role - with bind_secret_id=false. - - - vault?.approle_mount_path ?? '', (v) => setVaultField('approle_mount_path', v) - } - /> +
+
+ + vault?.approle_role_id ?? '', + (v) => update({ vault: { ...vault, approle_role_id: v ?? '' } }) + } + /> +
+
+ + + Leave blank to use VAULT_APPROLE_SECRET_ID. With neither set, no + secret_id is sent (bind_secret_id=false roles). + + vault?.approle_secret_id ?? '', (v) => setVaultField('approle_secret_id', v) + } + small + {disabled} + /> +
+
+ + vault?.approle_mount_path ?? '', (v) => setVaultField('approle_mount_path', v) + } + /> +
{:else if authMethod === 'jwt'} -
- - vault?.jwt_role ?? '', (v) => update({ vault: { ...vault, jwt_role: v ?? '' } }) - } - /> - - vault?.jwt_mount_path ?? '', (v) => setVaultField('jwt_mount_path', v) - } - /> +
+
+ + vault?.jwt_role ?? '', + (v) => update({ vault: { ...vault, jwt_role: v ?? '' } }) + } + /> +
+
+ + vault?.jwt_mount_path ?? '', (v) => setVaultField('jwt_mount_path', v) + } + /> +
{:else} -
+
Vault token - Recommended only for testing. + Recommended only for testing. vault?.token ?? '', (v) => update({ vault: { ...vault, token: v ?? '' } }) @@ -287,7 +326,7 @@
Allowed prefixes - + A reference resolves only under one of these prefixes, matched on whole path segments, for the listed workspaces (all workspaces when empty). Any admin of a listed workspace can read every secret under its prefixes, within what Windmill's Vault identity can read. diff --git a/frontend/src/lib/components/instanceSettings/HttpStoreSecretBackendConfig.svelte b/frontend/src/lib/components/instanceSettings/HttpStoreSecretBackendConfig.svelte index 01e9844cb0..1dac814027 100644 --- a/frontend/src/lib/components/instanceSettings/HttpStoreSecretBackendConfig.svelte +++ b/frontend/src/lib/components/instanceSettings/HttpStoreSecretBackendConfig.svelte @@ -117,11 +117,11 @@ } -
+
-

Generic HTTP store configuration

+

Generic HTTP store configuration

Read secrets from any secret store with an HTTP API. Windmill only reads: values are managed in the store. To reference a secret, save a secret variable with an empty value, and @@ -150,7 +150,7 @@ - PEM file of extra CAs trusted for the store's server certificate, re-read when it changes - Only enable for self-signed certificates in development.

@@ -193,7 +193,7 @@ - Appended to the base URL. {'{workspace}'} and {'{path}'} must each appear here or in a query value, so that workspaces cannot read each other's secrets. @@ -219,7 +219,7 @@
Path encoding - How a variable path becomes the store key: {EXAMPLE_PATH} → {exampleKey} @@ -244,7 +244,7 @@ - JSON pointer to the value in the response, e.g. /data/value. Empty means the whole body is the value. @@ -268,7 +268,7 @@
Authentication - Credential files must be mounted on servers and workers; agent workers never read them. {#if cfg().auth?.type === 'StaticHeader'} -
+
@@ -301,7 +301,7 @@
{:else if cfg().auth?.type === 'BearerTokenFile'} -
+
@@ -317,7 +317,7 @@ - The prefix goes before the token. Left empty, it is Bearer for the Authorization header and nothing for any other header. @@ -339,7 +339,7 @@ - The file is re-read at this interval, and sooner after a 401 (default 60)
{:else if cfg().auth?.type === 'ClientCertificate'} -
+
- PEM file with the client certificate, optionally followed by its intermediates Reload interval in seconds (optional) - The files are re-read at this interval, and sooner after a failed connection (default 300). A new certificate is only used once its key matches. @@ -419,7 +419,7 @@
Test connection - Reads one secret that exists in the store, given as the workspace and variable path that map to it. The value is not shown. @@ -436,7 +436,7 @@
Test connection
- Secret Migration - Secret migration + Original values are NOT deleted to allow for rollback.
-
+
@@ -779,7 +806,7 @@ vault write auth/{jwtMount}/role/{$values['secret_backend']?.jwt_role || 'windmi startIcon={{ icon: ArrowRight }}>Migrate to Vault
-
+
@@ -797,11 +824,11 @@ vault write auth/{jwtMount}/role/{$values['secret_backend']?.jwt_role || 'windmi
{:else if selectedType === 'AzureKeyVault'} -
+
-

Azure Key Vault Configuration

+

Azure Key Vault configuration

Store secrets in an Azure Key Vault instance.

@@ -848,24 +875,23 @@ vault write auth/{jwtMount}/role/{$values['secret_backend']?.jwt_role || 'windmi bind:value={$values['secret_backend'].client_id} />
-
+
Client secret (optional) - Leave blank to use Azure Workload Identity. Requires AZURE_FEDERATED_TOKEN_FILE on the Windmill process (auto-injected on AKS by the workload-identity webhook; set manually on other Kubernetes clusters).
-
+
- Static Bearer token for testing. If provided, OAuth2 is skipped.Static bearer token for testing. If provided, OAuth2 is skipped.
@@ -873,19 +899,19 @@ vault write auth/{jwtMount}/role/{$values['secret_backend']?.jwt_role || 'windmi
Test connection
- Secret Migration - Secret migration + Original values are NOT deleted to allow for rollback.
-
+
@@ -898,7 +924,7 @@ vault write auth/{jwtMount}/role/{$values['secret_backend']?.jwt_role || 'windmi startIcon={{ icon: ArrowRight }}>Migrate to Azure KV
-
+
@@ -916,11 +942,11 @@ vault write auth/{jwtMount}/role/{$values['secret_backend']?.jwt_role || 'windmi
{:else if selectedType === 'AwsSecretsManager'} -
+
-

AWS Secrets Manager Configuration

+

AWS Secrets Manager configuration

Store secrets in AWS Secrets Manager.

@@ -935,9 +961,9 @@ vault write auth/{jwtMount}/role/{$values['secret_backend']?.jwt_role || 'windmi
Access key ID (optional) - If not provided, the default AWS credential chain is used (env vars, instance profile, EKS pod identity) @@ -951,17 +977,17 @@ vault write auth/{jwtMount}/role/{$values['secret_backend']?.jwt_role || 'windmi bind:value={$values['secret_backend'].access_key_id} />
-
+
Secret access key (optional)
Secret name prefix (optional) - Prefix for secret names in AWS Secrets Manager (default: windmill/) Endpoint URL (optional) - Custom endpoint for LocalStack or other compatible services Test connection
- Secret Migration - Secret migration + Original values are NOT deleted to allow for rollback.
-
+
@@ -1015,7 +1041,7 @@ vault write auth/{jwtMount}/role/{$values['secret_backend']?.jwt_role || 'windmi startIcon={{ icon: ArrowRight }}>Migrate to AWS SM
-
+