From 1e118a5410c064310aa804ff78defa4c52ffa8ca Mon Sep 17 00:00:00 2001 From: John Murret Date: Thu, 14 Apr 2022 12:18:06 -0600 Subject: [PATCH] set vault namespaces on vault client prior to logging in with the vault auth method --- agent/connect/ca/provider_vault.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/agent/connect/ca/provider_vault.go b/agent/connect/ca/provider_vault.go index 787e5a247..dd548b218 100644 --- a/agent/connect/ca/provider_vault.go +++ b/agent/connect/ca/provider_vault.go @@ -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 { @@ -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