I’m beginning to design a RESTful API utilizing Node.js, Express, and MongoDB. This API will serve data for both a public and private section of a website, with potential future use in a mobile application. The frontend will be constructed using AngularJS.
I’ve spent several days researching methods to secure RESTful APIs, but I haven’t reached a conclusive approach. I understand that implementing HTTPS is crucial for basic security. However, I need guidance on safeguarding the API for the following scenarios:
- Restricting data access for the public section of the website/application to only visitors or users.
- Ensuring that only authenticated and authorized users can access data in the private section, specifically information for which they have received permission.
Currently, I consider permitting access to the API only for users with an active session. I plan to employ Passport for user authentication and will need to develop my own system for managing permissions, alongside enforcing HTTPS.
Could anyone share best practices or personal experiences regarding this? Is there something I might be missing in my design?