【问题标题】:Insecure Security rules for Cloud FirestoreCloud Firestore 的不安全安全规则
【发布时间】:2020-11-03 23:38:56
【问题描述】:

我总是收到关于我的 Cloud Firestore 安全规则不安全的邮件。

每个用户都可以读取整个数据库

但我不明白?这些是我的规则:

service cloud.firestore {
    match /databases/{database}/documents {
        match /users/{userID} {
            allow read;
            allow write: if request.auth != null;
        }
        match /users/{userId}/wishlists/{restOfPath=**} {
            allow read,write: if request.auth != null;
        }
    }
}

users 应该对每个人都可读,但其他所有内容都应该仅限于授权用户。我在这里错过了什么?

【问题讨论】:

  • 我认为这只是来自 Firestore 的警告,建议您在需要向所有用户开放数据库访问权限时尽量避免此类情况。你可以阅读更多关于规则here

标签: firebase google-cloud-firestore firebase-security


【解决方案1】:

我对“允许阅读”感到惊讶;线。您可以将其替换为“允许读取:如果为真;”

使用以下方式开始您的规则文件更安全:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if false;  // General rule that protects access to documents not covered by the next rules
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-04-21
    • 1970-01-01
    • 1970-01-01
    • 2018-04-05
    • 2021-11-22
    • 2018-07-23
    • 2018-10-19
    • 2019-07-05
    相关资源
    最近更新 更多