Skip to content

Commit 4fb0f1c

Browse files
committed
github: add support for OAuth with GHAE
Add support for detecting GitHub AE (GHAE) and enabling the OAuth authentication mode with the GitHub provider. https://docs.github.com/en/github-ae@latest/admin/overview/about-github-ae
1 parent e8e87b9 commit 4fb0f1c

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)