Firestore add security rule to allow reads only from mobile app [duplicate]

我的梦境 提交于 2021-02-05 08:30:35

问题


I am making a mobile app with Firestore and React Native.

There is no authentication system and upon starting the app, the user download a collection from Firestore.

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

As of right now, the rule allows everyone to read from the database. Is it possible/advisable to limit the traffic to only our mobile app?


回答1:


It's not possible to use security rules to limit access to a certain app. If your rules allow read access without requiring a sign-in using Firebase Authentication, then anyone with an internet connection can perform reads.

Minimally, you could require anonymous authentication. But that still would not stop someone from creating an account and using that to read everything without going through the app.



来源:https://stackoverflow.com/questions/62665107/firestore-add-security-rule-to-allow-reads-only-from-mobile-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!