Browse Source

fix: add namespace to path and route construction (#3632)

* fix: add namespace to path and route construction

Signed-off-by: Gergely Brautigam <182850+Skarlso@users.noreply.github.com>

* fix: use the correct namespace while restoring from auth namespace

Signed-off-by: Gergely Brautigam <182850+Skarlso@users.noreply.github.com>

* added fix suggestion from Gustavo

Signed-off-by: Gergely Brautigam <182850+Skarlso@users.noreply.github.com>

---------

Signed-off-by: Gergely Brautigam <182850+Skarlso@users.noreply.github.com>
Gergely Brautigam 1 year ago
parent
commit
c078a88d9b
1 changed files with 5 additions and 1 deletions
  1. 5 1
      pkg/provider/vault/auth.go

+ 5 - 1
pkg/provider/vault/auth.go

@@ -43,6 +43,10 @@ const (
 // setAuth gets a new token using the configured mechanism.
 // If there's already a valid token, does nothing.
 func (c *client) setAuth(ctx context.Context, cfg *vault.Config) error {
+	if c.store.Namespace != nil { // set namespace before checking the need for AuthNamespace
+		c.client.SetNamespace(*c.store.Namespace)
+	}
+
 	// Switch to auth namespace if different from the provider namespace
 	restoreNamespace := c.useAuthNamespace(ctx)
 	defer restoreNamespace()
@@ -200,7 +204,7 @@ func revokeTokenIfValid(ctx context.Context, client util.Client) error {
 
 func (c *client) useAuthNamespace(_ context.Context) func() {
 	ns := ""
-	if c.store.Namespace != nil {
+	if c.store != nil && c.store.Namespace != nil {
 		ns = *c.store.Namespace
 	}