firebase - 子集合的 Firestore 规则
问题描述
我在 Firestore 上有一个带有“级别”子集合的“游戏”集合。我正在尝试设置安全规则,以便您只能访问您创建的游戏或关卡。
所有文档(游戏或关卡)都有一个authorId
字段,其中包含创建它们的用户的 uid。我尝试了这个规则,但仍然出现Missing or insufficient permissions
错误:
service cloud.firestore {
match /databases/{database}/documents {
match /games/{document=**} {
allow read, write: if document.data.authorId == request.auth.uid;
}
}
}
我错过了什么?
我也尝试了以下规则但没有成功:
service cloud.firestore {
match /databases/{database}/documents {
match /games/{game}/levels/{level} {
allow read, write: if level.data.authorId == request.auth.uid;
}
}
}
service cloud.firestore {
match /games/{game} {
allow read, write: if game.data.authorId == request.auth.uid;
match /levels/{level} {
allow read, write: if level.data.authorId == request.auth.uid;
}
}
}
解决方案
推荐阅读
- android - 如何在android中将屏幕划分为小方块?
- java - 在可扩展列表中滚动父项内的子项
- java - HTTP 状态 404 - /UESProject/
- r - 安装 readxl 包后加载 tidyverse 时出错
- php - PHP - 数组元素上的 strpos?
- saml-2.0 - SAML2:由 URL 加载的 SP/idP 元数据是否安全?
- java - How configure c3p0 with Hibernate and JNDI?
- python - Django - error 500 occurs when checking if value is None
- android - Menu problems in toolbar
- c - Scanning Strings on Multiple input lines - C language