plamber / MSAL-Authenticationsamples

Sample projects that show how to authenticate against MSAL
13 stars 13 forks source link

Can this MSAL flow also be used when mutliple React apps are hosted ? #10

Open StefH opened 3 years ago

StefH commented 3 years ago

Currently you have 1 React app.

Did you also investigate if it's also possible to use MSAL AAD authentication when multiple React apps are hosted in the same website?

Will the authentication token be shared, or does the user need to login in each app separately?

plamber commented 3 years ago

Hi @StefH , I never tried it out like that. Always had separate application instances. I would give it a try with the new libraries provided by this link.

In the background it saves authentication tokens based on DNS + Application ID. I assume if you keep the same application ID for all apps and DNS entry, it should work

br,

StefH commented 3 years ago

Hi @plamber, thanks for the reply.

For a React application, can I just call the code below in App 2 (when App 1 was authenticated) to get the token, and not be presented with a login popup?

instance.acquireTokenSilent(. . .

Or should I manually get the token from the local-storage or session-storage in the App 2?

plamber commented 3 years ago

Hi, you should never try to manually get the token from the storage. It is done from the library. My understanding is that if you share the same AppID and you are on the same domain, the tokens are being shared.

You should give it a try.

br,