I have a rest api and this is the end point:
app.post('/Follow/:myUserId/:userId', async (req, res))
authorization is activated by this example: https://github.com/firebase/functions-samples/blob/master/authorized-https-endpoint/functions/index.js
everything works as expected, but I have the doubt that if someone who is already authenticated with firebase and gets user ids can call that endpoint and "fake followers".
Suppose that the Id: 12121 (myUserId) is authenticated and starts calling that endpoint and passes it the id 4444 (myUserId) and 5555 (userId)
the user can be accessed through req.user
in the rest call, it would be enough to put this in my endpoint:
app.post('/Follow/:myUserId/:userId', async (req, res) => {
if (req.user.Id !== myUserId) {
res.status(403).send('Unauthorized');
return null;
}
});
This would fix, or is it better to do database triggers?