How to enable access of firestore data to my nativ

2019-08-22 21:57发布

问题:

I am developing android/ios app using Nativesript + angular. I want to display a ListView in my app. For that ListView, I want to use firestore database product by Firebase as Backend data provider. What I want: 1. I don't want users to login or to be authenticated to use the app. 2. I want the data coming from firebase database can only be used by my app. If some other apps or anonymous utilizes the data, is there any way I can block them?

I have tried putting rules like

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read: if true;
    }
  }
}

But it allows everyone to access the data.

Is there any other data provider which gives the same functionality?

回答1:

There is no way to limit access based on whether the users are using your app. Anyone who has the configuration data for your project, can use the API to access the backend services (such as Firestore) in that project. This is why access control must be based on authenticating a user (allowing you to identify each individual user), and then ensuring they can only access data they're authorized for (in security rules).

If you don't want your users to have to sign in, you can use anonymous authentication. While this doesn't give you any information about the user, you can still identify them in security rules and thus limit their access based on what they've done.