Ad

How To Write Security Rules Of Firebase-Realtimedatabase So Unauth User Can Read And Write Only At My Specific Nodes

I want to know how we can write firebase realtime database security rules in the way like unauthenticated user can read and write on a specific nodes only

Right now my security rules are like this

 "rules": {
    ".read": "auth != null",
    ".write": "auth != null"
  }

my database structure is like this

 request
   |-user_id
     |-email:"value"

i want that the user can write from my Android app on this node even though he is not logged in using firebase auth

I am developing android app.

 "rules": {
    ".read": "auth != null",
    ".write": "auth != null"
  }
Ad

Answer

I want to know how we can write firebase realtime database security rules in the way like unauthenticated user can read and write on a specific nodes only

To allow unauthenticated users to read/write data on a specific ("request") section in your database, you should use the following rules:

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

For more information, please check the official documentation regarding authorization on a specific section in Firebase realtime database.

Ad
source: stackoverflow.com
Ad