我试图使用以下文档在Firestore中设置自定义规则:https://firebase.google.com/docs/reference/security/database/#containssubstring
我是用定制的索赔来做这个的。
什么起作用:
match /calendar/{calendar} {
allow read: if request.auth.token.customData == "calendar-read,calendar-write";
}我不知道为什么:
match /calendar/{calendar} {
allow read: if request.auth.token.customData.contains("calendar-read");
}这将给我:"FirebaseError:缺少或不足的权限“
发布于 2020-12-27 17:09:48
由于您使用的是Firestore,所以您应该使用固定字符串的API文档,而不是实时数据库字符串。您将看到没有用于Fi还原字符串的名为"contains“的方法。
如果要检查字符串中是否包含子字符串,则应该使用匹配(),并提供与之匹配的正则表达式。
allow read: if request.auth.token.customData.matches(".*calendar-read.*");如果request.auth.token.customData包含字符串“日历-读取”,那么上面的内容应该返回true。
如果您使用的是逗号分隔的值列表,请考虑使用斯普利特(和list.hasAny()来更清楚。
https://stackoverflow.com/questions/65467896
复制相似问题