Skip to content

Commit

Permalink
Merge pull request #171 from mjcheetham/gh-oauthonly
Browse files Browse the repository at this point in the history
Remove username/password authentication for GitHub.com
  • Loading branch information
mjcheetham committed Sep 21, 2020
2 parents c883429 + 4a5f54f commit 368d65a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/shared/GitHub.Tests/GitHubHostProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public async Task GitHubHostProvider_GetSupportedAuthenticationModes_Override_Re
public async Task GitHubHostProvider_GetSupportedAuthenticationModes_OverrideInvalid_ReturnsDetectedValue()
{
var targetUri = new Uri("https://github.com");
var expectedModes = GitHubConstants.DotDomAuthenticationModes;
var expectedModes = GitHubConstants.DotComAuthenticationModes;

var context = new TestCommandContext
{
Expand Down Expand Up @@ -205,7 +205,7 @@ public async Task GitHubHostProvider_GetSupportedAuthenticationModes_OverrideInv
public async Task GitHubHostProvider_GetSupportedAuthenticationModes_OverrideNone_ReturnsDetectedValue()
{
var targetUri = new Uri("https://github.com");
var expectedModes = GitHubConstants.DotDomAuthenticationModes;
var expectedModes = GitHubConstants.DotComAuthenticationModes;

var context = new TestCommandContext
{
Expand Down Expand Up @@ -235,7 +235,7 @@ public async Task GitHubHostProvider_GetSupportedAuthenticationModes_OverrideNon
public async Task GitHubHostProvider_GetSupportedAuthenticationModes_GitHubDotCom_ReturnsDotComModes()
{
var targetUri = new Uri("https://github.com");
var expectedModes = GitHubConstants.DotDomAuthenticationModes;
var expectedModes = GitHubConstants.DotComAuthenticationModes;

var provider = new GitHubHostProvider(new TestCommandContext());

Expand Down
3 changes: 1 addition & 2 deletions src/shared/GitHub/GitHubConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public static class GitHubConstants
/// <summary>
/// Supported authentication modes for GitHub.com.
/// </summary>
// TODO: remove Basic once the GCM OAuth app is whitelisted and does not require installation in every organization
public const AuthenticationModes DotDomAuthenticationModes = AuthenticationModes.Basic | AuthenticationModes.OAuth;
public const AuthenticationModes DotComAuthenticationModes = AuthenticationModes.OAuth;

public static class TokenScopes
{
Expand Down
4 changes: 2 additions & 2 deletions src/shared/GitHub/GitHubHostProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ internal async Task<AuthenticationModes> GetSupportedAuthenticationModesAsync(Ur
// GitHub.com should use OAuth authentication only
if (IsGitHubDotCom(targetUri))
{
Context.Trace.WriteLine($"{targetUri} is github.com - authentication schemes: '{GitHubConstants.DotDomAuthenticationModes}'");
return GitHubConstants.DotDomAuthenticationModes;
Context.Trace.WriteLine($"{targetUri} is github.com - authentication schemes: '{GitHubConstants.DotComAuthenticationModes}'");
return GitHubConstants.DotComAuthenticationModes;
}

// For GitHub Enterprise we must do some detection of supported modes
Expand Down

0 comments on commit 368d65a

Please sign in to comment.