简体   繁体   中英

firestore flutter admin app write rules and data from admin app

I made a Flutter app using cloud Firestore. I want to add documents, I have two options:

  • I put data in Firestore manually
  • I create an admin app for writing data

My question is: do I need auth in my admin app to write to my database? And if so, I don't know what client libraries and server-side. What is the safest option to write to Firestore database?

If your users just visualize your data without being able to authenticate then you can use authentication in your Admin application and authenticate yourself with the same Firebase Firestore. Don't forget to use the security rules as following in firestore:

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if request.auth != null;
    }
  }
}

If your users are also required authentication to visualize the data I'd suggest you to create Admin, Reader & Writer tokens so you can establish a Custom-claim attributes and roles. You can find more information on that here; https://firebase.google.com/docs/rules/basics

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