Search code examples
firebasefirebase-securityfirebase-authentication

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.


Solution

  • 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.