Commit graph

16 commits

Author SHA1 Message Date
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ć
1bd6d7b36c Extract parts of HTTPS-related setup shared between login and refresh 2021-02-04 18:36:42 +01:00
Mislav Marohnić
5a110c8e42 Add SSH key generation & uploading to gh auth login flow 2021-02-01 23:34:00 +01:00
Mislav Marohnić
c9407b2629 More descriptive error when aborting auth due to environment variables
Old message:

    read-only token in GH_TOKEN cannot be modified

This message was vague and some users did not understand that this
refers to the value that is read from environment variables.

New message:

    $ GH_TOKEN=123 ghd auth login -h github.com
    The value of the GH_TOKEN environment variable is being used for authentication.
    To have GitHub CLI store credentials instead, first clear the value from the environment.
2021-01-20 18:27:35 +01:00
Mislav Marohnić
75ebb863e3 Use testify assertions for error matching 2021-01-19 13:59:37 +01:00
Mislav Marohnić
38ea595ce2 Fix refresh test 2020-12-07 20:07:20 +01:00
Mislav Marohnić
381e83e6e5 Extend git credential prompt to auth refresh 2020-12-07 20:01:16 +01:00
vilmibm
a2aa154794 port entirely to ColorScheme 2020-10-29 12:37:45 -07:00
vilmibm
3a492b892a Merge branch 'disable-prompts' of github.com:cli/cli into disable-prompts 2020-09-11 11:42:20 -05:00
vilmibm
1073c97409 review feedback 2020-09-11 11:36:24 -05:00
vilmibm
4d3e26e927 prompts disabled test for auth refresh
the behavior for nontty vs. prompts disabled is pretty different so i
opted for a new test, here
2020-09-10 13:19:43 -05:00
vilmibm
c0fc31f7d5 use CanPrompt in commands 2020-09-10 12:13:48 -05:00
vilmibm
15bfb5447b split auth flow code into new internal package 2020-09-10 12:13:48 -05:00
Mislav Marohnić
c80292c2e8 Extend Config object with GITHUB_TOKEN support
Adding GITHUB_TOKEN & GITHUB_ENTERPRISE_TOKEN support orthogonal to
Config was getting out of hand, especially in `auth` commands that
adjust their messaging and error status based on the presence of these
environment variables.

The new approach builds in support for tokens from environment straight
into Config object by composition. Thus, commands need not ever be
concerned with any specific environment variables.
2020-09-07 21:33:26 +02:00
vilmibm
2f1e9ecc7a review feedback 2020-08-12 12:06:14 -05:00
vilmibm
f1c0d04bc0 gh auth refresh 2020-08-12 12:05:27 -05:00