Closed yoshegg closed 2 years ago
Have your Provider called in an Auth microfrontend with will set the user credential/token in the localStorage ( as you want ). Then have your other MFEs read those credentials from localStorage and behave accordingly. The Auth MFE would be your entrypoint MFE in root-config & always active. It needs to reroute to other MFE based on user authentification.
MFE: Microfrontend.
@yoshegg does the suggestion above work as a solution for you.
As as a library we do not have any official solutions other than the solutions stated above and the aforementioned issue, we however have this noted and have added this to our backlog.
@exaucae @samuelkubai We will try that and post our results. Thank you for your time.
@yoshegg , here is an additionnal doc for the issue: https://github.com/exaucae/single-spa-patterns/blob/master/AUTHENTICATION.md
@yoshegg This issue has been automatically marked as stale because it is marked as requiring author feedback but has not had any activity for 5 days. If your issue has been resolved please let us know by closing the issue. If your issue has not been resolved please leave a comment to keep this open. It will be closed automatically in 7 days if it remains stale.
Core Library
MSAL.js v2 (@azure/msal-browser)
Core Library Version
2.19.0
Wrapper Library
MSAL React (@azure/msal-react)
Wrapper Library Version
1.1.1
Description
We are using
React
andsingle-spa
to implement our multi-frontend application. We have a navigation bar and an index part; these are separated into two different applications. Parts of these applications should be shown (or not) depending on the authentication of the user.The problem is that we can't figure out how to use the mandatory
<MsalProvider>
in a way that it wraps around our application. Right now we use<MsalProvider>
twice, which we know is not recommended and leads to the problem that the instance state is not synchronized among our microfrontends: One application works as expected, whereas the other's instance's context is not updated correctly. Refreshing the page or navigating to it results in unexpected behaviour.Is there a way to use
msal-react
withsingle-spa
while using multiple applications?The user in the aformentioned issue solved his problem by using the vanilla javascript library.
Another user had a similar problem that was also linked to using
<MsalProvider>
in an inappropriate way; This seems to be related to an entirely different problem though.MSAL Configuration
Relevant Code Snippets
Identity Provider
Azure B2C Basic Policy
Source
External (Customer)