适用于特定用户的Firebase数据库规则 [英] Firebase database rules for particular user
问题描述
我有一个数据库,我需要对所有用户进行读取访问,并且 在用户运行的应用脚本中调用时的写访问权限= 'firebaseowner@gmail.com'
I have a db where I need read access to all users and write access when invoked in an apps script running by the user = 'firebaseowner@gmail.com'
我的Firebase结构是
My firebase structure is
ABC/AAA1/date
ABC/AAA2/date
ABC/AAA3/date
ABC/AAA4/date
规则是:
{
"rules": {
".read": true,
".write": false,
}
}
当用户'firebaseowner@gmail.com'在应用程序脚本中调用时,如何制定允许写入的规则.
How do I make the rule to allow write when invoked by the user 'firebaseowner@gmail.com' in the apps script.
我使用 https://sites .google.com/site/scriptsexamples/new-connectors-to-google-services/firebase/reference 用于插入数据
推荐答案
You should check the auth
variable.
要定义仅允许通过此电子邮件地址firebaseowner@gmail.com
对所有位置进行写访问的安全规则:
To define the security rules that allow write access to all the locations by this email address firebaseowner@gmail.com
only:
{
"rules": {
".read": true,
".write": "auth != null && auth.token.email == 'firebaseowner@gmail.com'"
}
}
要定义仅允许通过此电子邮件地址firebaseowner@gmail.com
仅访问位置/users
的安全规则,请执行以下操作:
To define the security rules that allow write access to only the location /users
by this email address firebaseowner@gmail.com
only:
{
"rules": {
".read": true,
"users": {
".write": "auth != null && auth.token.email == 'firebaseowner@gmail.com'"
}
}
}
这篇关于适用于特定用户的Firebase数据库规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!