Skip to content

Provide automatic git authentication to GitHub - #96069

Merged
João Moreno (joaomoreno) merged 4 commits into
masterfrom
joao/github-auth
Apr 27, 2020
Merged

João Moreno (joaomoreno) merged 4 commits into
masterfrom
joao/github-auth

Conversation

@joaomoreno

@joaomoreno João Moreno (joaomoreno) commented Apr 24, 2020 •

Copy link
Copy Markdown
Contributor

Fixes #96241

The Git extension currently already hijacks into the GIT_ASKPASS mechanism to provide UI to prompt the user for credentials when they try to run git commands over an HTTPS-based remote and do not have any credential manager installed:

image

This PR adds a new registerCredentialsProvider method to the Git extension API which allows other extensions to contribute to that mechanism and provide credentials themselves, before the last resort of prompting the user is used. Using the new vscode.authentication API, an extension can easily provide GitHub access tokens as credentials. We would have automatic authentication for all Git: Pull, Git: Push, etc. commands in our UI for GitHub repositories!

We could implement this in the GHPR extension, but another option is to simply implement this in the github-authentication core extension. Why not have this built into the core?

This PR implements exactly that.


The authentication authorization dialog currently looks like this:

image

It feels strange that GitHub Authentication appears in there.

  • Should we simply rename the extension to GitHub?
  • Or even rename the extension's id to github, for that matter?
  • Also, should this prompt even show up for built-in extensions at all?

Also, while this tackles git commands in the UI, it doesn't address terminal commands yet. Once #96061 lands, we'll be able to simply add a GIT_ASKPASS env var to terminals and even git pull, git push, etc. commands in the integrated terminal would have GitHub automatic authentication working.

cc Erich Gamma (@egamma) Kai Maetzel (@kieferrm) Rachel Macfarlane (@RMacfarlane) Daniel Imms (@Tyriar) Chris Dias (@chrisdias)

@Tyriar

Copy link
Copy Markdown
Contributor

Should we simply rename the extension to GitHub?

I was always hoping that eventually the GHPR extension would be simply "GitHub", especially now since it has issues in it as well.

@joaomoreno

Copy link
Copy Markdown
Contributor Author

Rachel Macfarlane (@RMacfarlane) had a great idea to tackle the dialog without any big decisions: we can make it such that the Git extension requests access to the creds, making it read:

The extension 'Git' wants to sign in using GitHub.

Which I really like. 👍

@joaomoreno

Copy link
Copy Markdown
Contributor Author

Alright, ended up moving the code into the Git extension for now, which means the dialog will look nice.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

git GIT issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Git: Provide automatic HTTPS authentication with GitHub

2 participants