Firebase Database Security Rules - SK PROJECT HIVE BLOG

Firebase Database Security Rules


 


Hello Guys Welcome To SK PROJECT HIVE BLOG.
Our Today's Topic Is Firebase Real Time DataBase Security Rules.

If You Need To Connect Your App Or Website To Firebase And You Don't Know About Firebase Database Security Rules So  Don't Worry In This Blog I Will Cover All Of Basic Security Rules About Firebase Database. So Let's Start...


Server Close

Our 1st Topic Is Server Close Or Lock Mode


With This Security Rules You Can Close Your Database Or Lock It

If You Need To Close Your Database In Emergency Situation . And You Don't Added This Feature In Your App Then This Rules Will Help You.

{

 “rules”: {

 “.read”: false,

 “.write”: false

 }

}



Server Open

This Code Will Help You To Input Data In Database


If You Went Input Data In Your Database This Code Will Help You. 

With This Code Any One Can Write Data And Read Data



{

 “rules”: {

 “.read”: true,

 “.write”: true

 }

}



Only Login User

With This Code Any Login User Can Write And Read Data


If You Add Login And Sign-up Feature In Your App And Website And You Need Only Sign-up And Login User Can Read And Write Data So This Code For You



{

 “rules”: {

 “.read”: “auth != null”,

 “.write”: “auth != null”

 }

}



Verifyed User Only

Only Email Verifyed User Can Write And Read Data


If You Added Email Verification System In Your App And Website And You Need Only Can Verifyed Email User Can Write Data And Read Form Your Database This Code Will Help You


{
  "rules": {
    "users": {
      "$uid": {
        ".read": "$uid === auth.uid",
        ".write": "$uid === auth.uid"
      }
    }
  }
}

Only user can read & write his own data


{

  "rules": {

    "posts": {

       "$uid": {

         ".read": "$uid === auth.uid",

         ".write": "$uid === auth.uid"

       }

     }

   }

}




Only Admins can read & write the data

{

 "rules":{

   "announcements":{

    ".read": true,

    ".write": "root.child('badges/admin/' + auth.uid).exists()"

        }

    }

}



Only Particular User can write

{

 "rules":{

    ".read": true,

    ".write": "auth.uid == 'pasteYourUID' "

      }

}

Only Users having verified emails can write

{

"rules":{

    ".read": true,

    ".write": "auth.token.email_verified === true"

}

Getting Info...

إرسال تعليق

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.