Through this part of the MongoDB tutorial you will learn about the security aspects of MongoDB, how to secure a database like enabling firewall, ensuring role-based authentication and authorization, using SSL and so on.
1.7 K Views
How does security in MongoDB work?
Security of data is paramount and therefore it is very much important to exercise control over access to the database. Though there is a long list of ways in which you can do this, but some of the important tips to help you secure your data are mentioned below :
Do not connect your DB to the Internet – Restrict the access to your database and do not connect it to internet if not required. It will protect your database from being hacked.
Enable firewall – You can restrict the entities from accessing your MongoDB server by enabling powerful firewalls. For your benefit allow the application servers to access the database. Different platforms allow diverse measures for securing the database. For more information check the MongoDB documentations and refer to the scenario that matches with yours.
Enable authentication – One of the best options is to deploy the MongoDB server on a trusted network. For better results configure auth as true. See below: auth = true.
Role-based authorization – you can control the activities of individual users by enabling role-based authentication. Instead of giving admin access to all the users, role-based authentication restricts the illegal access and protects the database at the end.
Use SSL – Until and unless you enable SSL the data is left unencrypted and prone to unauthenticated access. Hence if the MongoDB server is deployed on a untrustworthy network, enabling SSL is the best way to secure your database.