【问题标题】:Firebase security rules : How can I use dashes or hyphen in paths?Firebase 安全规则:如何在路径中使用破折号或连字符?
【发布时间】:2019-04-12 22:40:25
【问题描述】:

我找不到在 Firestore 安全规则路径中使用连字符或破折号的方法。我收到此错误消息:“意外'-'”

它仅适用于在线规则编辑器/模拟器,但在尝试使用 Firebase CLI (firebase deploy --only firestore:rules) 部署 .rules 文件时出现错误。

我尝试在连字符集合名称(路径)周围使用单引号。我在互联网上找不到任何关于此问题的信息。

service cloud.firestore {
  match /databases/{database}/documents {

    // Match any document in the 'oversea-users' collection
    match /oversea-users/{oversea-user} {
      allow read: ... condition ...;
    }
  }
}

【问题讨论】:

    标签: google-cloud-firestore firebase-security


    【解决方案1】:

    我发现我的错误只是在“catch”对象名称中,而不是在路径中。 {} 之间必须使用overseaUsers 而不是oversea-user。

    service cloud.firestore {
        match /databases/{database}/documents {
    
        // Match any document in the 'overseaUsers' collection
        match /oversea-users/{overseaUsers} {
            allow read: ... condition ...;
        }
      }
    }
    

    【讨论】:

    • 花括号中的那个东西被称为“通配符”。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多