Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Firebase Firestore安全规则:request.query.limit不使用复合查询_Firebase_Google Cloud Firestore_Firebase Security - Fatal编程技术网

Firebase Firestore安全规则:request.query.limit不使用复合查询

Firebase Firestore安全规则:request.query.limit不使用复合查询,firebase,google-cloud-firestore,firebase-security,Firebase,Google Cloud Firestore,Firebase Security,安全规则: firestore().collection('orders').where('customerId', '==', uid) .where('orderStatusCode', 'in', [1, 2, 3]) .limit(100) .get().... match/orders/{order}{ 允许列表:if request.query.limit如果任何安全规则允许操作,Firestore安全规则将允许该操作 在您的情况下,您允许在列表

安全规则:

firestore().collection('orders').where('customerId', '==', uid)
      .where('orderStatusCode', 'in', [1, 2, 3])
      .limit(100)
      .get()....
match/orders/{order}{

允许列表:if request.query.limit如果任何安全规则允许操作,Firestore安全规则将允许该操作

在您的情况下,您允许在列表规则后的行中进行
read
访问。
read
get
list
的组合
get
用于文档特定的查询,
list
用于对集合的查询。即使
list
规则被拒绝,
read
规则被拒绝传递,因此您的查询正在获取数据

您可以像这样更新安全规则以使其正常工作:

  match /orders/{order} {
  allow list: if request.query.limit <= 15;

  allow read: if request.auth.uid == resource.data.customerId;
  allow create: if request.auth != null;
  allow update: if request.auth.uid == resource.data.customerId;
  allow delete: if false;
}

您可以发布一个忽略规则的示例查询吗?另外,拥有完整的安全规则可能有助于调试此问题。这里的问题是什么?您有
limit获得了它。谢谢。我现在就写一个答案。@dshukertjr即使在查询中限制设置为100,我也会得到数据。我已经更新了我的答案
  match /orders/{order} {
  allow list: if request.query.limit <= 15;

  allow read: if request.auth.uid == resource.data.customerId;
  allow create: if request.auth != null;
  allow update: if request.auth.uid == resource.data.customerId;
  allow delete: if false;
}
match /orders/{order} {
  allow list: if request.query.limit <= 15;

  allow get: if request.auth.uid == resource.data.customerId;
  allow create: if request.auth != null;
  allow update: if request.auth.uid == resource.data.customerId;
  allow delete: if false;
}
match /orders/{order} {
  allow list: if request.query.limit <= 15 
  && request.auth.uid == resource.data.customerId;

  allow get: if request.auth.uid == resource.data.customerId;
  allow create: if request.auth != null;
  allow update: if request.auth.uid == resource.data.customerId;
  allow delete: if false;
}