10

Using Firebase multiple sites (ie. same project/authentication just different sites), I'd like to separate my public site from the main app without needing to log into both. ie. have the login form on one site, and using the auth token, have access to any other site within that Firebase project.

My main problem is that I'd like to keep my registration/login forms on the public site, however when authenticated, as the app is on a different connected domain, the token isn't available.

Some options I've considered but would like to avoid if a better solution exists:

1) Move the login form to the main app. It's currently in a nice modal on the public site, making it available on every page, which I'd like to keep.

2) Combine the apps (both are React). I'd keep them separated as it currently allows separated development and deployments work etc.

3) Lastly, I've read about minting my own tokens on my own server, but if I can avoid this I will.

Does anyone know if the above is possible?

M.Lewis
  • 961
  • 8
  • 18
  • You could easily use the same login database, but you would have to re-login across domains as that is where the browser stores the sessions... you can [hack this](https://stackoverflow.com/questions/14611545/preserving-session-variables-across-different-domains/14611577#14611577), but then it is a security issue. – Jonathan Sep 18 '21 at 15:09
  • One possibile option is to use multiple firebase hostings on the same Firebase project, one hosting per application, but all can share the same firebase projects's resources; this urges you to further "logically" separate other resources that at this time are not "phisically" separable (ie, create a root namespace per app for firestore documents). If you want to keep separate projects, i think the best approach would be to have a firebase projects that acts like an SSO, whom is only responsible of authentication and also syncs users across projects and forges auth tokens for other projects. – Mattia Galati Nov 06 '21 at 09:20

0 Answers0