-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add explicit GitHub device code authentication option #478
Conversation
Rename the OAuth GitHub authentication mode to Browser to better match what interaction will happen when selecting this mode. Also prepare for the introduction of an explicit device code OAuth flow mode.
Consolidate all the UI helper options for the GitHub `prompt` view in to an `Options` class (rather than bloat the execution handler with more arguments). Also fix a bug whereby the GitHub host provider would attempt to invoke the UI helper with an `--all` option when all authentication modes are available, but no such option is available! This option was only available on the old WPF UI helper, and was never carried forward to the Avalonia UI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Implement an explicit OAuth device code authentication mode for the GitHub host provider. Previously the 'web browser' option combined both the interactive/browser based flow (when a UI was present), and a TTY-based device code flow. This change allows users to select the device code flow even when they have a desktop/UI session present. This is useful to workaround possible problems with the browser loopback/redirect mechanism.
Add the device code option to the Avalonia and WPF helper UI applications for GitHub. This includes adding a new explicit "device code" button to the primary authentication prompt view, and a new device code display prompt.
Update documentation to include the new `browser` and `device` authentication modes for GitHub. The old `oauth` value expands to both `browser, device` for compatibility.
f3ea92b
to
0fb32aa
Compare
@@ -121,7 +121,7 @@ public async Task GitHubHostProvider_GetSupportedAuthenticationModes(string uriS | |||
[Theory] | |||
[InlineData("https://example.com", null, "0.1", false, AuthenticationModes.Pat)] | |||
[InlineData("https://example.com", null, "0.1", true, AuthenticationModes.Basic | AuthenticationModes.Pat)] | |||
[InlineData("https://example.com", null, "100.0", false, AuthenticationModes.Browser | AuthenticationModes.Pat)] | |||
[InlineData("https://example.com", null, "100.0", false, AuthenticationModes.OAuth | AuthenticationModes.Pat)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like an errant revert of a previous change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see. OAuth
is the combination of two. Should we have lines for Browser
, Device
, and OAuth
on this test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One change is to rename the current (browser) behaviour to Browser
, to better reflect what that mode does.
The next change is to add a new Device
mode, and reuse the newly "freed" option of OAuth
to represent the combination of Browser
and Device
.
This test checks that a GHES instance with version number 100.0
should support both Browser
and Device
(i.e, OAuth
).
@@ -196,7 +196,7 @@ public async Task GitHubHostProvider_GenerateCredentialAsync_Browser_ReturnsCred | |||
ghAuthMock.Setup(x => x.GetAuthenticationAsync(expectedTargetUri, null, It.IsAny<AuthenticationModes>())) | |||
.ReturnsAsync(new AuthenticationPromptResult(AuthenticationModes.Browser)); | |||
|
|||
ghAuthMock.Setup(x => x.GetOAuthTokenAsync(expectedTargetUri, It.IsAny<IEnumerable<string>>())) | |||
ghAuthMock.Setup(x => x.GetOAuthTokenViaBrowserAsync(expectedTargetUri, It.IsAny<IEnumerable<string>>())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the message for this commit, you say
This is useful to workaround possible
problems with the browser loopback/redirect mechanism.
Do you have an example? I'm guessing WSL has something to do with this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is indeed one, but the one that jumps to mind is problems we've had with:
- AVs blocking loopback listening
- enterprises that have registered
localhost
as a valid name with their DNS nameservers (yes, it has happened!!) - There are some random 'failures' that other teams have not been able to diagnose
See these issues the GitHub VS Extension has had problems with the loopback mechanism before:
Sign in with browser
not working - things to try github/VisualStudio#2568- Redirect to 127.0.0.1 instead of localhost github/VisualStudio#2554
- Unable to connect to GitHub from VS2019 github/VisualStudio#2550
- unable to connect to GitHub using visual studio 2019 github/VisualStudio#2527
- Github "Sign in with browser" open localhost in browser, login fails github/VisualStudio#2521
Implement an explicit OAuth device code authentication mode for the GitHub host provider. Previously the 'web browser' option combined both the interactive/browser based flow (when a UI was present), and a TTY-based device code flow.
This change allows users to select the device code flow even when they have a desktop/UI session present. This is useful to workaround possible problems with the browser loopback/redirect mechanism.
As well as introducing new
"browser"
and"device"
values, we keep the existing"oauth"
value for theGCM_GITHUB_AUTHMODES
environment variable andcredential.gitHubAuthModes
Git config, and let it expand to bothbrowser
anddevice
to allow users who may have set the older value before.(macOS)
(Ubuntu)
(Windows)