【发布时间】:2017-07-31 14:49:39
【问题描述】:
我有以下数据结构:
cars: {
$uid: {
brand: "Brand here",
model: "Model here etc"
},
$uid: {
brand: "Another brand here",
model: "Another model here etc"
}
}
任何人都可以像这样读取这些数据:firebase.com/cars/uniqueIDHere.json - 它是一个公共 API firebase.com/cars.json - 无法访问。
现在的规则是这样设置的:
"cars": {
"$uid": {
".read": "true",
".write": "auth != null"
}
}
我希望有以下授权规则:只有创建“汽车”的用户才能编辑/删除它。 有了现在的规则,我认为所有登录的用户都可以这样做(如果他们知道汽车的 $uid)。 可以制定哪些规则,以便只有所有者才能“编写”。我知道这样的规则:
"$uid": {
".read": "true",
".write": "auth.uid === $uid"
}
其中 $uid 是用户的 uid,但我不希望这样,因为它将在公共 API url 中公开 我可以采取什么方法?有什么想法吗?
【问题讨论】:
标签: javascript json firebase authorization