I'm building a simple sample app that essentially just allows all users to the site to chat with each other, like a chat room. Firebase let's me authenticate users anonymously, which is what I want, since I only want users who are on my app to use it. The following code provides authentication as per Firebase docs:
var ref = new Firebase("https://<your-firebase>.firebaseio.com");
ref.authAnonymously(function(error, authData) {
if (error) {
console.log("Login Failed!", error);
} else {
console.log("Authenticated successfully with payload:", authData);
}
});
That's cool. It works. Great. But here's my question.
What's to prevent someone from simply copying my javascript code from my sources and running their own app against my Firebase? Since the authentication method is on the client side within my app, one can simply copy-paste and start reading and writing onto my Firebase and modifying everything.
I have my rules set in my dashboard as such
{
"rules": {
".read": "auth !== null",
".write": "auth !== null"
}
}
I really am lost as to how secure this really is. I can't use secret tokens since it's all client-side. What am I missing?