Restricting Firebase read/write access to only myself

后端 未结 2 1674
粉色の甜心
粉色の甜心 2020-12-19 07:45

I have a static website which runs:

config =
  apiKey: \"HIDDEN\"
  authDomain: \"HIDDEN\"
  databaseURL: \"HIDDEN\"
  storageBucket: \"\"

firebase.initiali         


        
2条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-19 08:04

    The rules in your question would allow any authenticated user to read and write to any key in the database. If you wish, for development purposes, to configure a single user and restrict access to only that user, you could use the following rules:

    {
      "rules": {
        ".read": "auth !== null && auth.uid === ''",
        ".write": "auth !== null && auth.uid === ''"
      }
    }
    

    Where is the User UID for the user with which you wish to sign in - you can find it on the Firebase console under Auth (where you can also create a user, if you have not already done so).

    Typically, Firebase would be configured so that users could create accounts and finer-grained rules would be used to give users read and write access to specific parts of the database.

提交回复
热议问题