Rao Touseef Ahmad
Rao Touseef Ahmad

Reputation: 23

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"
  }

Upvotes: 1

Views: 124

Answers (1)

Alex Mamo
Alex Mamo

Reputation: 138824

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.

Upvotes: 0

Related Questions