Skip to content

Commit

Permalink
Ignore any existing token during CLI login (#7508)
Browse files Browse the repository at this point in the history
Fixes #6694
  • Loading branch information
Jim Kalafut authored Sep 25, 2019
1 parent ba834f8 commit 6a14065
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions command/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ func (c *LoginCommand) Run(args []string) int {
return 2
}

// Evolving token formats across Vault versions have caused issues during CLI logins. Unless
// token auth is being used, omit any token picked up from TokenHelper.
if authMethod != "token" {
client.SetToken("")
}

// Authenticate delegation to the auth handler
secret, err := authHandler.Auth(client, config)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions command/login_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ func TestLoginCommand_Run(t *testing.T) {
t.Fatal(err)
}

// Emulate an unknown token format present in ~/.vault-token, for example
client.SetToken("a.a")

code := cmd.Run([]string{
"-method", "userpass",
"-path", "my-auth",
Expand Down

0 comments on commit 6a14065

Please sign in to comment.