Skip to content
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

[Feature Request]: Expose MSAL caching services to be used by external services #2597

Closed
henriblMSFT opened this issue May 3, 2021 · 7 comments

Comments

@henriblMSFT
Copy link

Is your feature request related to a problem? Please describe.
Azure.Identity is a library to retrieve bearer token for azure managed identities. It does not currently expose a cache as mentioned in their documentation.

To fetch token reliably consumers of the Azure.Identity need to implement the caching logic with all the complexity that comes with managing refresh tokens, temporary outages, accessing different scopes and more.

Most of this logic is already present in the Microsoft.Identity.Client library but the Cache itself cannot be used as a standalone service. It is automatically used when fetching tokens directly from Azure Active Directory. Because Azure.Identity calls a service that is hosted on the virtual machine the MSAL library cannot be used to retrieve a token for a managed

Describe the solution you'd like
Expose the Caching services so that they can be used independently of the ConfidentialClientApplicationBuilder

Describe alternatives you've considered
Re-implementing the cache mechanism on our side which while doable is quite complex and time consuming. It is unlikely to be as robust as code that's used by thousands of other libraries.

A similar feature request has been made to the Azure.Identity library. But they mentioned that they would like to use the MSAL library caching services instead of re-building their own.

@jmprieur
Copy link
Contributor

jmprieur commented May 4, 2021

@henriblMSFT

  • If I understand correctly you'd want to use the token cache independently of MSAL.NET as a separate service (maybe DLL?)
  • There are discussions so that MSAL supports MSI directly (and it does already get to some MSI endpoints for Regional). This seems to be simpler? what do you think?

@henriblMSFT
Copy link
Author

If MSAL had support for MSI that would also solve the problem.

One scenario I'm not sure is covered is the fallback authentication mechanism that Azure.Identity has when using DefaultAzureCredential. If the ManagedIdentity service is not available it will try alternate means to obtain an auth token. This is quite useful to allow developers to run a project locally. Since they don't have access to a managed identity they need to fallback to their user identity to authenticate to external resources.

@qetza
Copy link

qetza commented Jul 4, 2021

Hi @jmprieur,
I found this issue while trying to deal with MSI and caching in Azure.Identity and seeing that no cache was provided 😞

As @henriblMSFT says using Azure.Identity is not only for support of MSI but also for its support of fallback authentication mechanism. As developers are developing and testing locally without MSI, the DefaultAzureCredential class allows them to work without having to deal with different authentication between local and azure.

Exposing the MSAL cache class so that it can be used by external libraries is one solution, another would be to add MSI support to MSAL and fallback mechanism as in Azure.Identity.

@jmprieur
Copy link
Contributor

jmprieur commented Jul 4, 2021

@qetza @henriblMSFT

  • Azure.Identity is going to add support for OBO, and therefore will leverage MSAL cache.
  • We also have discussions for MSAL to support MSI.

@qetza
Copy link

qetza commented Jul 5, 2021

@jmprieur, will Azure.Identity leverage MSAL cache for authentication mechanism (MSI, VS, Azure CLI...) or only for OBO flow? If it's only for OBO, it's a start but i think that what we would like is to have integrated caching for all mechanism 😄

@jmprieur
Copy link
Contributor

jmprieur commented Jul 5, 2021

that's more a question for the Azure SDK team, @qetza.

@bgavrilMS
Copy link
Member

MSAL is building support for Managed Identity - see a preview in 4.49.1
Azure SDK already uses MSAL's token cache via AppTokenProvider delegate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants