Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide automatic git authentication to GitHub #96069

Merged
merged 4 commits into from
Apr 27, 2020
Merged

Conversation

joaomoreno
Copy link
Member

@joaomoreno joaomoreno commented Apr 24, 2020

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 @egamma @kieferrm @RMacfarlane @Tyriar @chrisdias

@joaomoreno joaomoreno self-assigned this Apr 24, 2020
@joaomoreno joaomoreno added the git GIT issues label Apr 24, 2020
@joaomoreno joaomoreno added this to the April 2020 milestone Apr 24, 2020
@Tyriar
Copy link
Member

Tyriar commented Apr 24, 2020

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
Member Author

@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
Member Author

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

@joaomoreno joaomoreno merged commit c7fec92 into master Apr 27, 2020
@joaomoreno joaomoreno deleted the joao/github-auth branch April 27, 2020 10:23
@github-actions github-actions bot locked and limited conversation to collaborators Jun 11, 2020
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