【发布时间】:2020-05-02 19:51:39
【问题描述】:
按照 firebase 文档here,我实施了以下安全规则:
match /docs/{hashID} {
allow read, write: if hashing.md5(request.auth.uid.toUtf8()).toBase64() == hashID;
}
在客户端,我使用 node-md5 计算用户的 hashID 并写入文档
firebase.firestore().collection("docs").doc(md5(user.uid)).writeSomething()
由于哈希值不匹配,它未能通过安全规则。
对于 uid“crz6KyreRCM4A0Qvk9EfeXHBLF43”,我的客户端 md5 给了我“eee1f958a8c0a273f138bdee0167693d”,而 Firebase 规则游乐场给了我“fbOLeadWz7YxnsGgfESBNg==”。我已经使用https://www.md5hashgenerator.com/ 验证了客户端 md5 值是否正确。我在安全规则中做错了什么?
【问题讨论】:
标签: firebase google-cloud-firestore firebase-security