Thi*_*man 8 firebase google-cloud-firestore firebase-cli
今天我注意到我无法部署我的Firestore规则,即使它们一直运行到现在并且我没有更改它们.这是它不喜欢的部分的摘录:
match /databases/{database}/documents {
function userMatchesId(userId) {
return request.auth != null
&& request.auth.uid == userId
}
function userIsAdmin() {
return request.auth != null
&& get(/databases/$(database)/documents/users/$(request.auth.uid)).data.role == "admin"
}
// === Admins ====
// Admin users are allowed to access everythings.
// Writes should be performed via code executed by a service account
match /{document=**} {
allow read: if userIsAdmin()
}
// ==== Private ====
// Collections private to the user. Documents read access is matched
// with the authenticated user id.
match /users/{userId} {
allow get: if userMatchesId(userId)
}
match /userCredits/{userId} {
allow get: if userMatchesId(userId)
}
}
Run Code Online (Sandbox Code Playgroud)
在实践中,这些规则已经按照我的想象发挥作用.管理员可以读取非管理员无法直接查询的集合.但是,现在我在部署期间遇到此错误:
错误:firestore.rules中的编译错误:
[W] 42:5 - 重叠的递归通配符匹配语句.
我不太明白这个问题.你会如何解决这个问题?
(Googler在这里) 这是我们的错误.我们正在为规则添加新的编译器警告,以帮助您发现可能引入的错误.许多人没有意识到,如果您有多个match与特定路径匹配的语句,那么这些块中的规则就OR'ed在一起.这个警告应该可以帮助你发现这一点.
但是,如果您了解自己正在做的事情,那么从来没有打算阻止您部署有效的规则!我们会解决这个问题.
更新8/1 @太平洋标准时间上午11:50
我们在这里做了两处修改:
firebase-tools),4.0.2修复此问题以使警告不致命.这应该是暂时发生的.| 归档时间: |
|
| 查看次数: |
259 次 |
| 最近记录: |