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

Implement GitHub Enterprise authn provider #115940

Merged
merged 5 commits into from
May 7, 2021
Merged

Implement GitHub Enterprise authn provider #115940

merged 5 commits into from
May 7, 2021

Conversation

kabel
Copy link
Contributor

@kabel kabel commented Feb 5, 2021

👋 Note from the maintainers: If you arrived here looking for GitHub Enterprise Server support in the GitHub Pull Requests and Issues extension, please see the wiki. GitHub Enterprise is now tested and officially supported (since 0.51).


Adds an additional provider to the github-authentication extension that leverages the same code with minor modifications. A configuration item has been added for users to provide the URI of their GHE instance.

This allows GitHub API related extensions to easily integrate with
either GitHub.com or their on-premise installations.

This PR fixes microsoft/vscode-pull-request-github#1793
Also fixes #112043

Testing requires access to a GitHub Enterprise instance.

@ghost
Copy link

ghost commented Feb 5, 2021

CLA assistant check
All CLA requirements met.

@kabel
Copy link
Contributor Author

kabel commented Feb 5, 2021

Config added for instance URI.

image

@kabel
Copy link
Contributor Author

kabel commented Feb 5, 2021

Successful local test.

image

@mew1033
Copy link

mew1033 commented Feb 9, 2021

Awesome!

@lupalby
Copy link

lupalby commented Feb 13, 2021

I was able to test the changes using the configuration here and I can confirm that it works very well with the GHE instance we use at work.
Great work!

@joaomoreno joaomoreno changed the base branch from master to main February 15, 2021 08:51
@jasonwilliams
Copy link
Contributor

jasonwilliams commented Feb 16, 2021

I can also confirm that after following the instructions from microsoft/vscode-pull-request-github#1793 (comment) this works with our GitHub Enterprise Server.

@RMacfarlane
Copy link
Contributor

Thanks @kabel for picking this up, this is really great! I haven't had time to review this yet, but getting this in is on my to do list

@vortechs2000
Copy link

I can also confirm that after following the instructions from microsoft/vscode-pull-request-github#1793 (comment) this works with our GitHub Enterprise Server.

  • GHE: 2.22
  • VSCode 1.53.2
  • macOS 10.15.7

const json: { verifiable_password_authentication: boolean, installed_version: string } = await result.json();

/* __GDPR__
"ghe-session" : {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assume this would be valuable information to see where users are coming from. I don't know the schema for GDPR, so adjust as necessary.

@vortechs2000
Copy link

@RMacfarlane what needs to happen to get this and #2468 pulled in?

@RMacfarlane
Copy link
Contributor

I just need to review and merge them, I am holding off on doing this since we are in the middle of our stabilization period for the next release where we do not take in new features. We should create our release branch on Friday and I will review after that

@vortechs2000
Copy link

Awesome - very excited for this to get it. Feel free to ping me if you need something validated against a GHE 2.22 server and I'll do my best to help.

@eschweighofer
Copy link

I was able to test the changes using microsoft/vscode-pull-request-github#1793 and confirm it works very well with our GHE instance
Great work!
@RMacfarlane could this be merged?

@kubukoz
Copy link

kubukoz commented Mar 29, 2021

Bumping, I would also love if this got merged and soon released 🙏

@jasonwilliams
Copy link
Contributor

@RMacfarlane is there space in this iteration to review and merge this?

Adds an additional provider to the github-authentication extension that
leverages the same code with minor modifications. A configuration item
has been added for users to provide the URI of their GHE instance.

This allows GitHub API related extensions to easily integrate with
either GitHub.com or their on-premise installations.
@Ygilany
Copy link

Ygilany commented Apr 30, 2021

@RMacfarlane any plans to merge this soon?

kabel added a commit to kabel/vscode-pull-request-github that referenced this pull request May 6, 2021
Uses a new, proposed alternative authentication provider (switch) to
handle authentication and API queries.

Fixed microsoft#1793, microsoft#2282.

Depends on microsoft/vscode#115940
@mew1033
Copy link

mew1033 commented May 6, 2021

I'm super excited for this feature. I use GHE every day for work, and will use the pull request extension so much more when I can pair it with GHE. Can't wait to see this merged!

Copy link
Contributor

@RMacfarlane RMacfarlane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @kabel!

],
"contributes": {
"commands": [
{
"command": "github.provide-token",
"title": "Manually Provide Token"
"title": "GitHub: Manually Provide Token"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of changing the title to include "GitHub", there's another property called category that could be used

@RMacfarlane RMacfarlane merged commit 4978a18 into microsoft:main May 7, 2021
@RMacfarlane RMacfarlane added this to the May 2021 milestone May 7, 2021
@catskul
Copy link

catskul commented May 10, 2021

As of the new PR merge what's the right way to configure this?

@AlexDias95
Copy link

I have the same question, how can I configure the GitHub enterprise?

@kabel kabel deleted the feature/github-enterprise-auth branch May 11, 2021 15:50
@kabel
Copy link
Contributor Author

kabel commented May 11, 2021

As of the new PR merge what's the right way to configure this?

I have the same question, how can I configure the GitHub enterprise?

I would imagine there will be some updated wiki, documentation once this feature bakes into the official release process. That said, it's only available through the Insiders version 1.57 from 2021-05-10 or later.

If your question resolves around how this integrates with the GitHub Pull Requests and Issues extension, you will also need to use the nightly build until an official release. Assuming you have the right version of things installed, you can set the configuration as shown in step 4 of my preview releases.

In all cases, the authentication to Enterprise relies on a Personal Access Token (PAT), that must be manually generated and pasted into the appropriate prompt when you interact with a configured enterprise remote repository. Example: https://domain-of-ghe.your-enterprise.tld/settings/tokens

@AlexDias95
Copy link

@kabel Thanks for the help! I have installed the nightly build version and I have put in settings.json ("github-enterprise.uri": "https://github.XYZ.com",) but how can I add my token to this configuration?

@kabel
Copy link
Contributor Author

kabel commented May 11, 2021

The token is stored in a secure credential manager. It cannot be loaded through configuration; only the UI:

  1. Open a code instance with a workspace/folder that contains a GHE cloned repository. Default remote name origin works out-of-box.
  2. If you have the URI set appropriately (matches clone URI authority), the UI should prompt you that you have an account to authenticate to: image
  3. Click the Accounts icon and select the "Sign in..." option: image
  4. The UI will prompt for the PAT and display a status bar item:
    image
    image
  5. Assuming PAT works well and complete authn, the UI updates the Accounts menu:
    image
  6. If the GitHub UI view is still stale (didn't trigger the proper events), reload the window:
    image
    image
  7. Success!
    image

@catskul
Copy link

catskul commented May 11, 2021

Thanks so much for the detailed instructions!

I think step 6 was critical. I ended up restarting vscode before I saw your instructions and that seemed to do the trick.

@jasonwilliams
Copy link
Contributor

The token is stored in a secure credential manager. It cannot be loaded through configuration; only the UI:

  1. Open a code instance with a workspace/folder that contains a GHE cloned repository. Default remote name origin works out-of-box.
  2. If you have the URI set appropriately (matches clone URI authority), the UI should prompt you that you have an account to authenticate to: image
  3. Click the Accounts icon and select the "Sign in..." option: image
  4. The UI will prompt for the PAT and display a status bar item:
    image
    image
  5. Assuming PAT works well and complete authn, the UI updates the Accounts menu:
    image
  6. If the GitHub UI view is still stale (didn't trigger the proper events), reload the window:
    image
    image
  7. Success!
    image

@RMacfarlane You could copy this straight into the wiki 😄

@AlexDias95
Copy link

It worked @kabel!!! Thanks for all the help! :D

@vortechs2000
Copy link

I grabbed the latest Insider build, and set "github-enterprise.uri": "https://git.my.ghe.uri", but I'm not able to log into my GHE instance - I only get the option to log into github.com. Is there some other setting I need to adjust?

@catskul
Copy link

catskul commented May 13, 2021

Make sure you have the nightly of the extension as well vscode-pull-request-github-insiders
Also I had to restart vscode a few times before I got it to work. Also nightly stores it's config in a separate location so if you added it to vscode, and then tried it on nightly, you might be missing the config there.

@vortechs2000
Copy link

Make sure you have the nightly of the extension as well vscode-pull-request-github-insiders

That did it - thank you @catskul! I knew I was missing something obvious.

@jasonwilliams
Copy link
Contributor

jasonwilliams commented Jun 4, 2021

Latest test seems to have errors

  • Installed VSCode Insiders (Version: 1.57.0-insider (Universal) Commit: 387e2f3)
  • Installed pull request github nightly (Version: 2021.6.1983)
  • I set my enterprise URI, filling out "github-enterprise.uri" (I included the schema)
  • Then needed to restart VSCode
  • Then i signed in following @kabel's instructions here:
    Implement GitHub Enterprise authn provider #115940 (comment)

I can see the list of PRs but clicking on the dropdown shows nothing.

Extension output is as follows:

[Info] Failed to get pull request review comments: Error: GraphQL error: Field 'path' doesn't exist on type 'PullRequestReviewThread'
GraphQL error: Field 'isOutdated' doesn't exist on type 'PullRequestReviewThread'
[Info] Error: GraphQL error: Field 'viewerViewedState' doesn't exist on type 'PullRequestChangedFile'
[Info] Failed to get pull request review comments: Error: GraphQL error: Field 'path' doesn't exist on type 'PullRequestReviewThread'
GraphQL error: Field 'isOutdated' doesn't exist on type 'PullRequestReviewThread'
[Info] Error: GraphQL error: Field 'viewerViewedState' doesn't exist on type 'PullRequestChangedFile'
[Info] Failed to get pull request review comments: Error: GraphQL error: Field 'path' doesn't exist on type 'PullRequestReviewThread'
GraphQL error: Field 'isOutdated' doesn't exist on type 'PullRequestReviewThread'
[Info] Error: GraphQL error: Field 'viewerViewedState' doesn't exist on type 'PullRequestChangedFile'

Github Authentification Output:

[Info  - 09:22:45.590] Getting user info...
[Info  - 09:22:46.204] Got account info!

Enterprise version is: v2.22.4

@kabel do you know why the above errors are happening? Is GHEP now out of sync with the extension again?

@bowendeng
Copy link

@jasonwilliams I had similar errors on our GHE instance. Based on the change log, these fields were introduced on 2020-09-23. I guess you have to upgrade the GHE to a version after that.

@kabel
Copy link
Contributor Author

kabel commented Jun 11, 2021

Opened a tracking issue at microsoft/vscode-pull-request-github#2772 for the schema related errors. Gotta love GraphQL API version fragmentation. We'll see how hard it will be to keep up with Enterprise support pattern. My enterprise upgraded to GHE 3 and it's seems to be working fine.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 21, 2021
@alexr00
Copy link
Member

alexr00 commented Sep 27, 2022

If you arrived here looking for GitHub Enterprise support in the GitHub Pull Requests and Issues extension, please see the wiki. The TL;DR is that GitHub Enterprise is now tested and supported by the project maintainers.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GitHub Enterprise support for the GitHub auth provider Its possible connect to github enterprise