I'm looking into authentication for Firebase Realtime database and have a few questions which I cannot seem to find an answer for.
We have a Firebase realtime database consisting of a bunch of data which should be accessible for all our users. however, it should only be accessible through our mobile applications and preferably without the need for user registration and login. The users are not going to write to the database, it is only the reading part we are worried about. We do not want someone "copying" our entire database through a script/application.
This question is quite similar to Restrict Firebase database access to one Android app and Firebase Read Only With No Authentication from App. In those discussions, it is suggested to use anonymous authentication https://firebase.google.com/docs/auth/web/anonymous-auth.
If I understand anonymous authentication correctly, it will not solve the issue. Anyone could connect to the same Firebase url from their own script/application with the use of Firebase SDK and just sign in anonymously. This will allow them to read all our data.
Even with the integration of user login e.g. Facebook or Google, our data will still be at great risk of being compromised. Anyone could create a user in our application. Afterwards they could create their own Firebase script/application and connect to our database with that user and retrieve the data.
The discussion Restrict Firebase database access to one Android app talks about possible solutions for restricting access to only the mobile application. This could be done by either using an API key or username/password combination for the app. This would then either be hard coded in the app or send through a service. As stated in the discussion, hard coding seems both hacky and insecure due to decompilation and it will be hard to update in the future if the username/password combination should change for some reason. Sending the API key through a service is also insecure since anyone could request the service from the outside. As mentioned in How to prevent other access to my firebase, there is no way to protect the url.
Is this achievable or am I missing something?