【发布时间】:2019-05-05 12:15:40
【问题描述】:
我为每个用户创建了一个用户 ID 集合,并且我想设置数据库规则以仅当用户 ID 与集合项名称匹配时才读取集合项。 我试过类似的东西:
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read: if request.auth != null;
}
match /{userId} {
allow read: if belongsTo(userId);
}
function belongsTo(userId) {
return request.auth.uid == userId
}
}
}
【问题讨论】:
标签: firebase google-cloud-firestore firebase-security