Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Database, Cloud Functions, Rules

How to restrict write access to /lastmodified table in database named /functions-project-12345 only to cloud function, read & write access to table /chat to everyone

/functions-project-12345
    /lastmodified: 1234567890
    /chat
        /key-123456
            username: "Mat"
            text: "Hey Bob!"
        /key-123457
            username: "Bob"
            text: "Hey Mat"
like image 344
Isaak Osipovich Dunayevsky Avatar asked Jun 25 '26 08:06

Isaak Osipovich Dunayevsky


1 Answers

Cloud Functions run with administrative privileges, which means they bypass the security rules of your database. Knowing that, it is quite simple to secure the database to your requirements:

{
  "rules": {
    ".write": false,
    "chat": {
      ".write": true
    }
  }
}
like image 65
Frank van Puffelen Avatar answered Jun 28 '26 17:06

Frank van Puffelen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!