为本地应用程序保留 firebase firestore 和存储安全规则(允许读取、写入 = true)是否有风险?

is it risky to keep firebase firestore & storage security rules (allow read , write = true) for a local application?

我正在构建一个 Flutter 应用程序来管理任务并将客户端数据存储在 firebase firestore 上,但我没有配置 firebase 安全规则的经验。

了解 firebase 安全规则并配置它们是否是必须的,或者在没有安全规则的情况下允许读写是可以的,因为知道该应用程序将仅在员工手机(15 人)和本地下载和使用,并且对 cloudFirestore 中的文档进行更改的权限是通过来自 flutter App 的登录用户角色管理的?

如果有风险,我可能面临什么样的风险?

如果您谈论的是 firebase 数据库(例如 firestore)或存储,您必须始终根据您希望每个用户读取或写入的内容添加安全规则。 您的后端可以通过其他客户端 API 访问,例如web api 所以安全规则很重要。

Firebase 使用基于通用表达语言 (CEL) 的领域特定语言。一般结构是:

service << name >>  {
  // Match the resource path.
  match << path >>  {
      // Allow the request if the following conditions are true.
      allow << methods >> : if << condition >>;
  }
}

一个非常基本的规则是允许任何用户读取但只有经过身份验证的用户才能写入,可以这样写:

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