Restrict user requests based on IP addresses

Hello Community,

In a project, I need to add a security layer to restrict user requests based on IP addresses. The IP addresses differ between two users and whitelist will by same on user.

My challenge is that I’m unsure where to place my code to check the IP for:

  • User login,
  • Retrieving and saving data,
  • Cloud code.

I can use hooks, but that would mean I’d have to repeat my code for each of the parts mentioned above.

Do you have any advice?

Would using an authentication provider solve my problem?

Thank you very much.


I’m using middleware for this situation , I recommend middleware using, because you can implement a custom middleware function in your Parse Server’s Express.js app to check the user’s IP address on every incoming request. This middleware can be placed at a central location to handle IP checks. By using a single middleware, you avoid code repetition.