This issue is for a: (mark with an x)
- [ ] bug report -> please search issues before submitting
- [ x] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)
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.
{
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
// missing lines here ...
"SingletonTokenAcquisition" : false
},
// missing lines here ...
}
Proposed design:
- Add a boolean SingletonTokenAcquisition in the MicrosoftIdentityOptions, by default this would be false.
- Add a bool parameter in AddTokenAcquisition to specify if the token acquisition service should be a singleton or not (and use .AddScoped if it's not a singleton, and AddSignleton if this is a singleton)
- Pass this parameter in methods calling AddTokenAcquisition, the value coming from the MicrosoftIdentityOptions.SingletonTokenAcquisition. Probably:
- AddProtectedWebApiCallsWebApis
- AddWebAppCallsWebApis,
Issue copied from Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2#287, that will need to be updated
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.
{ "AzureAd": { "Instance": "https://login.microsoftonline.com/", // missing lines here ... "SingletonTokenAcquisition" : false }, // missing lines here ... }Proposed design:
Issue copied from Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2#287, that will need to be updated