简体   繁体   English

如何在 Firebase 中授予完全读写权限

[英]How to give full read and write permission in Firebase

{
    "rules": {
        ".read": "true",
        ".write": "true"
    }
}

Please mention complete code that I have to put in the Rules section of Firebase since I am facing error while entering the above code.请提及我必须放入 Firebase 规则部分的完整代码,因为我在输入上述代码时遇到错误。

If you are using firebase then the rules below apply as an example, for firestore the rule structure is a little different.如果您使用的是 firebase,则以下规则作为示例适用,对于 firestore,规则结构略有不同。

To change the rulles you can go to the firebase project area Database on the left menu and then rules on the blue menu.要更改规则,您可以转到左侧菜单上的 firebase 项目区域数据库,然后转到蓝色菜单上的规则。

However I need to mention that if you are doing a firebase deploy you WILL OVERWRITE these rulles with the contents of database.rules.json that is in your top level for firebase project structure and firestore.rules for firestore.但是,我需要提及的是,如果您正在进行 firebase firebase deploy您将使用database.rules.json的内容覆盖这些规则,该内容位于您的 firebase 项目结构的顶层和firestore.rules的 firestore。

{
"rules": {
    ".read": true,
    ".write": "auth != null",
    "FirstlevelNode_1": {
        ".read": "auth != null",
        ".write": "auth.uid == 'NyEFUW2fdsbgv3WRQRHl4K4YWTxf17Dgc2' || auth.uid == '34x5KfLnk4fgyrjMtvvanb4VSypenBC83'"
    },
    "FirstlevelNode_2_with_children": {
        ".read": true,
        ".write": "auth.uid == 'NyEFUWv3WRQRHl4K4YWTdsfdxf17Dgc2' || auth.uid == '34x5KfLnk4Mtvvanb4VSypfdsahenBC83'",

        "SecondLevelNode_1": {
            "$uid": {
                ".read": true,
                ".write": "$uid === auth.uid || auth.uid == 'NyEFUWv3WRQRHlddsfsadsa4K4YWTxf17Dgc2' '"
            }
        },
        "SecondLevelNode_2": {
            "$uid": {
                ".read": "$uid === auth.uid",
                ".write": "$uid === auth.uid "
            }
        }

    }
}

} }

Readhere 在这里阅读

// Allow read/write access to all users under any conditions
// Warning: **NEVER** use this rule set in production; it allows
// anyone to overwrite your entire database.
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if true;
    }
  }
}
{
  "rules": {
    ".read": "auth != null",
    ".write": "auth != null"
  }
}

But this is not secure.但这并不安全。 Firebase say that "Your security rules are not secure. Any authenticated user can steal, modify, or delete data in your database." Firebase 说“您的安全规则不安全。任何经过身份验证的用户都可以窃取、修改或删除您数据库中的数据。”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM