如何防止我的用户将 firebase 实时数据库下载为 json 文件
How to prevent my users downloading firebase realtime database as a json file
我有一个简单的搜索数据应用程序,它给出了用户输入值的相应结果。
我的用户可以通过转至 https://test.firebaseio.com/data.json
将 firebase 实时数据库下载为单个文件。如何防止这种情况。仅提供搜索结果而不读取完整数据的任何方式。我的意思是不允许将完整的 json 文件下载给用户,但只允许搜索。
访问 https://test.firebaseio.com/data.json
URL 正在使用 Firebase 实时数据库的 REST API。鉴于云托管数据库的性质,一般来说,人们总是能够通过此 API 获取任何数据,他们也可以在您的应用程序代码中访问这些数据。
事实上,在编写良好的应用程序中,security rules of your database will match closely with the client-side code of that application. For example: if you application code only reads specific keys, your security rules should only allow those keys to be read - and reject reads of other data. This is known as the principle of least privilege 是 Firebase 安全策略的关键。
有关这方面的更多信息,我建议阅读我对这些最近问题的一些回答:
或这些较早但排名靠前的答案:
最后,要将对数据库的访问限制为您的应用程序代码,请考虑实施 Firebase App Check。虽然它并非万无一失,但使用 App Check 可以让恶意用户更难运行他们自己的代码来攻击您的项目,从而减少对您项目的滥用。
我有一个简单的搜索数据应用程序,它给出了用户输入值的相应结果。
我的用户可以通过转至 https://test.firebaseio.com/data.json
将 firebase 实时数据库下载为单个文件。如何防止这种情况。仅提供搜索结果而不读取完整数据的任何方式。我的意思是不允许将完整的 json 文件下载给用户,但只允许搜索。
访问 https://test.firebaseio.com/data.json
URL 正在使用 Firebase 实时数据库的 REST API。鉴于云托管数据库的性质,一般来说,人们总是能够通过此 API 获取任何数据,他们也可以在您的应用程序代码中访问这些数据。
事实上,在编写良好的应用程序中,security rules of your database will match closely with the client-side code of that application. For example: if you application code only reads specific keys, your security rules should only allow those keys to be read - and reject reads of other data. This is known as the principle of least privilege 是 Firebase 安全策略的关键。
有关这方面的更多信息,我建议阅读我对这些最近问题的一些回答:
或这些较早但排名靠前的答案:
最后,要将对数据库的访问限制为您的应用程序代码,请考虑实施 Firebase App Check。虽然它并非万无一失,但使用 App Check 可以让恶意用户更难运行他们自己的代码来攻击您的项目,从而减少对您项目的滥用。