Skip to content

Commit

Permalink
exec: exit if the credentials aren't accessible
Browse files Browse the repository at this point in the history
If someone can't open the keychain backend or provide access to the
keychain item, it should fail and notify the user
  • Loading branch information
jacobbednarz committed Sep 17, 2020
1 parent e574eb2 commit 19acc15
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cmd/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,15 @@ var execCmd = &cobra.Command{
log.Fatal("cf-vault sessions shouldn't be nested, unset CLOUDFLARE_VAULT_SESSION to continue or open a new shell session")
}

ring, _ := keyring.Open(keyringDefaults)
keychain, _ := ring.Get(fmt.Sprintf("%s-%s", profileName, profileSection.Key("auth_type").String()))
ring, err := keyring.Open(keyringDefaults)
if err != nil {
log.Fatalf("failed to open keyring backend: %s", strings.ToLower(err.Error()))
}

keychain, err := ring.Get(fmt.Sprintf("%s-%s", profileName, profileSection.Key("auth_type").String()))
if err != nil {
log.Fatalf("failed to get item from keyring: %s", strings.ToLower(err.Error()))
}

cloudflareCreds := []string{
fmt.Sprintf("CLOUDFLARE_VAULT_SESSION=%s", profileName),
Expand Down

0 comments on commit 19acc15

Please sign in to comment.