Gar*_*ryO 4 google-cloud-storage firebase firebase-security
我正在尝试根据用户数据保护我的 Firebase(谷歌云存储)文件。在 firestore 中,我使用基于获取数据库内容的规则(在用户表中查找 uid 并匹配一个字段),并且工作正常。我试图在 firebase 存储中使用相同类型的规则,但在模拟器中我得到Error: simulator.rules line [12], column [17]. Function not found error: Name: [get].; Error: Invalid argument provided to call. Function: [get], Argument: ["||invalid_argument||"]. 我的规则是这样的:
match /b/{bucket}/o {
function isAuth() {
return request.auth != null && request.auth.uid != null
}
function isAdmin() {
return isAuth() &&
"admin" in get(/databases/$(database)/documents/users/$(request.auth.uid)).data.roles;
}
function clientMatch(client) { // expects user's "client" field to be ID of client
return isAuth() &&
client == get(/databases/$(database)/documents/users/$(request.auth.uid)).data.client;
}
match /P/Clients/{client}/{allPaths=**} {
allow read, write: if isAdmin() || clientMatch(client);
}
}
}
Run Code Online (Sandbox Code Playgroud)
第 12 行是一个开始client == get,在clientMatch(). 我无法判断这些函数是否仅支持 Firestore (db) 规则,或者它们是否也适用于存储。
如果这不起作用,我有什么选择?人们如何查找 Firebase 存储安全的用户数据?
| 归档时间: |
|
| 查看次数: |
1255 次 |
| 最近记录: |