Skip to content

Commit 5dc3657

Browse files
authored
Merge pull request #343 from mjcheetham/ghae
Add support for OAuth with GitHub AE
2 parents 39efe03 + 4fb0f1c commit 5dc3657

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/shared/GitHub/GitHubConstants.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ public static class GitHubConstants
3232
// TODO: update this with a real version number once the GCM OAuth application has been deployed to GHE
3333
public static readonly Version MinimumEnterpriseOAuthVersion = new Version("99.99.99");
3434

35+
/// <summary>
36+
/// The version string returned from the meta API endpoint for GitHub AE instances.
37+
/// </summary>
38+
public const string GitHubAeVersionString = "GitHub AE";
39+
3540
/// <summary>
3641
/// Supported authentication modes for GitHub.com.
3742
/// </summary>

src/shared/GitHub/GitHubHostProvider.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,15 @@ internal async Task<AuthenticationModes> GetSupportedAuthenticationModesAsync(Ur
263263
{
264264
modes |= AuthenticationModes.Basic;
265265
}
266-
if (Version.TryParse(metaInfo.InstalledVersion, out var version) && version >= GitHubConstants.MinimumEnterpriseOAuthVersion)
266+
267+
if (StringComparer.OrdinalIgnoreCase.Equals(metaInfo.InstalledVersion, GitHubConstants.GitHubAeVersionString))
268+
{
269+
// Assume all GHAE instances have the GCM OAuth application deployed
270+
modes |= AuthenticationModes.OAuth;
271+
}
272+
else if (Version.TryParse(metaInfo.InstalledVersion, out var version) && version >= GitHubConstants.MinimumEnterpriseOAuthVersion)
267273
{
274+
// Only GHES versions beyond the minimum version have the GCM OAuth application deployed
268275
modes |= AuthenticationModes.OAuth;
269276
}
270277

0 commit comments

Comments
 (0)