Firebase 安全规则正确格式
Firebase Security Rules Correct Format
这些规则的格式是否正确?当我将它们放入数据库规则时,我看到可能表示 error/warning 的红色虚线,但是当我将鼠标悬停在它上面时,我没有收到任何反馈。
{
"rules": {
"users": {
"$uid": {
// grants write access to the owner of this user account whose uid must exactly match the key ($uid)
".write": "auth !== null && auth.uid === $uid",
// grants read access to any user who is logged in --&& auth.provider === 'password'
".read": "auth !== null"
}
},
"usernames": {
"$userName": {
// grants write access to the owner of this user account whose uid must exactly match the key ($uid)
".write": "root.child('usernames').child($userName).child('uid').val() == auth.uid || root.child('usernames').child($userName).child('uid').val() == null",
// grants read access to any user who is logged in --&& auth.provider === 'password'
".read": "auth !== null"
}
},
"following": {
"$uid": {
// grants write access to the owner of this user account whose uid must exactly match the key ($uid)
".write": "auth !== null && auth.uid === $uid",
// grants read access to any user who is logged in --&& auth.provider === 'password'
".read": "auth !== null"
}
},
"followedBy": {
"$fid": {
"$uid": {
// grants write access to the owner of this user account whose uid must exactly match the key ($uid)
".write": "auth !== null && auth.uid === $uid",
// grants read access to any user who is logged in --&& auth.provider === 'password'
".read": "auth !== null"
}
}
}
}
}
这是我看到的:
我也看过那些。几乎只要我添加一个空行。
我认为空行只是导致出现错误指示器。
因为什么都没有失败(至少在我看来对我来说不是),我不会担心他们。
重新格式化您的代码规则并使其可读
只需复制您的规则,然后转到 JS cleaner 并单击 claen Js 重新复制并粘贴到您的数据库规则中
这些规则的格式是否正确?当我将它们放入数据库规则时,我看到可能表示 error/warning 的红色虚线,但是当我将鼠标悬停在它上面时,我没有收到任何反馈。
{
"rules": {
"users": {
"$uid": {
// grants write access to the owner of this user account whose uid must exactly match the key ($uid)
".write": "auth !== null && auth.uid === $uid",
// grants read access to any user who is logged in --&& auth.provider === 'password'
".read": "auth !== null"
}
},
"usernames": {
"$userName": {
// grants write access to the owner of this user account whose uid must exactly match the key ($uid)
".write": "root.child('usernames').child($userName).child('uid').val() == auth.uid || root.child('usernames').child($userName).child('uid').val() == null",
// grants read access to any user who is logged in --&& auth.provider === 'password'
".read": "auth !== null"
}
},
"following": {
"$uid": {
// grants write access to the owner of this user account whose uid must exactly match the key ($uid)
".write": "auth !== null && auth.uid === $uid",
// grants read access to any user who is logged in --&& auth.provider === 'password'
".read": "auth !== null"
}
},
"followedBy": {
"$fid": {
"$uid": {
// grants write access to the owner of this user account whose uid must exactly match the key ($uid)
".write": "auth !== null && auth.uid === $uid",
// grants read access to any user who is logged in --&& auth.provider === 'password'
".read": "auth !== null"
}
}
}
}
}
这是我看到的:
我也看过那些。几乎只要我添加一个空行。
我认为空行只是导致出现错误指示器。
因为什么都没有失败(至少在我看来对我来说不是),我不会担心他们。
重新格式化您的代码规则并使其可读 只需复制您的规则,然后转到 JS cleaner 并单击 claen Js 重新复制并粘贴到您的数据库规则中