Commit graph

59 commits

Author SHA1 Message Date
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
8cdbc1a8ca Refactor authCfg.UsersForHost to not return an error 2023-12-06 14:06:28 +01:00
William Martin
2c72647cf7 Update git protocol login prompt to indicate it is host level 2023-12-06 14:06:28 +01:00
William Martin
1bf6023164 Display message when logging into existing account 2023-12-06 14:06:28 +01:00
William Martin
9efa7248a9 Initial multi-account migration work 2023-12-06 14:06:28 +01:00
Keith Bailey
97755c6bf0
Document when gh auth login writes oauth token to plain text (#7781) 2023-09-18 11:34:13 +02:00
Jamie Tanna
e4cddb562e
Remove GHE handling for workflow scope (#7841)
According to [0] we appear to no longer support GHE 2.x, as the latest
release was deprecated in early 2022.

We can therefore remove this custom handling.

[0]: https://docs.github.com/en/enterprise-server@3.7/admin/all-releases
2023-08-15 17:40:09 +00:00
vaindil
7006d3f0a5 move SSH key errors out of upload function 2023-03-31 13:47:25 -04:00
vaindil
f21f1ca4ef check SSH key existence before uploading 2023-03-29 17:32:25 -04:00
Sam Coe
50ddb369a6
Manually get current user name rather than use api client (#7114) 2023-03-09 11:50:12 +11:00
Sam Coe
df83dc2d58
Add ability to store tokens in encrypted storage (#7043) 2023-02-28 00:04:53 +00:00
Sam Coe
a33e12a21d
Refactor Config interface in preperation for encrypted token storage (#7033) 2023-02-28 10:51:12 +11:00
Ariel Deitcher
a5edd8f542
show token scopes on auth status (#6546)
- show path to config file
- display token prefix
- refine how missing scopes are shown

Co-authored-by: Sam Coe <samcoe@users.noreply.github.com>
Co-authored-by: Mislav Marohnić <mislav@github.com>
2023-01-25 16:25:00 +01:00
Mislav Marohnić
ba028b9044 Fix setting up git credential helper on Windows 2022-11-02 15:53:26 +01:00
Sam Coe
4294ee14a1
revert revert 57fbe4f317 (#6474) 2022-10-20 12:17:20 +00:00
Sam Coe
2cefb9fa59
Fix pr create regression (#6472)
* Revert "Refactor to use new git client (#6447)"

This reverts commit 57fbe4f317.

* Fix pr create regression
2022-10-20 12:46:23 +03:00
Sam Coe
57fbe4f317
Refactor to use new git client (#6447) 2022-10-19 21:11:36 +03:00
Sam Coe
2944f7c3ab
Create git client (#6354) 2022-10-14 07:47:03 +00:00
vilmibm
8f3032af36 use Prompter in auth commands 2022-09-13 13:22:50 -07:00
Sam Coe
6955db471d
Set default value for all Select prompts (#6131) 2022-08-24 09:10:38 +03:00
vilmibm
2d093c1741 add test helpers 2022-08-15 13:53:43 -05:00
vilmibm
e1238015f5 linter appeasement 2022-07-26 16:45:28 -05:00
vilmibm
f7d5c5f725 move prompter to own package 2022-07-26 16:41:13 -05:00
vilmibm
4afb567d06 WIP: survey wrapper 2022-07-26 14:39:38 -05:00
Sam Coe
cacff4ad6d
Use go-gh config package (#5771) 2022-06-23 11:50:04 +00:00
Caleb Brose
83153fe9e5 Cleanups from PR comments 2022-06-14 14:33:41 +00:00
Caleb Brose
919dcebc45 Rename Context 2022-06-13 19:16:16 +00:00
Caleb Brose
b5580f9503 Refactor inferfaces from PR comments 2022-06-13 19:04:29 +00:00
cmbrose
60032db5eb Use function options pattern 2022-06-07 11:04:08 -05:00
cmbrose
2209a84c9d More cleanup 2022-06-03 14:07:41 -05:00
cmbrose
f67ca53c07 Refactor ssh_keys to a more common location 2022-06-03 13:39:52 -05:00
JP Ungaretti
a1629c70c0 Generate codespaces key 2022-05-31 17:19:16 -07:00
Andrew Senetar
ff8aa8a555
Add ability to set title for ssh key in auth login (#5524) 2022-05-23 08:06:42 +00:00
Håvard Anda Estensen
58cb773e09
Replace ioutil with io and os (#5498) 2022-04-26 13:07:44 +02:00
Naïm Favier
8dbd07212c
Stop auth commands from modifying global config file (#5378) 2022-04-11 17:26:18 +02:00
Jonathan Mayer
1eefda0b45
gh auth login: add git protocol flag (#5158)
Co-authored-by: Mislav Marohnić <mislav@github.com>
2022-02-17 19:35:59 +00:00
Mislav Marohnić
a3f0940c62
Merge pull request #5032 from cli/ask-stubber
Improve Survey stubber for tests
2022-01-17 12:32:28 +01: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
Mislav Marohnić
e43cb2b880 Port more legacy stubs to the new ask stubber 2022-01-14 19:34:15 +01:00
Mislav Marohnić
be9f01101a Tweak auth flow re: interactivity
Fixes non-interactive login flow and make sure "prompt" configuration is
respected by never prompting if it was explicitly disabled.

No longer asks to press Enter again after "Authentication complete"
message, since that didn't provide any value to the user.
2022-01-12 15:50:51 +01:00
Nick Cooper
a408f24d3a auth: add noninteractive flow to login/refresh 2022-01-11 22:44:46 +01:00
Des Preston
94a640bd2a
Add auth setup-git for setting up gh as a git credential helper (#4246)
Adds a new command `gh auth setup-git [<hostname>]` that sets up git to
use the GitHub CLI as a credential helper.

The gist is that it runs these two git commands for each hostname the
user is authenticated with.

```
git config --global --replace-all 'credential.https://github.com.helper' ''
git config --global --add 'credential.https://github.com.helper' '!gh auth git-credential'
```

If a hostname flag is given, it'll setup GH CLI as a credential helper
for only that hostname.

If the user is not authenticated with any git hostnames, or the user is
not authenticated with the hostname given as a flag, it'll print an
error.

Co-authored-by: Mislav Marohnić <mislav@github.com>
2021-12-02 16:38:34 +00:00
Mislav Marohnić
2c86e671f3 Enable gh auth login for github.localhost 2021-10-18 20:01:18 +02:00
Mislav Marohnić
89ad870190 auth refresh: preserve existing scopes when requesting new ones
When there was a previously valid token that was granted some scopes,
ensure all those scopes will be re-requested when doing the
authentication flow for the new token.
2021-10-14 19:52:59 +02:00
Mislav Marohnić
11fbb60ae7 Rename the module to "github.com/cli/cli/v2" 2021-08-25 12:41:30 +02:00
Mislav Marohnić
21521b06b9 Check git presence during auth login only if it's going to be needed 2021-08-11 19:22:16 +02:00
Mislav Marohnić
98f1f5ec0d Use absolute path when configuring gh as git credential
This keeps git operations working even when PATH is modified, e.g. `brew
update` will work even though Homebrew runs the command explicitly
without `/usr/local/bin` in PATH.

Additionally, this inserts a blank value for `credential.*.helper` to
instruct git to ignore previously configured credential helpers, i.e.
those that might have been set up in system configuration files. We do
this because otherwise, git will store the credential obtained from gh
in every other credential helper in the chain, which we want to avoid.

Before:

    git config --global credential.https://github.com.helper '!gh auth git-credential'

After:

    git config --global credential.https://github.com.helper ''
    git config --global --add credential.https://github.com.helper '!/path/to/gh auth git-credential'
2021-03-03 16:20:21 +01:00
Mislav Marohnić
cfddda8829 Indicate workflow scope is GHE 3.0+ only during auth login 2021-02-23 10:52:29 +01:00
Mislav Marohnić
f807795491 Fix pasting Personal Access Token to auth login for GHE 2021-02-23 10:19:11 +01:00
Mislav Marohnić
1a9e42ed55 Add ssh-key add command and publish ssh-key 2021-02-17 19:46:59 +01:00