简体   繁体   中英

How to set up and connect Firebase Project for Authentication ONLY to an Angular web app in another project?

I currently have two Firebase projects. One has the main database, an angular entry tool web app (used internally that fills the database), and two mobile apps that read from that database (currently have authentication in this project set up for the mobile apps users). The other project is blank and is thought to be used for authentication for the internal entry tool web app only .

I don't know if this is the best route. However, if so how do I connect the Entry Tool Auth Project to the Main Project? Especially if I'm not creating any apps within the Entry Tool Auth since it's only used for authentication?

Thanks!

If the data entry app is writing data to the main project, it should authenticate its users against that main project. There is no need to add a second project to the mix, and in fact doing so is what complicates things.

If you only want certain users to be able to use the data entry app, you can keep a list of those user's UIDs in the database and then check in both the code and security rules against that list.

Database

allowedDataEntryUsers: {
  "uidOfUser1": true,
  "uidOfUser2": true
}

Rules:

{
  "rules": {
    "allowedDataEntryUsers": {
      ".read": true,
      ".write": false
    },
    "data": {
      ".read": true,
      ".write": "root.child('allowedDataEntryUsers').child(auth.uid).exists()"
    }
  }
}

So:

  • Everyone can read both the data, and the UIDs of who is allowed to modify the data. You'll want to adapt this to your use-case of course.
  • Nobody can modify the list of allowed users, which means that you can only modify it from the Firebase console, or with the Admin SDK.
  • Only allowed UIDs can modify the data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM