firebase - 在没有身份验证的情况下设置 Firestore,但使用(密钥,签名)数据
问题描述
我想在我的网络应用程序中设置一个 firestore-redux 集成,但不是使用身份验证通过电子邮件进行身份验证并定义“用户”集合,而是想知道用户是否可以使用他的私钥签署消息并将哈希存储为firebase的“auth.uid”?示例:而不是像这样使用身份验证配置:
// react-redux-firebase config
const rrfConfig = {
userProfile: 'users'
UseFirestoreForProfile: true // Firestore for Profile instead of Realtime DB
}
而不是像这样设置安全规则:
// security rules
service cloud.firestore {
match /databases/{database}/documents {
// Allow only authenticated content owners access
match /some_collection/{userId}/{documents=**} {
allow read, write: if request.auth != null && request.auth.uid == userId
}
}
}
我们可以有一个自定义配置,其中文档密钥是用户的公钥,使用用户私钥的签名哈希在安全规则(用于读取和写入)中验证?
// react-redux-firebase config
const rrfConfig = {
userProfile: <<some public key or ethereum address of user>>
UseFirestoreForProfile: true // Firestore for Profile instead of Realtime DB
}
// security rules
service cloud.firestore {
match /databases/{database}/documents {
// Allow only authenticated content owners access
match /some_collection/{userPubKey}/{documents=**} {
allow read, write: if request.data.signHash!= null && request.data.signHash == resource.data.signHash
}
}
}
当使用基于以太坊(区块链)帐户的身份验证进行 Firebase 存储时,这将是相关的,而不是通常的基于电子邮件的。
解决方案
推荐阅读
- javascript - 检查值是否在数组列表javascript中
- javascript - 如何在前端调用后端错误消息?
- r - 根据R中ggplot中的组为每个多边形着色
- superpower - Superpower:创建解析器以匹配“\r\n”或“\n”(更通用:匹配字符串文字)
- python - 如果熊猫数据框已经有两列,如何将它添加到另一个熊猫数据框?
- c - 我应该像介绍的那样使用 fflush 吗?有什么选择吗?
- python - 有人可以向我解释一下这一行:'\n'.join([f"{n} x {i} = {n*i}" for i in range(1,11)?
- python - 使用 xpaths 抓取 Amazon 表的特定部分时出错
- html - 小于 x 的数字的正则表达式?
- mysql - Keycloak 无法连接到我的 MySQL 数据库