I am working on a system that consists of different backend microservices and a few inter-linked micro-frontend apps (all of them built with ReactJS).
Below is my use case (for brevity, I'm just listing the frontend apps here and leaving out the backend services):
We have the following apps:
- https://id.example.com - The frontend that handles user login, profile management and presents the user with a dashboard with links to the modules he/she has access to. The dashboard has links, such as
Settings
,Tickets
,Campaigns
,Analytics
, etc. - We use an OAuth2 server for authentication that gives us an
access_token
and arefresh_token
. Once these tokens are obtained, the dashboard screen is shown - Now, the user clicks
Tickets
, which must redirect to https://tickets.example.com
When the redirect happens, I need to be able to pass the authentication information (obtained from https://id.example.com) to the Tickets app (at https://tickets.example.com), so that the tickets app can validate the token when it loads up.
I understand I can redirect the user to https://tickets.example.com?token=<auth_token>&refresh_token=<refresh_token>
, but I am not sure if that is a secure way of doing it.
Tried using localStorage
, but seems they are also tied up to the host and I was unable to get value from the localStorage
of id.example.com
from within tickets.example.com
Also, the micro-frontends are deployed separately each with its own subdomain (tickets.example.com, campaigns.example.com, etc.) and I understand that one can use frameworks such as single-spa
and Module federation to load them inside a Container app. But this is not what I prefer.
In summary, I would like to know how I can pass bits of information (such as auth tokens, session information, etc.) between any two front-end apps?
Thanks, Sriram