Skip to content

Conversation

bodis
Copy link

@bodis bodis commented Oct 9, 2025

Fixes #7426

Description

Added underscore support to vaultMatch and consulMatch regex patterns to allow secret keys like API_KEY and DB_PASSWORD.

Before: $secret_vault.([A-Za-z0-9\/\-\.]+)
After: $secret_vault.([A-Za-z0-9_\/\-\.]+)

Motivation and Context

Vault references are currently truncated at underscores, forcing users to duplicate secrets with different names. This fixes the regex to match standard naming conventions used in production environments.

Example:

  • Config: $secret_vault.kv-v2/path.API_KEY
  • Current behavior: Only matches up to .API
  • Fixed behavior: Matches full path including .API_KEY

This aligns vault/consul patterns with envValueMatch which already supports underscores.

Breaking Change Note

Potential edge case: If anyone is currently using the underscore as an intentional path terminator (e.g., $secret_vault.path.API_KEY expecting only .API to be processed with _KEY as a literal suffix), this will now include the full path. However, this use case is highly unlikely compared to the standard use of underscores in secret names.

How This Has Been Tested

  • Built successfully with go build
  • Verified regex patterns compile and match underscore paths correctly
  • Tested backward compatibility with existing non-underscore references

Types of changes

New feature (low probability small breaking change but adds functionality) -

Tamás Bódis and others added 2 commits October 9, 2025 11:19
Fixes TykTechnologies#7426 - Allow underscores in $secret_vault and $secret_consul
reference paths to support standard secret naming conventions."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support underscores in Vault secret reference paths

2 participants