Skip to content

Commit

Permalink
Merge pull request #105 from articulate/fix/vault-auth
Browse files Browse the repository at this point in the history
fix(vault): only authenticate vault in known AWS environment
  • Loading branch information
mloberg authored Nov 16, 2022
2 parents 4b49655 + 960e2a3 commit 05281f0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ func loadVault(ctx context.Context, addr string, c Config, l zerolog.Logger) Dic
l.Fatal().Err(err).Msg("Could not authenticate Vault")
}

if auth == "" {
l.Warn().Msg("Not loading values from Vault. Unable to authenticate Vault")
return make(Dict)
}

paths := c.VaultPaths()
if p := os.Getenv("VAULT_PATHS"); p != "" {
paths = append(paths, strings.Split(p, ",")...)
Expand Down
9 changes: 8 additions & 1 deletion vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (v *Vault) Authenticate(ctx context.Context, token, role string) (string, e
}

auth, err := v.getAuthMethod(role)
if err != nil {
if auth == nil || err != nil {
return "", err
}

Expand All @@ -58,6 +58,13 @@ func (v *Vault) getAuthMethod(role string) (api.AuthMethod, error) {
return kubernetes.NewKubernetesAuth(role)
}

ecs := os.Getenv("AWS_CONTAINER_CREDENTIALS_RELATIVE_URI")
lambda := os.Getenv("AWS_LAMBDA_FUNCTION_NAME")

if ecs == "" && lambda == "" {
return nil, nil
}

region := os.Getenv("AWS_REGION")
if region == "" {
region = "us-east-1"
Expand Down

0 comments on commit 05281f0

Please sign in to comment.