-
Notifications
You must be signed in to change notification settings - Fork 706
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix release build * Fix release version
- Loading branch information
1 parent
756f2d0
commit 1083572
Showing
5 changed files
with
49 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<CredentialProviderVersion>1.0.2-preview</CredentialProviderVersion> | ||
<CredentialProviderVersion>1.0.2</CredentialProviderVersion> | ||
<VersionSuffix>-preview</VersionSuffix> | ||
<TargetFrameworks>netcoreapp3.1;net461;net6.0</TargetFrameworks> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
CredentialProvider.Microsoft/CredentialProviders/Vsts/MSAL/MsalUtil.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Microsoft.Identity.Client; | ||
|
||
namespace NuGetCredentialProvider.CredentialProviders.Vsts | ||
{ | ||
public class MsalUtil | ||
{ | ||
public static List<(IAccount, string)> GetApplicableAccounts(IEnumerable<IAccount> accounts, Guid authorityTenantId, string loginHint) | ||
{ | ||
var applicableAccounts = new List<(IAccount, string)>(); | ||
|
||
foreach (var account in accounts) | ||
{ | ||
string canonicalName = $"{account.HomeAccountId?.TenantId}\\{account.Username}"; | ||
|
||
// If a login hint is provided and matches, try that first | ||
if (!string.IsNullOrEmpty(loginHint) && account.Username == loginHint) | ||
{ | ||
applicableAccounts.Insert(0, (account, canonicalName)); | ||
continue; | ||
} | ||
|
||
if (Guid.TryParse(account.HomeAccountId?.TenantId, out Guid accountTenantId)) | ||
{ | ||
if (accountTenantId == authorityTenantId) | ||
{ | ||
applicableAccounts.Add((account, canonicalName)); | ||
} | ||
else if (accountTenantId == AuthUtil.MsaAccountTenant && (authorityTenantId == AuthUtil.FirstPartyTenant || authorityTenantId == Guid.Empty)) | ||
{ | ||
applicableAccounts.Add((account, canonicalName)); | ||
} | ||
} | ||
} | ||
|
||
return applicableAccounts; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters