Firebase安全规则附带一个记录为here的资源对象。但是,在编写规则时使用id字段无法正常工作。
match /{collectionName}/{document=**} {
allow read: resource.id == 'SomeDocumentId'
allow write: if false;
}
}
当使用文档ID进行模拟时,它会拒绝。
match /{collectionName}/{document=**} {
allow read: resource.id == null
allow write: if false;
}
}
match /{collectionName}/{document=**} {
allow read: resource.id != null
allow write: if false;
}
}
如果检查它是否为空,则两个规则始终拒绝。在同一设置中,Id字段为空且不为空。
我相信在编写我的规则差不多一年之前,我测试了它并且正在工作,但现在它有问题。有关使用resource.id字段的任何帮助?
这个问题自己解决了。 firebase端可能存在暂时性问题。现在,如果资源可用,则null check始终返回false,而不是null check对于id字段,总是返回true。如果资源可用,那么这个也总是返回true
match /{collectionName}/{document} {
allow read: resource.id == document
allow write: if false;
}
}