AzureAD / microsoft-identity-web

Helps creating protected web apps and web APIs with Microsoft identity platform and Azure AD B2C
MIT License
683 stars 217 forks source link

[Feature Request] Add overloads to DefaultCertificateLoader and DefaultCredentialLoader that accept a cancellation token #3128

Open pmaytak opened 2 weeks ago

pmaytak commented 2 weeks ago

Is your feature request related to a problem? Please describe. It's a best practice to have async methods accept and honor a cancellation token. DefaultCredentialsLoader.LoadCredentialsIfNeededAsync uses a semaphore which accepts a cancellation token. We recommend to use this certificate loader when MSAL is used to acquire tokens. The recommendation is also to recreate an MSAL instance per request and pass cancellation tokens with timeouts where accepted. This means the call to load a certificate can be called per request. So we should have an API that passes a cancellation token to the semaphore.

Describe the solution you'd like Add an overload that accepts a cancellation token to APIs in DefaultCertificateLoader and DefaultCredentialsLoader. Pass the token to the semaphore in LoadCredentialsIfNeededAsync.

agarwalishita commented 1 week ago

Please assign this issue to me. Would like to contribute to this one.