From 8cb1b9ca7e34ced65bf357275a52c59f243abfc4 Mon Sep 17 00:00:00 2001 From: Hanjiang Yu Date: Sat, 27 Jan 2024 09:22:23 +0800 Subject: [PATCH] Consider domain matched when no domain hint is provided in GitHub account filtering --- src/shared/GitHub.Tests/GitHubAuthChallengeTests.cs | 6 +++--- src/shared/GitHub/GitHubAuthChallenge.cs | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/shared/GitHub.Tests/GitHubAuthChallengeTests.cs b/src/shared/GitHub.Tests/GitHubAuthChallengeTests.cs index c52a67b8b..3beec8998 100644 --- a/src/shared/GitHub.Tests/GitHubAuthChallengeTests.cs +++ b/src/shared/GitHub.Tests/GitHubAuthChallengeTests.cs @@ -86,9 +86,9 @@ public void GitHubAuthChallenge_FromHeaders_EmptyHeaders_ReturnsEmpty() [InlineData("", false)] [InlineData(" ", false)] [InlineData("alice", true)] - [InlineData("alice_contoso", false)] - [InlineData("alice_CONTOSO", false)] - [InlineData("alice_contoso_alt", false)] + [InlineData("alice_contoso", true)] + [InlineData("alice_CONTOSO", true)] + [InlineData("alice_contoso_alt", true)] [InlineData("pj_nitin", true)] [InlineData("up_the_irons", true)] public void GitHubAuthChallenge_IsDomainMember_NoHint(string userName, bool expected) diff --git a/src/shared/GitHub/GitHubAuthChallenge.cs b/src/shared/GitHub/GitHubAuthChallenge.cs index de3afbdbd..485db814c 100644 --- a/src/shared/GitHub/GitHubAuthChallenge.cs +++ b/src/shared/GitHub/GitHubAuthChallenge.cs @@ -73,10 +73,15 @@ public bool IsDomainMember(string userName) return false; } + if (string.IsNullOrWhiteSpace(Domain)) + { + return true; + } + int delim = userName.LastIndexOf('_'); if (delim < 0) { - return string.IsNullOrWhiteSpace(Domain); + return false; } // Check for users that contain underscores but are not EMU logins