Files
windmill/frontend/src/lib/externalSecretRef.ts
T
6f4124e9a0 feat: reference existing HashiCorp Vault secrets from secret variables (#12078)
* feat: reference existing HashiCorp Vault secrets from secret variables

A secret variable can hold `$external:vault://<path>#<key>` instead of a
value. The reference is resolved from Vault each time the variable is
read, so the value is never stored in Windmill. An instance-level
allow-list of path prefixes, optionally per workspace, is checked when a
reference is saved and again when it is resolved. Other schemes are
parsed and refused as unsupported backends.

Adds AppRole as a Vault auth method, an "External reference" toggle in
the variable editor and an instance settings section for the connection
and the allow-list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore: point ee-repo-ref at the external secret references branch

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: keep external secret references intact on delete, deploy and export

- Deleting a reference no longer runs the managed backend cleanup, which
  could delete the secret it points at.
- Deploying a variable to another workspace copies the reference, which
  the target's allow-list then checks, instead of its resolved value.
- A plain-secrets workspace export writes references verbatim.
- Reference paths reject backslashes, `#` and control characters, which
  the URL parser would otherwise normalize past the allow-list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: skip external secret references in key rotation and the read cache

- Workspace key rotation no longer tries to decrypt references.
- `get_value?allow_cache=true` does not cache a resolved reference, so
  Vault rotation and allow-list changes apply on the next read.
- `VaultSettings.mount_path` is optional in the OpenAPI spec, matching
  its serde default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore: keep the OSS Vault reader stub public and regenerate workspace tool schemas

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: restrict external secret references to workspace admins and keep them out of the managed Vault storage

Creating, repointing or removing a reference now takes a workspace admin, on
create and update including already-encrypted pushes and cross-workspace
deploys; the variable form disables the toggle and fields for anyone else.

A reference into the storage of Windmill's own Vault secret backend (same
address, namespace folded into the path) is refused on save and on resolve,
whatever the allow-list says.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: compare external secret references as written in workspace comparison

Two references that currently resolve to the same value still point at
different secrets, so comparing their resolved values hid a repoint from the
diff and from deployment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: let external secret references reuse the Vault backend connection

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: hide the external reference toggle from non-admins unless already set

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: read whole Vault secrets, show allowed paths, and pick the variable type in one control

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: mask JSON fields only for whole Vault secrets, and skip PEM armor and JSON lines

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: align the reference editor and settings warning with the form and alert guidelines

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: let a saved reference become non-secret directly, and warn when no prefix is allowed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: save an empty value when a reference is switched to another type

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: keep a saved reference's baseline through type round trips

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: drop an unused binding in the reference parser

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: offer vault reference only when a vault path is allowed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore: update ee-repo-ref to c0fd22ba77e6618cea7611d72fe2e75c8855c595

This commit updates the EE repository reference after PR #932 was merged in windmill-ee-private.

Previous ee-repo-ref: 56cba4e7771e7a87e56a67eb115549a31dd12b1a

New ee-repo-ref: c0fd22ba77e6618cea7611d72fe2e75c8855c595

Automated by sync-ee-ref workflow.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Ruben Fiszel <ruben@windmill.dev>
Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com>
2026-10-30 20:23:27 +01:00

27 lines
1.2 KiB
TypeScript

// A secret variable whose stored value is `$external:<scheme>://<path>[#<key>]` is resolved
// from an external secret store each time it is read, without a key as a JSON object of all
// the secret's fields; the backend parses and authorizes it
// (`secret_backend/external_ref.rs`). Only Vault is supported.
export const EXTERNAL_REF_PREFIX = '$external:'
const VAULT_PREFIX = `${EXTERNAL_REF_PREFIX}vault://`
export function isExternalRef(value: string | undefined | null): boolean {
return !!value?.startsWith(EXTERNAL_REF_PREFIX)
}
export function parseVaultRef(value: string): { path: string; key: string } {
const rest = value.startsWith(VAULT_PREFIX) ? value.slice(VAULT_PREFIX.length) : ''
const i = rest.indexOf('#')
return i < 0 ? { path: rest, key: '' } : { path: rest.slice(0, i), key: rest.slice(i + 1) }
}
export function formatVaultRef(path: string, key: string): string {
return `${VAULT_PREFIX}${path}${key ? `#${key}` : ''}`
}
/** "Vault · secret/team/app#token", or "Vault · secret/team/app" for the whole secret, for lists. */
export function describeExternalRef(value: string): string {
const { path, key } = parseVaultRef(value)
return `Vault · ${path}${key ? `#${key}` : ''}`
}