Commit graph

130 commits

Author SHA1 Message Date
vilmibm
8f3032af36 use Prompter in auth commands 2022-09-13 13:22:50 -07:00
Sam Coe
2fc0ffd0be
Fix auth refresh prompter initialization (#6141)
* Fix prompter not being initialized in auth refresh

* fix broken issue list test
2022-08-25 12:07:40 +03:00
Sam Coe
6955db471d
Set default value for all Select prompts (#6131) 2022-08-24 09:10:38 +03:00
Nate Smith
49adbe3fe6
Merge pull request #6079 from white-hat/6066-fix-git-protocol
fix protocol not being set when token is read from stdin
2022-08-15 16:54:59 -05:00
vilmibm
2d093c1741 add test helpers 2022-08-15 13:53:43 -05:00
Ilya Trushchenko
0a73192ace fix protocol not being set when token is read from stdin 2022-08-15 14:12:19 -04:00
vilmibm
41385477c3 fix linting 2022-07-27 14:15:27 -05:00
vilmibm
d5334f4115 Revert "update linter checks"
This reverts commit 40ecb8c188.
2022-07-27 13:30:41 -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
40ecb8c188 update linter checks 2022-07-26 16:06:52 -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
Sam Coe
074ed50b8a
Integrate go-gh API package (#5614) 2022-06-23 04:05:31 +01: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
9095556372 Merge remote-tracking branch 'upstream/trunk' into jungaretti/no-ssh-keys 2022-06-07 12:07:03 -05:00
cmbrose
60032db5eb Use function options pattern 2022-06-07 11:04:08 -05:00
Jonathan Fenwick
2abe1b3294
Remove auth logout confirmation prompt (#5751) 2022-06-07 15:26:53 +00: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
Mislav Marohnić
57d0581504 Add note about git auth 2022-02-21 15:24:54 +01:00
Mislav Marohnić
9cbfe73140 Have core commands have consistent Short description 2022-02-18 18:39:30 +01:00
Mislav Marohnić
0f956c8502 auth login: clarify authentication alternatives 2022-02-18 18:39:30 +01: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ć
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
Kevin Lee
0d143ca89c
Consistent punctuation in command usages (#5139)
* Fix spelling and grammatical errors in command docs
* Add periods for consistency across the long command descriptions
* Format imports
2022-01-31 10:56:12 +00: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ć
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
nate smith
0a619d422a undo overzealous find/replace 2022-01-14 15:27:05 -06:00
Mislav Marohnić
e43cb2b880 Port more legacy stubs to the new ask stubber 2022-01-14 19:34:15 +01:00
Mislav Marohnić
62bd82809d Port auth login tests to the new ask stubber 2022-01-13 11:56:45 +01:00
Mislav Marohnić
8198cce59b
Merge pull request #3997 from nicknotfun/non-interactive-auth
Add interactive mode to auth flow, pass from login and refresh

Closes #4506
2022-01-12 15:59:30 +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
nate smith
56522f9f14 formatting 2022-01-11 14:57:10 -06:00
nate smith
562f1b3d0d add GetOrDefault functionality to config 2022-01-11 14:56:58 -06:00
Mislav Marohnić
3cce16e72d Refactor factory.Executable() to be a method rather than a func
This way, factory can satisfy an interface that requires `Executable()`.
2021-12-21 13:50:55 +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
Alan Donovan
f4491c7a80 Add FlagErrorf; encapsulate FlagError.error 2021-10-21 11:40:20 -04: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ć
b38ce24497 Ensure correct path to gh after gh auth refresh git credential setup 2021-09-24 14:43:48 +02:00
Mislav Marohnić
d853ce5bc9 Avoid resolving executable() until requested at runtime
This is to avoid hitting the filesystem and resolving symlinks
unnecessarily. The value of executable is just used conditionally by a
handful of commands.
2021-09-24 14:42:41 +02:00