-
Notifications
You must be signed in to change notification settings - Fork 378
Adjust WithExtraQueryParameters APIs and cache key behavior #5536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 5 commits
215f703
3f853e0
6a8aa9e
2921a79
d8e728e
d8d60ef
8ab80c9
5eb3f7d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,10 +89,46 @@ public T WithCorrelationId(Guid correlationId) | |
| /// as a string of segments of the form <c>key=value</c> separated by an ampersand character. | ||
| /// The parameter can be null.</param> | ||
| /// <returns>The builder to chain the .With methods.</returns> | ||
| [Obsolete("This method is deprecated. Please use the WithExtraQueryParameters(IDictionary<string, (string value, bool includeInCacheKey)>) method instead, which provides control over which parameters are included in the cache key.", false)] | ||
| public T WithExtraQueryParameters(Dictionary<string, string> extraQueryParameters) | ||
| { | ||
| CommonParameters.ExtraQueryParameters = extraQueryParameters ?? | ||
| new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); | ||
| return WithExtraQueryParameters(CoreHelpers.ConvertToTupleParameters(extraQueryParameters)); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Sets Extra Query Parameters for the query string in the HTTP authentication request with control over which parameters are included in the cache key | ||
| /// </summary> | ||
| /// <param name="extraQueryParameters">This parameter will be appended as is to the query string in the HTTP authentication request to the authority. | ||
| /// For each parameter, you can specify whether it should be included in the cache key. | ||
|
||
| /// The parameter can be null.</param> | ||
| /// <returns>The builder to chain .With methods.</returns> | ||
| public T WithExtraQueryParameters(IDictionary<string, (string value, bool includeInCacheKey)> extraQueryParameters) | ||
bgavrilMS marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| if (extraQueryParameters == null) | ||
| { | ||
| CommonParameters.ExtraQueryParameters = null; | ||
| return this as T; | ||
| } | ||
|
|
||
| // Add each parameter to ExtraQueryParameters and, if requested, to CacheKeyComponents | ||
| foreach (var kvp in extraQueryParameters) | ||
| { | ||
| CommonParameters.ExtraQueryParameters = CommonParameters.ExtraQueryParameters ?? new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, setting a value to itself seems like an odd way to check if something is null and then initializing it. It can be misleading potentially. I would simply add a normal if check. |
||
|
|
||
| CommonParameters.ExtraQueryParameters[kvp.Key] = kvp.Value.value; | ||
|
|
||
| if (kvp.Value.includeInCacheKey) | ||
| { | ||
| CommonParameters.CacheKeyComponents = CommonParameters.CacheKeyComponents ?? new SortedList<string, Func<CancellationToken, Task<string>>>(); | ||
|
|
||
| // Capture the value in a local to avoid closure issues | ||
| string valueToCache = kvp.Value.value; | ||
|
|
||
| // Add to cache key components - uses a func that returns the value as a task | ||
| CommonParameters.CacheKeyComponents[kvp.Key] = (CancellationToken _) => Task.FromResult(valueToCache); | ||
| } | ||
| } | ||
|
|
||
| return this as T; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Microsoft.Identity.Client.AbstractApplicationBuilder<T>.WithExtraQueryParameters(System.Collections.Generic.IDictionary<string, (string value, bool includeInCacheKey)> extraQueryParameters) -> T | ||
| Microsoft.Identity.Client.BaseAbstractAcquireTokenParameterBuilder<T>.WithExtraQueryParameters(System.Collections.Generic.IDictionary<string, (string value, bool includeInCacheKey)> extraQueryParameters) -> T |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Microsoft.Identity.Client.AbstractApplicationBuilder<T>.WithExtraQueryParameters(System.Collections.Generic.IDictionary<string, (string value, bool includeInCacheKey)> extraQueryParameters) -> T | ||
| Microsoft.Identity.Client.BaseAbstractAcquireTokenParameterBuilder<T>.WithExtraQueryParameters(System.Collections.Generic.IDictionary<string, (string value, bool includeInCacheKey)> extraQueryParameters) -> T |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Microsoft.Identity.Client.AbstractApplicationBuilder<T>.WithExtraQueryParameters(System.Collections.Generic.IDictionary<string, (string value, bool includeInCacheKey)> extraQueryParameters) -> T | ||
| Microsoft.Identity.Client.BaseAbstractAcquireTokenParameterBuilder<T>.WithExtraQueryParameters(System.Collections.Generic.IDictionary<string, (string value, bool includeInCacheKey)> extraQueryParameters) -> T |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Microsoft.Identity.Client.AbstractApplicationBuilder<T>.WithExtraQueryParameters(System.Collections.Generic.IDictionary<string, (string value, bool includeInCacheKey)> extraQueryParameters) -> T | ||
| Microsoft.Identity.Client.BaseAbstractAcquireTokenParameterBuilder<T>.WithExtraQueryParameters(System.Collections.Generic.IDictionary<string, (string value, bool includeInCacheKey)> extraQueryParameters) -> T |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Microsoft.Identity.Client.AbstractApplicationBuilder<T>.WithExtraQueryParameters(System.Collections.Generic.IDictionary<string, (string value, bool includeInCacheKey)> extraQueryParameters) -> T | ||
| Microsoft.Identity.Client.BaseAbstractAcquireTokenParameterBuilder<T>.WithExtraQueryParameters(System.Collections.Generic.IDictionary<string, (string value, bool includeInCacheKey)> extraQueryParameters) -> T |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Microsoft.Identity.Client.AbstractApplicationBuilder<T>.WithExtraQueryParameters(System.Collections.Generic.IDictionary<string, (string value, bool includeInCacheKey)> extraQueryParameters) -> T | ||
| Microsoft.Identity.Client.BaseAbstractAcquireTokenParameterBuilder<T>.WithExtraQueryParameters(System.Collections.Generic.IDictionary<string, (string value, bool includeInCacheKey)> extraQueryParameters) -> T |
Uh oh!
There was an error while loading. Please reload this page.