fix: authenticate HashiCorp Vault login against the configured Enterprise namespace#13
Merged
Merged
Conversation
jcastiarena
approved these changes
Jul 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On Vault Enterprise, credentials and roles are scoped to a namespace, so the
setuplogin must target that namespace — otherwise Vault returns access denied. Until nowsetupalways logged in against the root namespace ($VAULT_ADDR/v1/auth/userpass/login/...), so namespace-scoped credentials failed authentication.store/retrieve/deletealready worked because they embed the fullVAULT_PATH_PREFIX(which carries the namespace) into their request paths — only the login was namespace-unaware.Change
setupnow derives the Vault namespace fromVAULT_PATH_PREFIX(envVAULT_PATH_PREFIX/ config.setup.namespace) and prefixes both theuserpassandkuberneteslogin URLs with it.Derivation rule — trailing
/dataonly: the namespace is derived only when the prefix ends in the KV v2datasegment..setup.namespacesecret/data/nullplatform(default)secret/data/nullplatform/…secret/data/team-xsecret/data/team-x/…admin/ns/dataadmin/nsadmin/ns/data/…admin/team/sub/dataadmin/team/subadmin/team/sub/data/…A
datasegment in the middle (the default, or any custom root-namespace subpath such assecret/data/team-x/kv/data/foo) is treated as a plain KV mount + path in the root namespace and derives no namespace. Since<mount>/data/<subpath>and<namespace>/data/<subpath>are textually indistinguishable, matching only a trailing/datais what keeps existing non-Enterprise deployments working unchanged.Matching is segment-safe (
.../databasedoes not end in/data). The namespace path is not URL-encoded on purpose: its/are real path separators for nested namespaces.Trade-off (documented)
An Enterprise namespace combined with a KV subpath after
data(admin/ns/data/foo) is not auto-derived — configure the prefix ending at<namespace>/data.Test plan
bats parameters/tests/providers/hashicorp-vault/*.bats→ 51/51 passshellcheckclean onsetup/dataderivation (userpass + kubernetes), default → root login, non-default root prefix (secret/data/team-x) → root login (regression guard), subpath-after-data → root login,databasesegment-safety, and that the exportedVAULT_PATH_PREFIXkeeps its full value (store/retrieve compose paths from it verbatim).Docs
Updated the provider
README.md,docs/architecture.md, the config schema field description, andCHANGELOG.md.