Skip to content

Commit

Permalink
Merge pull request hashicorp#12793 from hashicorp/jm/vault-ns-auth
Browse files Browse the repository at this point in the history
Set vault namespaces on vault client prior to logging in
  • Loading branch information
markan authored Apr 15, 2022
2 parents 319a0a0 + 8ad9bf8 commit 25ef2ea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changelog/12793.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
```release-note:bug
The Connect CA Vault system now sets the Namespace (if present) prior
to attempting to login to Vault. This means the AuthMethod needs to
be in the specified namespace. Previously the AuthMethod needed to be
in the root namespace to work.
15 changes: 8 additions & 7 deletions agent/connect/ca/provider_vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ func (v *VaultProvider) Configure(cfg ProviderConfig) error {
return err
}

// We don't want to set the namespace if it's empty to prevent potential
// unknown behavior (what does Vault do with an empty namespace). The Vault
// client also makes sure the inputs are not empty strings so let's do the
// same.
if config.Namespace != "" {
client.SetNamespace(config.Namespace)
}

if config.AuthMethod != nil {
loginResp, err := vaultLogin(client, config.AuthMethod)
if err != nil {
Expand All @@ -112,13 +120,6 @@ func (v *VaultProvider) Configure(cfg ProviderConfig) error {
}
client.SetToken(config.Token)

// We don't want to set the namespace if it's empty to prevent potential
// unknown behavior (what does Vault do with an empty namespace). The Vault
// client also makes sure the inputs are not empty strings so let's do the
// same.
if config.Namespace != "" {
client.SetNamespace(config.Namespace)
}
v.config = config
v.client = client
v.isPrimary = cfg.IsPrimary
Expand Down

0 comments on commit 25ef2ea

Please sign in to comment.