Firebase 不同Firestore集合的不同安全规则
我目前第一次使用Firestore,并试图稍微了解一下安全规则。我现在的问题非常简单,我可以通过做更多的研究来找出答案,但我想确定我做的是正确的事情,所以我认为在这里提问会更好 如果我在Firestore中有两个集合,一个叫做“A”,另一个叫做“B”,如果我只想让经过身份验证的用户读、写、更新、删除,那么我的安全规则应该是什么。。。在A和B中,每个人都可以阅读,但只有经过身份验证的用户才能写入、更新、删除。。。在B 编辑: 以下是当前规则—它们将B的规则应用于所有集合:Firebase 不同Firestore集合的不同安全规则,firebase,firebase-authentication,google-cloud-firestore,firebase-security,Firebase,Firebase Authentication,Google Cloud Firestore,Firebase Security,我目前第一次使用Firestore,并试图稍微了解一下安全规则。我现在的问题非常简单,我可以通过做更多的研究来找出答案,但我想确定我做的是正确的事情,所以我认为在这里提问会更好 如果我在Firestore中有两个集合,一个叫做“A”,另一个叫做“B”,如果我只想让经过身份验证的用户读、写、更新、删除,那么我的安全规则应该是什么。。。在A和B中,每个人都可以阅读,但只有经过身份验证的用户才能写入、更新、删除。。。在B 编辑: 以下是当前规则—它们将B的规则应用于所有集合: service clou
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read: if true;
allow write: if request.auth.uid != null;
}
}
}如果您查看,您会发现以下规则:
针对您的用例进行了修改,如下所示:
service cloud.firestore {
match /databases/{database}/documents {
match /A/{id} {
allow read, write: if request.auth.uid != null;
}
match /B/{id} {
allow read;
allow write: if request.auth.uid != null;
}
}
}
如果您查看,您将发现以下规则:
针对您的用例进行了修改,如下所示:
service cloud.firestore {
match /databases/{database}/documents {
match /A/{id} {
allow read, write: if request.auth.uid != null;
}
match /B/{id} {
allow read;
allow write: if request.auth.uid != null;
}
}
}
请将Firestore规则放在线程中。(我现在在手机上,从这里直接读起来很容易),我会尽力帮你的下面是如何构建它的。使用类似这样的“match/{}”命令:match/{B}请将Firestore规则放入线程中。(我现在在手机上,从这里直接读起来很容易),我会尽力帮你的下面是如何构建它的。使用类似这样的“match/{}”命令:match/{B}