Repository navigation
Closed
Labels
authrelated to tokens, authentication state, or oauthcoreThis issue is not accepting PRs from outside contributorsenhancementa request to improve CLI
Description
After successfully authenticating with GitHub CLI #1413, we could potentially prime the user's git credential cache with a token that can be used for git clone/push/pull operations.
What this solves: users would no longer get another authentication prompt (this time from git, but the user typically doesn't know that) right after they've authenticated gh and ran something like gh repo clone myrepo. Furthermore, if the user has 2FA enabled, even though the git prompt asks them for their github.com password, their actual password will not work and they will have to generate a Personal Access Token. However, at this point in GitHub CLI we already have a token for them that is valid for git operations.
How this would work, roughly:
$ git config --global credential.helper
osxkeychain
$ git credential-osxkeychain
usage: git credential-osxkeychain <get|store|erase>
# getting an existing token
$ git credential-osxkeychain get <<<"host=github.com
protocol=https"
password=TOKEN
username=mislav
# setting a new token (old one needs to be `erase`d first)
$ git credential-osxkeychain store <<<"host=github.com
protocol=https
username=mislav
password=NEWTOKEN"Risks:
- With Git for Windows and its default credential helper, requesting a cached credential could spawn a graphical window asking to log into GitHub if there is no stored credential. We would definitely want to avoid that.
- Depending on OS permissions and the configured credential helper, gh executable might not have the privileges to check or store git credentials.
- There might be no credential helper configured for the user on Linux. In those cases, it would be hard to pick a default for a user, so we should probably bail out in that case, but we could provide the user with some pointers.
Reacted by Valentin Hăloiu, Ludwik Trammer, Michelangelo Bucci, Marius Filipowski, Nir Adler, Benjamin Lea, Simone Primarosa, Horace Williams, Matthew Conto, Craig S. Keogh and 2 more
Metadata
Metadata
Assignees
Labels
authrelated to tokens, authentication state, or oauthcoreThis issue is not accepting PRs from outside contributorsenhancementa request to improve CLI
Activity
mislav commentedon Nov 16, 2020
If the user already has SSH keys in their
~/.sshdirectory, GitHub CLI could offer to default to SSH protocol for cloning/pushing and ensure that the public SSH key is uploaded to the user's account.If there are no local SSH keys, but the user indicates that they would still like to use SSH for authentication (e.g. if their org mandates it), we could guide the person through the process of generating a new SSH key and upload the resulting public key to the GitHub account, so that the user could be quickly up-and-running on a fresh machine. Idea by
@LeonardAukea🙇