AzureAD / microsoft-authentication-library-for-java

Microsoft Authentication Library (MSAL) for Java http://aka.ms/aadv2
MIT License
282 stars 137 forks source link

Update cache keys for MSI scenarios #746

Closed Avery-Dunn closed 8 months ago

Avery-Dunn commented 8 months ago

Addresses https://github.com/AzureAD/microsoft-authentication-library-for-java/issues/710

In both MSAL .NET and MSAL Java, the cache key for access tokens contains the tenant. For .NET this tenant value is a constant "managed_identity" for MSI scenarios, however in Java we had a default authority value which we extracted the tenant from, which meant it was always "common" instead of "managed_identity"

The changes in this PR add a new 'tenant' field to Public/Confidential/ManagedIdentity apps, which is then used in the token cache instead of parsing the authority. This will allow the cache keys in Java to better match those in .NET, and hopefully be more clear about where the tenant in a cache key came from.

(tests covering both the old and new cases will be coming soon)