AzureAD / microsoft-authentication-library-common-for-android

Common code used by both the Active Directory Authentication Library (ADAL) and the Microsoft Authentication Library (MSAL)
MIT License
41 stars 35 forks source link

Update active broker cache upon returned result #2140

Closed rpdome closed 1 year ago

rpdome commented 1 year ago

PBI: https://identitydivision.visualstudio.com/Engineering/_boards/board/t/Auth%20Client%20-%20Android/Backlog%20items/?workitem=2582815

With the new Broker selection mechanism - every response from broker will contain the updated active broker package name and signing certificate thumbprint.

(This is because the broker app that was made a request to might not be the broker app that process the request. This is rare, but technically can happen)

This change is to make sure that the active broker cache remains fresh if such edge case happens.

In BrokerOperationExecutor.performStrategy(), we'll always try to update the cache (if the active broker info is returned along with the response bundle).

NOTE: I also remove the in-memory cached value from BaseActiveBrokerCache.. simply because there could be multiple cache instances, and this (premature optimization) could lead to issues.

NOTE-2: this change will only be applicable to MSAL and Broker API. Extra work is needed for the new MWPJ API.


Validated by the added unit tests in BrokerOperationExecutorTests and ActiveBrokerCacheUpdaterUtilTest