Azure / azure-sdk-for-cpp

This repository is for active development of the Azure SDK for C++. For consumers of the SDK we recommend visiting our versioned developer docs at https://azure.github.io/azure-sdk-for-cpp.
MIT License
181 stars 126 forks source link

Support token cache persistence in client assertion workflow #6049

Open ahsonkhan opened 1 month ago

ahsonkhan commented 1 month ago

Description of Ask: To have ClientAssertionCredentialOptions implement ISupportsTokenCachePersistenceOptions. As a consumer of Identity, Azure PowerShell is dependent on the Azure Identity library for .NET. Now the client assertion workflow has increasing usage, so the ask should have higher priority.

Business Impact: In the client assertion auth flow, Azure PowerShell customers acquire the access token with the federated token. The access token must be used by the subsequent Azure PowerShell cmdlets. We depend on Azure.Identity to save the tokens to the MSAL cache. As the federated token has a short lifetime, it's impossible to cache the federated token and reauthenticate every time a cmdlet is run.

.NET reference implementation - https://github.com/Azure/azure-sdk-for-net/pull/43633

Moved from https://github.com/Azure/azure-sdk-for-cpp-pr/issues/26

cc @scottaddie

ahsonkhan commented 1 month ago

After discussion, this feature requires support from MSAL to enable. This is because MSAL handles the following important aspects: 1) Encrypting the cache file on disk using data protection APIs (and picking a consistent location) 2) Store the cache in a file format and structure that is consistent across languages (.NET/Java/Python)

From @RickWinter:

MSAL is the correct place for persistent token cache to reside. We can implement this feature once we have that support in MSAL.

We'd want to wait and see if there's customer asks for this, in C++, to help prioritize.

Open question:

Other notes: