我的自定义声明中有一个包含单个整数的数组/列表,如下所示:
someList: [0]
我想检查我的存储安全规则列表中是否存在数字。我似乎无法使文档中提到的
hasAll
规则起作用:https://firebase.google.com/docs/reference/security/storage#hasall
引用列表时有些规则起作用,所以我确定该属性在我的自定义声明中,但我似乎无法让它与
hasAll
一起使用或使用字符串技巧。
例子-
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /clients/{clientId}/{allPaths=**} {
// These work -
allow read, write: if request.auth.token.someList.join('').size() > 0
allow read, write: if request.auth.token.someList != null
// These do not -
allow read, write: if request.auth.token.someList.hasAll([0])
allow read, write: if request.auth.token.someList.join('').matches('0')
}
}
}
🤷u200d♂️🧐?
您可以做的一些事情:
getidtoken
并在拨打电话之前将 forceRefresh
设置为 true,记录您返回的数据。
检查以下规则是否通过:
allow read, write: if request.auth.token.someList is list;
allow read, write: if request.auth.token.someList.size() == 1;
allow read, write: if 0 in request.auth.token.someList;