来自 Google AppEngine 服务帐户的 Firestore 规则和版本

Firestore rules and edition from Google AppEngine service account

我更新了我的 Google App Engine 应用程序,以便在同一项目中新创建的 firestore 实例中写入一些设置。

我收到来自 firestore/firebase 的电子邮件,说我的 firestore 不安全并且对 read/write 的任何人开放。

当我查看文档时,所有示例都指向 Firebase 应用程序,而我正在通过“google/cloud”PHP 使用 Google App Engine 服务帐户写入 firestore图书馆。

你们有样品吗? 我只需要允许服务帐户读写单个集合。

听起来您正在使用 Admin SDK 或其他方式server-side API 来访问 Cloud Firestore。在这种情况下,您的代码使用管理凭据访问 Firestore,并绕过安全规则。

如果这是您访问 Cloud Firestore 的唯一方式,您只需设置安全规则以禁止来自 client-side SDK 的所有访问。根据 locking down the database 上的 Firebase 文档,这些规则是:

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