Commit graph

17 commits

Author SHA1 Message Date
Sam Coe
fd7dc25e2a
Add error to auth refresh when active user does not match newly authenticated token user 2023-12-06 16:51:48 -04:00
Sam Coe
024cb939af Rename authCfg.Token to authCfg.ActiveToken and authCfg.SetToken to authCfg.SetActiveToken 2023-12-06 14:06:28 +01:00
Sam Coe
1a3392a379 Rename authCfg.User to authCfg.ActiveUser 2023-12-06 14:06:28 +01:00
Sam Coe
eca5f72328 UX polish and standardization of language 2023-12-06 14:06:28 +01:00
Sam Coe
c9a2d85793
Cleanup config.AuthToken and config.DefaultHost methods (#7049) 2023-02-28 00:24:45 +00:00
Sam Coe
47b27cde4b
Handle erase operation in auth git-credential command (#6805) 2023-01-03 14:03:27 -08:00
Sam Coe
cacff4ad6d
Use go-gh config package (#5771) 2022-06-23 11:50:04 +00:00
Håvard Anda Estensen
58cb773e09
Replace ioutil with io and os (#5498) 2022-04-26 13:07:44 +02:00
Mislav Marohnić
6701b526d1 Fix authenticating git operations after auth login --with-token
After completing the interactive `gh auth login` flow, the `hosts.yml`
config file will have been populated with both `oauth_token` and `user`
properties for the GitHub host. However, after `auth login --with-token`
only the `oauth_token` is persisted but no username.

This fixes `auth git-credential` behavior so it allows authentication
even if the `user` property is missing. It's entirely optional to send a
proper username for git authentication, since GitHub seems to ignore the
actual value sent and just focuses on the token itself.
2022-02-09 00:10:10 +01:00
Nate Smith
4b415f80d7
Merge pull request #5022 from cli/config-defaults
add GetOrDefault and related methods to Config
2022-01-17 10:44:28 -06:00
Mislav Marohnić
583af3e54c
Allow gh auth git-credential to authenticate GitHub Gist requests (#3064)
* Allow `gh auth git-credential` to authenticate GitHub Gist requests

When there are stored credentials for `example.com`, allow using them to
authenticate requests to `gist.example.com` as well.

* Fix writing out of credential config

* remove unneccessary function

* actually delete

Co-authored-by: nate smith <vilmibm@github.com>
2022-01-14 22:18:07 +00:00
nate smith
0a619d422a undo overzealous find/replace 2022-01-14 15:27:05 -06:00
nate smith
562f1b3d0d add GetOrDefault functionality to config 2022-01-11 14:56:58 -06:00
Mislav Marohnić
11fbb60ae7 Rename the module to "github.com/cli/cli/v2" 2021-08-25 12:41:30 +02:00
Mislav Marohnić
9bf1668b3f Fix auth git-credential when the token comes from environment
When a token such as GH_TOKEN is set through environment variables and
`~/.config/gh/hosts.yml` is non-existent, the `auth git-credential get`
command used to fail due to missing username.

Since GitHub username isn't at all required for token authentication,
use the `x-access-token` faux username instead of trying to obtain one
from a config file.
2021-02-19 15:37:11 +01:00
Mislav Marohnić
3c76eb15a4 Add tests for auth git-credential command 2020-12-07 20:01:53 +01:00
Mislav Marohnić
d56d92c908 If git credential helper is non-defined, set gh as credential helper 2020-11-23 20:20:05 +01:00