【发布时间】:2020-07-29 13:44:57
【问题描述】:
我无法理解和配置 Firebase 云 Firestone 安全规则。 我正在使用 Plugin.CloudFirestore。
完全释放安全性后,我可以访问。见规则和代码:
match /{document=**} {
allow read: if true;
allow write: if true
}
public async Task<IQuerySnapshot> GetCollection(string collection)
{
var group = await CrossCloudFirestore.Current
.Instance
.GetCollectionGroup(collection)
.GetDocumentsAsync();
return group;
}
现在,由于不允许以下规则,访问被拒绝:
match /Categorias/{document=**} {
allow read: if true;
allow write: if true
}
like this: match / Categorias / {document = **} - 我只能通过指定文档获取数据,无法获取文档列表。
请帮助我了解我缺少什么。
【问题讨论】:
-
如果你这样做
.GetCollection("Categorias")会发生什么,所以使用硬编码的名称并且只获取单个集合而不是组? -
嗨弗兰克,规则:
match /Categorias/{document=**} { allow read: if true; allow write: if true }如果我指定文档,它可以工作:firebase.GetDocument("Categorias", "3");如果我必须返回集合中的所有文档:firebase.GetCollection("Categorias")发生错误:PERMISSION_DENIED: Missing or权限不足 -
如果你改成
match /Categorias/{document}这样的东西,能用吗?除此之外,您能否检查一下您的服务帐户是否具有完全访问权限,如 here 所阐明的那样?也许您正在使用它,但它没有所有需要的权限。 -
嗨 gso_gabriel 我检查了
match /Categorias/{document}并得到了相同的结果。关于服务帐户,不是这样,因为如果我配置规则match /{document=**} { allow read: if true; allow write: if true }我可以让 GetCollection 工作。 -
嗨@JoséDonizeteOliveiraJunior 考虑到这一点,我建议您直接联系Firebase Support,以便他们帮助您检查。您的规则以及您的帐户权限似乎都是正确的,因此他们可以进一步调查您的实例。
标签: c# xamarin google-cloud-firestore firebase-security