-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Notify other open tabs of updates to localStorage #7550
Conversation
…tion-library-for-js into localStorage-update-events
change/@azure-msal-browser-8d616d70-17b9-4549-a720-855a2874c1da.json
Outdated
Show resolved
Hide resolved
change/@azure-msal-common-c1d96db0-db2f-4c63-918b-2da95279ee16.json
Outdated
Show resolved
Hide resolved
Co-authored-by: Jo Arroyo <joarroyo@microsoft.com>
…AD/microsoft-authentication-library-for-js into localStorage-update-events
return; | ||
} | ||
|
||
if (context && context !== this.clientId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it expected to reload if clientId
changes? Is it not possible for multiple apps to be in same frame (some apps do this)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the in-memory cache should contain only the cache entries that belong to its own clientId, it will ignore broadcasts coming from other clientIds. In the case where an app has multiple clientIds in the same frame each one will have its own listener and handle messages from its respective instance in the other tab.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added one comment, can be addressed later
In v4 we added encryption of localStorage entries, which also makes use of an in-memory cache to avoid constantly decrypting localStorage. This had the side effect of creating scenarios where multiple open tabs may have diverging cache states until they refresh and resync with localStorage. This PR adds broadcasting of localStorage updates to notify other open tabs or other instances of MSAL they should pull the latest changes into their respective in-memory cache objects.
On a related note: This PR also implements broadcasting for the Account Added and Account Removed events since these can no longer rely on the localStorage update events due to those values now being encrypted.