Skip to content

Commit 57ea819

Browse files
authored
Resolve dependency conflict with Az module. (#1894)
* Resolve dependency conflict with Az module. * Default to Process ContextScope when on WSL
1 parent 9cd80d9 commit 57ea819

File tree

7 files changed

+43
-32
lines changed

7 files changed

+43
-32
lines changed

src/Authentication/Authentication.Core/Microsoft.Graph.Authentication.Core.csproj

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@
44
<TargetFrameworks>netstandard2.0;net6.0;net472</TargetFrameworks>
55
<RootNamespace>Microsoft.Graph.PowerShell.Authentication.Core</RootNamespace>
66
<VersionPrefix>2.0.0</VersionPrefix>
7-
<VersionSuffix>preview5</VersionSuffix>
7+
<VersionSuffix>preview7</VersionSuffix>
88
</PropertyGroup>
99
<PropertyGroup>
1010
<EnableNETAnalyzers>true</EnableNETAnalyzers>
1111
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
1212
</PropertyGroup>
1313
<ItemGroup>
14-
<PackageReference Include="Azure.Core" Version="1.28.0" />
15-
<PackageReference Include="Azure.Identity" Version="1.8.2" />
16-
<PackageReference Include="Microsoft.Graph.Core" Version="2.0.15" />
17-
<PackageReference Include="Microsoft.Identity.Client" Version="4.50.0" />
18-
<PackageReference Include="Microsoft.Identity.Client.Extensions.Msal" Version="2.26.0" />
14+
<PackageReference Include="Azure.Core" Version="1.25.0" />
15+
<PackageReference Include="Azure.Identity" Version="1.6.1" />
16+
<PackageReference Include="Microsoft.Graph.Core" Version="2.0.11" />
17+
<PackageReference Include="Microsoft.Identity.Client" Version="4.51.0" />
18+
<PackageReference Include="Microsoft.Identity.Client.Extensions.Msal" Version="2.27.0" />
1919
<!--Always ensure this version matches the versions of System.Security.Cryptography.* dependencies of Microsoft.Identity.Client when targeting PowerShell 6 and below.-->
20-
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="7.0.1" />
21-
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
22-
<PackageReference Include="System.Text.Json" Version="7.0.2" />
20+
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="6.0.0" />
21+
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
22+
<PackageReference Include="System.Text.Json" Version="6.0.5" />
2323
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
2424
</ItemGroup>
2525
<Target Name="CopyFiles" AfterTargets="Build">

src/Authentication/Authentication.Core/Utilities/JwtHelpers.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
using Microsoft.Graph.PowerShell.Authentication.Core.Models;
66
using Microsoft.Graph.PowerShell.Authentication.Models;
77
using Microsoft.Identity.Client;
8-
using Newtonsoft.Json;
98
using System;
109
using System.Globalization;
1110
using System.Text;
11+
using System.Text.Json;
1212

1313
namespace Microsoft.Graph.PowerShell.Authentication.Core.Utilities
1414
{
@@ -64,7 +64,7 @@ internal static T DecodeToObject<T>(string jwtString)
6464
var decodedJWT = DecodeJWT(jwtString);
6565
if (string.IsNullOrWhiteSpace(decodedJWT?.Payload))
6666
return default;
67-
return JsonConvert.DeserializeObject<T>(decodedJWT.Payload);
67+
return JsonSerializer.Deserialize<T>(decodedJWT.Payload);
6868
}
6969
catch (Exception ex)
7070
{

src/Authentication/Authentication/Cmdlets/ConnectMgGraph.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Microsoft.Graph.PowerShell.Authentication.Core.Extensions;
77
using Microsoft.Graph.PowerShell.Authentication.Core.TokenCache;
88
using Microsoft.Graph.PowerShell.Authentication.Core.Utilities;
9+
using Microsoft.Graph.PowerShell.Authentication.Extensions;
910
using Microsoft.Graph.PowerShell.Authentication.Helpers;
1011
using Microsoft.Graph.PowerShell.Authentication.Interfaces;
1112
using Microsoft.Graph.PowerShell.Authentication.Models;
@@ -15,6 +16,7 @@
1516
using System.Collections.Generic;
1617
using System.Linq;
1718
using System.Management.Automation;
19+
using System.Runtime.InteropServices;
1820
using System.Security;
1921
using System.Security.Cryptography.X509Certificates;
2022
using System.Text;
@@ -177,8 +179,16 @@ private async Task ProcessRecordAsync()
177179
authContext.AuthType = AuthenticationType.Delegated;
178180
string[] processedScopes = ProcessScopes(Scopes);
179181
authContext.Scopes = !processedScopes.Any() ? new[] { "User.Read" } : processedScopes;
180-
// Default to CurrentUser but allow the customer to change this via `-ContextScope`.
181-
authContext.ContextScope = this.IsParameterBound(nameof(ContextScope)) ? ContextScope : ContextScope.CurrentUser;
182+
if (RuntimeInformation.OSDescription.ContainsValue("WSL", StringComparison.InvariantCulture))
183+
{
184+
// Use process scope when on WSL. WSL does not have secret service that's used to cache tokens on Linux, see https://github.com/microsoft/WSL/issues/4254.
185+
authContext.ContextScope = ContextScope.Process;
186+
}
187+
else
188+
{
189+
// Default to CurrentUser but allow the customer to change this via `-ContextScope`.
190+
authContext.ContextScope = this.IsParameterBound(nameof(ContextScope)) ? ContextScope : ContextScope.CurrentUser;
191+
}
182192
authContext.TokenCredentialType = UseDeviceCode ? TokenCredentialType.DeviceCode : TokenCredentialType.InteractiveBrowser;
183193
}
184194
break;

src/Authentication/Authentication/Microsoft.Graph.Authentication.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<NuspecFile>Microsoft.Graph.Authentication.nuspec</NuspecFile>
1212
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
1313
<VersionPrefix>2.0.0</VersionPrefix>
14-
<VersionSuffix>preview5</VersionSuffix>
14+
<VersionSuffix>preview7</VersionSuffix>
1515
</PropertyGroup>
1616
<PropertyGroup>
1717
<EnableNETAnalyzers>true</EnableNETAnalyzers>

src/Authentication/Authentication/Microsoft.Graph.Authentication.nuspec

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22
<package>
33
<metadata>
4-
<version>2.0.0-preview5</version>
4+
<version>2.0.0-preview7</version>
55
<id>Microsoft.Graph.Authentication</id>
66
<description>Microsoft Graph PowerShell authentication module</description>
77
<authors>Microsoft</authors>
@@ -25,6 +25,21 @@
2525
<file src="artifacts\StartupScripts\" target="StartupScripts" />
2626
<file src="artifacts\custom\" target="custom" />
2727
<!-- Copy framework dependent assemblies to respective framework directory. -->
28+
<!-- Shared -->
29+
<file src="artifacts\Dependencies\Azure.Core.dll" target="Dependencies" />
30+
<file src="artifacts\Dependencies\Azure.Identity.dll" target="Dependencies" />
31+
<file src="artifacts\Dependencies\Microsoft.Bcl.AsyncInterfaces.dll" target="Dependencies" />
32+
<file src="artifacts\Dependencies\Microsoft.Identity.Client.Extensions.Msal.dll" target="Dependencies" />
33+
<file src="artifacts\Dependencies\Microsoft.IdentityModel.Abstractions.dll" target="Dependencies" />
34+
<file src="artifacts\Dependencies\Newtonsoft.Json.dll" target="Dependencies" />
35+
<file src="artifacts\Dependencies\System.Buffers.dll" target="Dependencies" />
36+
<file src="artifacts\Dependencies\System.Diagnostics.DiagnosticSource.dll" target="Dependencies" />
37+
<file src="artifacts\Dependencies\System.Memory.dll" target="Dependencies" />
38+
<file src="artifacts\Dependencies\System.Numerics.Vectors.dll" target="Dependencies" />
39+
<file src="artifacts\Dependencies\System.Runtime.CompilerServices.Unsafe.dll" target="Dependencies" />
40+
<file src="artifacts\Dependencies\System.Text.Encodings.Web.dll" target="Dependencies" />
41+
<file src="artifacts\Dependencies\System.Text.Json.dll" target="Dependencies" />
42+
<file src="artifacts\Dependencies\System.Threading.Tasks.Extensions.dll" target="Dependencies" />
2843
<!-- Core-->
2944
<file src="artifacts\Dependencies\Core\Azure.Core.dll" target="Dependencies\Core" />
3045
<file src="artifacts\Dependencies\Core\Azure.Identity.dll" target="Dependencies\Core" />
@@ -35,23 +50,9 @@
3550
<file src="artifacts\Dependencies\Core\Newtonsoft.Json.dll" target="Dependencies\Core" />
3651
<file src="artifacts\Dependencies\Core\System.Security.Cryptography.ProtectedData.dll" target="Dependencies\Core" />
3752
<!-- Desktop -->
38-
<file src="artifacts\Dependencies\Desktop\Azure.Core.dll" target="Dependencies\Desktop" />
39-
<file src="artifacts\Dependencies\Desktop\Azure.Identity.dll" target="Dependencies\Desktop" />
40-
<file src="artifacts\Dependencies\Desktop\Microsoft.Bcl.AsyncInterfaces.dll" target="Dependencies\Desktop" />
4153
<file src="artifacts\Dependencies\Desktop\Microsoft.Graph.Core.dll" target="Dependencies\Desktop" />
4254
<file src="artifacts\Dependencies\Desktop\Microsoft.Identity.Client.dll" target="Dependencies\Desktop" />
43-
<file src="artifacts\Dependencies\Desktop\Microsoft.Identity.Client.Extensions.Msal.dll" target="Dependencies\Desktop" />
44-
<file src="artifacts\Dependencies\Desktop\Microsoft.IdentityModel.Abstractions.dll" target="Dependencies\Desktop" />
45-
<file src="artifacts\Dependencies\Desktop\Newtonsoft.Json.dll" target="Dependencies\Desktop" />
46-
<file src="artifacts\Dependencies\Desktop\System.Buffers.dll" target="Dependencies\Desktop" />
47-
<file src="artifacts\Dependencies\Desktop\System.Diagnostics.DiagnosticSource.dll" target="Dependencies\Desktop" />
48-
<file src="artifacts\Dependencies\Desktop\System.Memory.dll" target="Dependencies\Desktop" />
4955
<file src="artifacts\Dependencies\Desktop\System.Net.Http.WinHttpHandler.dll" target="Dependencies\Desktop" />
50-
<file src="artifacts\Dependencies\Desktop\System.Numerics.Vectors.dll" target="Dependencies\Desktop" />
51-
<file src="artifacts\Dependencies\Desktop\System.Runtime.CompilerServices.Unsafe.dll" target="Dependencies\Desktop" />
5256
<file src="artifacts\Dependencies\Desktop\System.Security.Cryptography.ProtectedData.dll" target="Dependencies\Desktop" />
53-
<file src="artifacts\Dependencies\Desktop\System.Text.Encodings.Web.dll" target="Dependencies\Desktop" />
54-
<file src="artifacts\Dependencies\Desktop\System.Text.Json.dll" target="Dependencies\Desktop" />
55-
<file src="artifacts\Dependencies\Desktop\System.Threading.Tasks.Extensions.dll" target="Dependencies\Desktop" />
5657
</files>
5758
</package>

src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: Microsoft
55
#
6-
# Generated on: 3/10/2023
6+
# Generated on: 3/22/2023
77
#
88

99
@{
@@ -114,7 +114,7 @@ PrivateData = @{
114114
ReleaseNotes = 'See https://aka.ms/GraphPowerShell-Release.'
115115

116116
# Prerelease string of this module
117-
Prerelease = 'preview5'
117+
Prerelease = 'preview7'
118118

119119
# Flag to indicate whether the module requires explicit user acceptance for install/update/save
120120
# RequireLicenseAcceptance = $false

src/Authentication/Authentication/Microsoft.Graph.Authentication.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if (Test-Path -Path "$PSScriptRoot\StartupScripts" -ErrorAction Ignore)
1717
Export-ModuleMember -Cmdlet (Get-ModuleCmdlet -ModulePath $ModulePath) -Alias (Get-ModuleCmdlet -ModulePath $ModulePath -AsAlias)
1818

1919
$DependencyPath = (Join-Path $PSScriptRoot -ChildPath "Dependencies")
20-
if (Test-Path $DependencyPath -ErrorAction Ignore)
20+
if ((Test-Path $DependencyPath -ErrorAction Ignore) -and ($PSEdition -eq "Desktop"))
2121
{
2222
try
2323
{

0 commit comments

Comments
 (0)