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

auth tokens cache overrides auth token specified via env variable #175

Closed
preslavmihaylov opened this issue Feb 9, 2022 · 2 comments · Fixed by #182
Closed

auth tokens cache overrides auth token specified via env variable #175

preslavmihaylov opened this issue Feb 9, 2022 · 2 comments · Fixed by #182
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@preslavmihaylov
Copy link
Owner

Whenever you specify an auth token for e.g. domain hello.myjira.net with auth token via env variable:

$ TODOCHECK_AUTH_TOKEN=<auth-token> ./todocheck

if there is an auth token already present for that domain in ~/.todocheck/authtokens.yaml, todocheck will use the auth token from that file vs. using the one specified via the env variable.

This shouldn't happen. The env variable should override the auth tokens cache.

@preslavmihaylov preslavmihaylov added bug Something isn't working good first issue Good for newcomers labels Feb 9, 2022
@aaronangxz
Copy link
Contributor

Hello! stumbled upon your repo and I'll love to start contributing to some minor issues :)

For this fix, can we make some changes to acquireToken in authmanager.go:

	if store.Tokens[tokenKey] != "" {
		authCfg.Token = store.Tokens[tokenKey]
		return nil
	} else if envToken := os.Getenv(authTokenEnvVariable); envToken != "" {
		authCfg.Token = envToken
		return nil
	}

It seems like the cache token has higher priority than the env variable. CMIIW, thanks!

@preslavmihaylov
Copy link
Owner Author

hey, @aaronangxz thanks for considering contributing!

Go for it, feel free to open a PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants