Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: by default, if a token is found in Vaults ~/.vault-token, use thi… #1228

Merged
merged 4 commits into from
Jul 18, 2019
Merged

fix: by default, if a token is found in Vaults ~/.vault-token, use thi… #1228

merged 4 commits into from
Jul 18, 2019

Conversation

jurgenweber
Copy link
Contributor

…s and renew when necessary...

as per the outrage outlined here which seems to have been ignored;

#1182

@hashicorp-cla
Copy link

hashicorp-cla commented Jul 11, 2019

CLA assistant check
All committers have signed the CLA.

@jurgenweber jurgenweber changed the title fix: by default, if a token is found in Vaults /.vault-token, use thi… fix: by default, if a token is found in Vaults ~/.vault-token, use thi… Jul 11, 2019
@eikenb
Copy link
Contributor

eikenb commented Jul 16, 2019

Thanks for the PR @jurgenweber,

This does look like a pretty bad regression. My guess is that it was missed before due to the comments being on the merged PR instead of in a new issue. I know I missed it completely due to that as I only reviewed open issues and PRs when picking up the project.

I'm sort of confused by a something thouh... Why does setting vault_agent_token_file to a value, set renew_token to false? Why not respect both configuration fields so that if you want the token file without renewing, you set your config up that way? That would allow for both the use case where you don't want it renewed (which seems was part of the initial ask for that option) and where you do what it renewed (as is the case here).

@eikenb
Copy link
Contributor

eikenb commented Jul 16, 2019

To put this another way... why isn't the fix for this to just remove this line...

c.RenewToken = Bool(false)

Maybe with something to expand $HOME in vault_agent_token_file if that seems useful?

@eikenb
Copy link
Contributor

eikenb commented Jul 16, 2019

Spoke with @kyhavlov about this and he agrees that the renew field should still be respected even though the vault_agent_token_file is set. That we should remove that above line.

He also thought it might be a good idea to just still accept ~/.vault-token as implemented here to keep backwards compatibility for now. That it would remain undocumented and only remain for compatibility.

@eikenb
Copy link
Contributor

eikenb commented Jul 16, 2019

Reviewing issues and came across #1189 which this will directly fix.

@eikenb
Copy link
Contributor

eikenb commented Jul 16, 2019

Oh.. and I think I like the idea presented there of making renew_token=false the default if vault_agent_token_file is set to help maintain compatibility for those who are already using it.

@jurgenweber
Copy link
Contributor Author

Yeah, removing that line makes sense.. It should be honoured. I updated it.

@eikenb eikenb added this to the v0.20.1 milestone Jul 16, 2019
@eikenb
Copy link
Contributor

eikenb commented Jul 17, 2019

Thanks @jurgenweber ... but thinking about it there are probably a couple more things needed.

First is that I do think we should make an allowance for people who picked this up since the changed behavior and make renew_token default to false if vault_agent_token_file is set. Maybe something like what you have plus changing..

if c.RenewToken == nil {
c.RenewToken = boolFromEnv([]string{
"VAULT_RENEW_TOKEN",
}, DefaultVaultRenewToken)
}

to..

	if c.RenewToken == nil {
		default_renew := DefaultVaultRenewToken
		if c.VaultAgentTokenFile != nil {
			default_renew = false
		}
		c.RenewToken = boolFromEnv([]string{
			"VAULT_RENEW_TOKEN",
		}, default_renew)
	}

Or something to that end (please feel free to come up with something better).

Second, the documentation in the README.md for the vault_agent_token_file needs to be updated. Specifically the line "# - Consul Template will not try to renew the Vault token." needs to go away. I'm not sure if something needs to be said about the renew_token or not. I'll probably ask one of documentation writers for their opinion on it before finalizing it.

I can do any/all of this, but thought you might be interested.

Thanks!

@jurgenweber
Copy link
Contributor Author

ok, added. I did not remove that comment but just explained further.. Maybe that makes more sense?

@eikenb
Copy link
Contributor

eikenb commented Jul 18, 2019

Thanks. Looks good and I like your change to the comment. I think I'll add a test, but I'll commit that later.

@eikenb eikenb merged commit e58635f into hashicorp:master Jul 18, 2019
@jurgenweber jurgenweber deleted the fix_home_token_location_regression branch July 18, 2019 07:58
@devlounge
Copy link

Awesome!
When will this be released?

@eikenb
Copy link
Contributor

eikenb commented Jul 19, 2019

At this point I have one more issue I'd like to fix before putting out a release. So soon-ish.. depending on how tough that issue is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants