简体   繁体   中英

Firebase - How to set security rules so that only logged in users can read and write?

Firebase - How to set security rules so that only logged in users can read and write for a specific table?

For the logins I'm using firebase built in authentication.

You can check on the auth variable

{
  "rules": {
    "posts": {
      "$post_id": {
        ".write": "auth != null"
      }
    }
  }
}

Check out the Firebase Security Guide for more information.

Also, you may want to check out the Bolt compiler.

by changing the rules as follows

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if request.auth != null;
    }
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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