I intend to use Firebase Queue to push tasks for registering a user using his/her mobile number like Whatsapp for a mobile application. I am using a third party service to verify a user's mobile number. The verification process is a two step process
- Send the user's mobile number to the third party service which returns back a request_id and sends a code to the user's mobile via SMS
- Send the request_id and code entered by the user and verify it
This is like the first thing that I would do when the user open the mobile app for the first time after installing. Since the user is not even registered yet, there is no auth data for the user.
I want to ask what kind of security rules can I add to the firebase queues so that no outsider can add/remove tasks to the firebase queues.
I can also expose APIs on the server directly which the mobile app can use to perform the above verification but I am thinking that if there is a way to add some security rules to the firebase queues for such a scenario case also, then I would rather have the mobile app talk to only firebase.
I have created the following sample code 1.Queue worker 2.Client
Currently, anyone who knows my app location can add a task to the queue. Since, the user has not been authenticated yet, I cannot add any auth specific security rules to firebase. I was thinking of shipping the mobile app with an application secret and have something like this for the security rule for the firebase queue
{
"rules": {
"queue": {
"tasks": {
".write": "newData.appSecret === <appSecret>"
}
}
Here <appSecret>
is what is shipped with the mobile app and each new task also contains the appSecret in it. Now, only clients who know the appSecret can add tasks to the firebase queue.