Reputation: 768
assume we have a banking app with a firebase backend. We can see our current balance and we can add a transaction.
Now from coding perspective:
If we add a transaction we need to adjust the account balance. As this is security relevant (we do not want someone to manipulate the frontend and adjust the account balance) we only add the transaction and let the backend (firebase cloud function) execute it.
But now the account balance (the ui) will be unresponsive until the backend added the transaction and synched it to the frontend leading to a bad user experience.
Expected behaviour: An added transaction directly reflects to the account balance.
How to workaround this issue?
I have multiple ideas in my mind:
Note: I do not think this is an opinion based question. I think there are standard ways of doing such things thus I think this question is legit.
Any help appreciated
EDIT: It is not actually a banking app. This is an easy example to demonstrate the problem. The target application needs way less security then a banking app, still the issue stays
Upvotes: 0
Views: 87
Reputation: 920
the thing with working directly with firebase as "back end" is that sometimes it's hard to separate responsibilities between front and back, leading to security issues.
The most important element is that you must NEVER trust just your user input, and have clear layer isolation, one way to achieve this could be to handle your transactions using cloud functions so you only read data from your client code (also add some security so you are 100% no remote client is changing data), and run transactions through functions.
Upvotes: 1