【发布时间】:2022-01-18 22:53:45
【问题描述】:
在我的规则中,我想确保 data.id 字段是 doc id 的哈希值。以下操作无效。
function hashGood(a, b) {
let x = hashing.sha256(a);
return x == b;
}
match /users/{userId} {
allow create: if request.auth != null && hashGood(userId, request.resource.data.id);
}
我也尝试过hashing.sha256(a.toUtf8()).toBase64() 及其变体。
当我尝试在“规则游乐场”中创建 /users/B 时,它会显示 x == "B" 。但是x应该是“B”的hash,不等于“B”。
我做错了什么?
编辑:我正在使用rules_version = '2';
【问题讨论】:
标签: google-cloud-firestore firebase-security