I am trying to set up a Firebase database that only I can write. So no user will have permission to write anything. But everyone will be able to read it.
However, I could not set up the rules for it. I have one admin user that I created using Email/Password login, and I know its UID. Let's say my UID is: dJrGShfgfd2
I tried these two methods, but they didn't allow me to write to database.
{
"rules": {
"events": {
".read": true,
".write": "auth.uid === 'dJrGShfgfd2'"
}
}
}
.
{
"rules": {
"users": {
"$user_id": {
".read" : true,
".write": "$user_id === 'dJrGShfgfd2'"
}
}
}
}
So how do I allow only one user with a specific UID to write anything to database?
events
path for the admin and read access for others. – cartantevents
in your rules hierarchy. If there is no such key in the database, remove it and move the.read
and.write
up underrules
. – cartant