Not sure on the best way to achieve this, and forgive my terminology. I want to create (i think) a hybrid multi-instance/multi-tenant architecture with a CMS app and multiple firestore projects.
User logs into my CMS app and once authenticated they can access their data based on what their userId has access to , i.e all their data could be under a collection users with all their data in subcollections belonging to the document with their userID (or something to that effect)
I want the user to be authenticated, but once logged their data is retrieved from a separate google project. Why? Because i would prefer for the data to be separated, and be able to manage the project in a more individual way. For example, if the client decides they want to part ways, or we need to get a bit complex with their setup, or they have a requirement for their data to be partitioned away from others' data, then this will make sense, it then also means I can be more specific with the firebase auth config in each project.
so let's call my CMS APP Project 1 (using Firebase auth and Firestore*)
*there is a firestore in project 1, with some config to say what Joe can access in the CMS and to handle any billing bits)
Joe Bloggs authenticates on
myapp.com/login against Project and succeeds.
He is then taken to his dashboard and the data is pulled from Project 2. Any records he created in the CMS are stored to Project 2. Joes website interacts with Project 2 via cloud function hosted Graph QL
Jess Blogs signs up for CMS App, and a new Project is created (Project 3) and Jess logins in (authenticated against project 1). Jess creates some records in the CMS and the records are created in the firestore in her project (Project 3)
It feels like this is possible as I can use connect to do instances with the relevant api key and project id. But the black hole of information for me is.
1. When Jess signs up, could I automatically create a new firebase project/web app and firebase instance + deploy a cloud function (for the Graph QL)? If so what's the best way to do this, can it all be done in node js?
2. How can I grant access to Project 3, when Jess signs in an authenticate against project 1 (I thought maybe I could store the API key and project id as a custom claim, so i could then access that data from the auth object and use that to connect the 2nd instance of a firebase in my cms app....however, my spidey senses say may its unsafe to do it that way?
I feel like I'm close but after days of reading up, i'm concerned I'm barking up the wrong tree perhaps?