-
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?
Conversation
… deprecate existing WithExtraQueryParameters APIs
src/client/Microsoft.Identity.Client/ApiConfig/BaseAbstractAcquireTokenParameterBuilder.cs
Show resolved
Hide resolved
src/client/Microsoft.Identity.Client/ApiConfig/BaseAbstractAcquireTokenParameterBuilder.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but the tuple in public API is not going to work
…uireTokenParameterBuilder.cs Co-authored-by: Bogdan Gavril <[email protected]>
/// 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming: (string ParameterValue, bool IncludeInCacheKey)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, minor option
This PR is for KR 3310905 and issue #5361.
In short, there is a problem in our existing
WithExtraQueryParameters
behavior: the extra query parameters could affect tokens but were not used as part of the cache keys, so if theWithExtraQueryParameters
values changed between requests we could return cached tokens that were not valid for the new request. However, simply adding the extra query parameters to the cache key would not work: it would break existing cache lookup behavior, and not all parameters should be cached.This PR tries to solve that problem with the following changes:
WithExtraQueryParameters
that takes in aIDictionary<string, (string value, bool includeInCacheKey)>
CacheKeyComponents
field, which already does the task of adding extra parameters to the cache keyBaseAbstractAcquireTokenParameterBuilder
,AbstractApplicationBuilder
WithExtraQueryParameters
APIs, and have them call the new API to set theExtraQueryParameters
fieldsAbstractAcquireTokenParameterBuilder
,BaseAbstractAcquireTokenParameterBuilder
,AbstractApplicationBuilder
CoreHelpers
to covert the old Dictionary style to the new oneThis PR also adds some new tests to cover the new behavior, and makes some small changes to existing tests:
ExtraQueryParametersTests
: A new test class with tests covering the new cache key behavior, as well as demonstrating the behavior of the deprecatedWithExtraQueryParameters
APIsCacheKeyExtensionTests
: A new test to show the newWithExtraQueryParameters
API does not conflict with the existingWithAdditionalCacheKeyComponents
API from the extensibility package