From f454fa9ef230bb20aef9a45f6e10ca67727d03f2 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Tue, 13 Oct 2020 17:13:31 -0400 Subject: [PATCH] Don't return error code 1 if saving the value to the keyring (#668) --- internal/cmd/base/base.go | 2 ++ internal/cmd/commands/authenticate/password.go | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/cmd/base/base.go b/internal/cmd/base/base.go index 902ee5fd9..30a36c74d 100644 --- a/internal/cmd/base/base.go +++ b/internal/cmd/base/base.go @@ -234,7 +234,9 @@ func (c *Command) ReadTokenFromKeyring(tokenName string) *authtokens.AuthToken { if err == keyring.ErrNotFound { c.UI.Info("No saved credential found, continuing without") } else { + // TODO: potentially look for dbus-launch in advance and don't issue a warning at all c.UI.Error(fmt.Sprintf("Error reading auth token from system credential store: %s", err)) + c.UI.Warn("Token must be provided via BOUNDARY_TOKEN env var or -token flag. Reading the token can also be disabled via -token-name=none.") } token = "" } diff --git a/internal/cmd/commands/authenticate/password.go b/internal/cmd/commands/authenticate/password.go index c337e05ed..41c2d37c1 100644 --- a/internal/cmd/commands/authenticate/password.go +++ b/internal/cmd/commands/authenticate/password.go @@ -168,9 +168,10 @@ func (c *PasswordCommand) Run(args []string) int { c.UI.Error(fmt.Sprintf("Error marshaling auth token to save to system credential store: %s", err)) return 1 } + // TODO: potentially look for dbus-launch in advance and don't issue a warning at all if err := keyring.Set("HashiCorp Boundary Auth Token", tokenName, base64.RawStdEncoding.EncodeToString(marshaled)); err != nil { c.UI.Error(fmt.Sprintf("Error saving auth token to system credential store: %s", err)) - return 1 + c.UI.Warn("The token printed above must be manually passed in via the BOUNDARY_TOKEN env var or -token flag. Storing the token can also be disabled via -token-name=none.") } }