firebase firestore规则无法按预期工作,允许阅读:如果请求。auth!= null&& request.auth.uid == userId;";"
这是我第一次在Firestore中设置安全规则,我想使其成为经过身份验证的用户只能访问。我正在为我的auth系统使用firebase自定义验证。
Firebase安全规则:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId} {
allow write: if false;
allow read: if request.auth != null && request.auth.uid == userId;
}
}
}
我的数据库架构是./用户/{userId}/...
我只希望用户可以在数据库中访问其特定集合。
write 规则是错误的,因此只有我带有管理特权的后端服务器才能
使用以下规则编写我的客户端代码丢弃错误firebaseError:丢失或不足的权限。
尝试时打电话阅读。
如果重要的话,我要制作next.js应用程序,并使用标准Web版本9(模块化)Firestore函数
编辑:我更改了规则,仍然会遇到相同的错误...
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if true;
}
}
}
It's my first time setting up security rules in firestore and I want to make it so authenticated users only have access. I'm using firebase custom auth for my auth system.
Firebase security rules:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId} {
allow write: if false;
allow read: if request.auth != null && request.auth.uid == userId;
}
}
}
my database schema is ./users/{userId}/...
I only want users to have access to their specific collection in the database.
The write rule is false so only my backend server with admin privileges can write
With these rules my client side code is throwing the error FirebaseError: Missing or insufficient permissions.
when I try to make a call to read.
If it matters I'm making a next.js app and using the standard Web Version 9 (modular) firestore functions
EDIT: I changed the rules to this, still getting the same error...
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if true;
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论