Skip to content
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f14d53f
Handle deprecation of WithExtraQueryParameters APIs in MSAL.NET
Avery-Dunn Nov 3, 2025
e86d2d7
Update MicrosoftIdentityClientVersion
Avery-Dunn Nov 10, 2025
25f5111
Merge branch 'master' into avdunn/extraqp-deprecation
Avery-Dunn Nov 10, 2025
da2d18b
Update SystemFormatsAsn1Version
Avery-Dunn Nov 10, 2025
874efd4
Merge branch 'avdunn/extraqp-deprecation' of https://github.com/Azure…
Avery-Dunn Nov 10, 2025
e84c231
Add missing Unshipped.txt declaration
Avery-Dunn Nov 11, 2025
845ede5
Merge branch 'master' into avdunn/extraqp-deprecation
Avery-Dunn Nov 11, 2025
e2108bb
Handle deprecation of WithExtraQueryParameters APIs in MSAL.NET
Avery-Dunn Nov 3, 2025
37e248b
Update MicrosoftIdentityClientVersion
Avery-Dunn Nov 10, 2025
00156a4
Update SystemFormatsAsn1Version
Avery-Dunn Nov 10, 2025
a34377b
Add missing Unshipped.txt declaration
Avery-Dunn Nov 11, 2025
7cce634
Update MSAL version
Avery-Dunn Nov 13, 2025
19abae7
Revert "Update MSAL version"
Avery-Dunn Nov 13, 2025
b22f109
Merge branch 'avdunn/extraqp-deprecation' of https://github.com/Azure…
Avery-Dunn Nov 13, 2025
0b3446e
Update MSAL version
Avery-Dunn Nov 13, 2025
96462c2
Merge branch 'master' into avdunn/extraqp-deprecation
Avery-Dunn Nov 13, 2025
95d410b
Merge branch 'master' into avdunn/extraqp-deprecation
Avery-Dunn Nov 14, 2025
470ed6e
Merge branch 'master' into avdunn/extraqp-deprecation
Avery-Dunn Nov 17, 2025
bb97a87
Adjust dependencies
Avery-Dunn Nov 17, 2025
2ea6b54
Merge branch 'avdunn/extraqp-deprecation' of https://github.com/Azure…
Avery-Dunn Nov 17, 2025
8114745
Merge branch 'master' into avdunn/extraqp-deprecation
Avery-Dunn Nov 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@

<PropertyGroup Label="Common dependency versions">
<MicrosoftIdentityModelVersion Condition="'$(MicrosoftIdentityModelVersion)' == ''">8.14.0</MicrosoftIdentityModelVersion>
<MicrosoftIdentityClientVersion Condition="'$(MicrosoftIdentityClientVersion)' == ''">4.77.1</MicrosoftIdentityClientVersion>
<MicrosoftIdentityClientVersion Condition="'$(MicrosoftIdentityClientVersion)' == ''">4.79.1</MicrosoftIdentityClientVersion>
<MicrosoftIdentityAbstractionsVersion Condition="'$(MicrosoftIdentityAbstractionsVersion)' == ''">9.5.0</MicrosoftIdentityAbstractionsVersion>
<FxCopAnalyzersVersion>3.3.0</FxCopAnalyzersVersion>
<SystemTextEncodingsWebVersion>4.7.2</SystemTextEncodingsWebVersion>
Expand All @@ -95,7 +95,7 @@
<!--CVE-2024-43485-->
<SystemTextJsonVersion>8.0.5</SystemTextJsonVersion>
<!--CVE-2023-29331-->
<SystemFormatsAsn1Version>8.0.1</SystemFormatsAsn1Version>
<SystemFormatsAsn1Version>9.0.8</SystemFormatsAsn1Version>
<BannedApiAnalyzersVersion>4.14.0</BannedApiAnalyzersVersion>
<PublicApiAnalyzersVersion>4.14.0</PublicApiAnalyzersVersion>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#nullable enable
const Microsoft.Identity.Web.Constants.UserIdKey = "IDWEB_USER_ID" -> string!
readonly Microsoft.Identity.Web.TokenAcquisition._certificatesObservers -> System.Collections.Generic.IReadOnlyList<Microsoft.Identity.Web.Experimental.ICertificatesObserver!>!
static Microsoft.Identity.Web.TokenAcquisition.MergeExtraQueryParameters(Microsoft.Identity.Web.MergedOptions! mergedOptions, Microsoft.Identity.Web.TokenAcquisitionOptions? tokenAcquisitionOptions) -> System.Collections.Generic.Dictionary<string!, (string! value, bool includeInCacheKey)>?
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#nullable enable
static Microsoft.Identity.Web.TokenAcquisition.MergeExtraQueryParameters(Microsoft.Identity.Web.MergedOptions! mergedOptions, Microsoft.Identity.Web.TokenAcquisitionOptions? tokenAcquisitionOptions) -> System.Collections.Generic.Dictionary<string!, (string! value, bool includeInCacheKey)>?
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#nullable enable
static Microsoft.Identity.Web.TokenAcquisition.MergeExtraQueryParameters(Microsoft.Identity.Web.MergedOptions! mergedOptions, Microsoft.Identity.Web.TokenAcquisitionOptions? tokenAcquisitionOptions) -> System.Collections.Generic.Dictionary<string!, (string! value, bool includeInCacheKey)>?
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#nullable enable
static Microsoft.Identity.Web.TokenAcquisition.MergeExtraQueryParameters(Microsoft.Identity.Web.MergedOptions! mergedOptions, Microsoft.Identity.Web.TokenAcquisitionOptions? tokenAcquisitionOptions) -> System.Collections.Generic.Dictionary<string!, (string! value, bool includeInCacheKey)>?
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#nullable enable
static Microsoft.Identity.Web.TokenAcquisition.MergeExtraQueryParameters(Microsoft.Identity.Web.MergedOptions! mergedOptions, Microsoft.Identity.Web.TokenAcquisitionOptions? tokenAcquisitionOptions) -> System.Collections.Generic.Dictionary<string!, (string! value, bool includeInCacheKey)>?
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#nullable enable
static Microsoft.Identity.Web.TokenAcquisition.MergeExtraQueryParameters(Microsoft.Identity.Web.MergedOptions! mergedOptions, Microsoft.Identity.Web.TokenAcquisitionOptions? tokenAcquisitionOptions) -> System.Collections.Generic.Dictionary<string!, (string! value, bool includeInCacheKey)>?
42 changes: 28 additions & 14 deletions src/Microsoft.Identity.Web.TokenAcquisition/TokenAcquisition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public async Task<AcquireTokenResult> AddAccountToCacheFromAuthorizationCodeAsyn

if (mergedOptions.ExtraQueryParameters != null)
{
builder.WithExtraQueryParameters((Dictionary<string, string>)mergedOptions.ExtraQueryParameters);
builder.WithExtraQueryParameters(MergeExtraQueryParameters(mergedOptions, null));
}

if (!string.IsNullOrEmpty(authCodeRedemptionParameters.Tenant))
Expand Down Expand Up @@ -1145,8 +1145,8 @@ private void NotifyCertificateSelection(
// Special case when the OBO inbound token is composite (for instance PFT)
if (dict.ContainsKey(assertionConstant) && dict.ContainsKey(subAssertionConstant))
{
string assertion = dict[assertionConstant];
string subAssertion = dict[subAssertionConstant];
string assertion = dict[assertionConstant].value;
string subAssertion = dict[subAssertionConstant].value;

// Check assertion and sub_assertion passed from merging extra query parameters to ensure they do not contain unsupported character(s).
CheckAssertionsForInjectionAttempt(assertion, subAssertion);
Expand All @@ -1164,7 +1164,6 @@ private void NotifyCertificateSelection(
dict.Remove(assertionConstant);
dict.Remove(subAssertionConstant);
}

builder.WithExtraQueryParameters(dict);
}
if (tokenAcquisitionOptions.ExtraHeadersParameters != null)
Expand Down Expand Up @@ -1362,25 +1361,40 @@ private Task<AuthenticationResult> GetAuthenticationResultForWebAppWithAccountFr
return builder.ExecuteAsync(tokenAcquisitionOptions != null ? tokenAcquisitionOptions.CancellationToken : CancellationToken.None);
}

internal static Dictionary<string, string>? MergeExtraQueryParameters(
internal static Dictionary<string, (string value, bool includeInCacheKey)>? MergeExtraQueryParameters(
MergedOptions mergedOptions,
TokenAcquisitionOptions tokenAcquisitionOptions)
TokenAcquisitionOptions? tokenAcquisitionOptions)
{
if (tokenAcquisitionOptions.ExtraQueryParameters != null)
// Return null if both sources are empty
if (tokenAcquisitionOptions?.ExtraQueryParameters == null && mergedOptions.ExtraQueryParameters == null)
{
var mergedDict = new Dictionary<string, string>(tokenAcquisitionOptions.ExtraQueryParameters);
if (mergedOptions.ExtraQueryParameters != null)
return null;
}

var mergedDict = new Dictionary<string, (string value, bool includeInCacheKey)>(StringComparer.OrdinalIgnoreCase);

// Add from tokenAcquisitionOptions first (these take precedence)
if (tokenAcquisitionOptions?.ExtraQueryParameters != null)
{
foreach (var pair in tokenAcquisitionOptions.ExtraQueryParameters)
{
mergedDict[pair.Key] = (pair.Value, true);
}
}

// Add from mergedOptions without overriding existing keys
if (mergedOptions.ExtraQueryParameters != null)
{
foreach (var pair in mergedOptions.ExtraQueryParameters)
{
foreach (var pair in mergedOptions!.ExtraQueryParameters)
if (!mergedDict.ContainsKey(pair.Key))
{
if (!mergedDict!.ContainsKey(pair.Key))
mergedDict.Add(pair.Key, pair.Value);
mergedDict.Add(pair.Key, (pair.Value, true));
}
}
return mergedDict;
}

return (Dictionary<string, string>?)mergedOptions.ExtraQueryParameters;
return mergedDict;
}

protected static bool AcceptedTokenVersionMismatch(MsalUiRequiredException msalServiceException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,9 @@ public void MergeExtraQueryParametersTest()

// Assert
Assert.Equal(3, mergedDict!.Count);
Assert.Equal("newvalue1", mergedDict["key1"]);
Assert.Equal("value2", mergedDict["key2"]);
Assert.Equal("value3", mergedDict["key3"]);
Assert.Equal("newvalue1", mergedDict["key1"].value);
Assert.Equal("value2", mergedDict["key2"].value);
Assert.Equal("value3", mergedDict["key3"].value);
}

[Fact]
Expand All @@ -411,8 +411,8 @@ public void MergeExtraQueryParameters_TokenAcquisitionOptionsNull_Test()
var mergedDict = TokenAcquisition.MergeExtraQueryParameters(mergedOptions, tokenAcquisitionOptions);

// Assert
Assert.Equal("value1", mergedDict!["key1"]);
Assert.Equal("value2", mergedDict["key2"]);
Assert.Equal("value1", mergedDict!["key1"].value);
Assert.Equal("value2", mergedDict["key2"].value);
}

[Fact]
Expand Down
Loading