是否可以在Firebase中向孩子添加密码?
问题描述:
我正在为用户可以加入和创建的频道创建一个空间。但是,我希望用户给出一个选项来为他们创建的频道添加密码。现在我想知道是否可以在加密的Firebase中添加密码。当然,一种选择是将密码作为正常值上传到Firebase中的字符串中,但任何人都可以读取(因为.read规则为真)。这样,任何人都可以看到不是我想要的密码。所以我的问题是:这是可能的,如果是的话:如何?以下是一些可能有所帮助的代码。是否可以在Firebase中向孩子添加密码?
创建频道IBAction为功能:
@IBAction func createChannel(_ sender: AnyObject) {
if let name = newChannelTextField?.text {
let newChannelRef = channelRef.childByAutoId()
let channelItem = [
"name": name
]
newChannelRef.setValue(channelItem)
}
}
Channel.swift:
internal class Channel {
internal let id: String
internal let name: String
init(id: String, name: String) {
self.id = id
self.name = name
}
}
有勾选细胞功能:
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
{
if indexPath.section == Section.currentChannelsSection.rawValue
{
if searchController.isActive && searchController.searchBar.text != ""
{
let channel = filteredChannels[(indexPath as NSIndexPath).row]
sendStatisticsToChannel(channel: channel)
}
else
{
let channel = channels[(indexPath as NSIndexPath).row]
sendStatisticsToChannel(channel: channel)
}
}
}
答
不,除非你有一个服务器端的检查密码或您在Firebase规则中公开密码。原因是为了检查用户是否输入了正确的密码,必须根据实际密码进行检查。如果他们可以检查实际的密码,那么他们可以读取它开始。加密也是一样。如果一切都在客户端完成,那么有人可能会改变流程。
好的,谢谢。你有什么想法如何做到这一点在设备上?是否有加密扩展?谢谢! – Petravd1994
我不确定你在使用什么设备,但最有可能的情况是,如果你的加密算法在用户设备上可以被破坏。您将需要一台服务器来使用加密或密码。你有没有考虑另一种方法? –