-
Notifications
You must be signed in to change notification settings - Fork 208
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
There should be an option to have TokenAcquisition be a singleton #1
Comments
@jmprieur - I had a look at this scenario in more detail. AquireTokenSilent does:
Steps 1 and 3 are guaranteed to be consistent because we use locks. The entire AcquireTokenSilent is not locked. So the whole thing might work from a consistency perspective, even However, please note that using the same cache has performance implications: a. Operations 1 and 3 above are probably executed in a critical section . This can result in high contention, especially under heavy load. This isn't a bug in MSAL per se, but we'll have to retest token cache web implementations. Some improvements can be made such as using separate read and write locks. All in all, this work item requires a lot of testing. |
Thanks @bgavrilMS |
Then concern a. above is also not relevant. The locks are at the Token Cache level, so if you have a token cache for each account, contention is not an issue. |
Thanks for confirming @bgavrilMS |
This is illustrated by the following sample: |
This issue is for a: (mark with an
x
)Why?
Today, TokenAcquisition is a scoped by request. See https://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2/blob/ab84785cf757c2d3244090a90d563528ee4be616/Microsoft.Identity.Web/ServiceCollectionExtensions.cs#L38
There are scenarios, like using the Graph SDK, which require it to be a singleton. This is a request from the Graph SDK team (Darrel Miller).
Given Bogdan's analysis (below), this is safe to have a singleton.
What: proposed developer experience?
Provide an option in the configuration, which sets the TokenAcquisition service to be a singleton.
Proposed design:
Issue copied from Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2#287, that will need to be updated
The text was updated successfully, but these errors were encountered: