Skip to content

Commit

Permalink
fix: add checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahanmmi committed Nov 14, 2024
1 parent 66dda47 commit c9c35c0
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions pkg/vault/hashicorp_vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ func NewHashiCorpVaultClient(ctx context.Context, logger *zap.Logger, config Has
return nil, err
}

// check if auth was successful
_, err = client.Auth().Token().LookupSelf()
if err != nil {
logger.Error("failed to authenticate", zap.Error(err))
return nil, err
}

secret, err := client.KVv2(secretMountPath).Get(ctx, secretId)
if err != nil {
logger.Error("failed to get secret", zap.Error(err))
Expand Down Expand Up @@ -186,6 +193,13 @@ func NewHashiCorpVaultSecretHandler(ctx context.Context, logger *zap.Logger, con
return nil, err
}

// check if auth was successful
_, err = client.Auth().Token().LookupSelf()
if err != nil {
logger.Error("failed to authenticate", zap.Error(err))
return nil, err
}

return &HashiCorpVaultSecretHandler{
logger: logger,
client: client,
Expand Down Expand Up @@ -245,6 +259,13 @@ func NewHashiCorpVaultSealHandler(ctx context.Context, logger *zap.Logger, confi
return nil, err
}

// check if auth was successful
_, err = client.Auth().Token().LookupSelf()
if err != nil {
logger.Error("failed to authenticate", zap.Error(err))
return nil, err
}

return &HashiCorpVaultSealHandler{
logger: logger,
client: client,
Expand Down

0 comments on commit c9c35c0

Please sign in to comment.