Restricting MongoDB access by enabling authentication
Follow this procedure for a stand-alone environment only (not when running MongoDB as a replica set).
Video demonstration
The following video (4:10) demonstrates how to restrict MongoDB access by enabling authentication and store the encrypted MongoDB password in the configuration file:
To restrict MongoDB access by enabling authentication
Log on to the MongoDB shell and enter the following commands:
use admin
db.createUser( {
user: "siteUserAdmin",
pwd: "<siteUserAdminPassword>",
roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
});
use social
db.createUser( {
user: "social_admin",
pwd: "<social_adminPassword>",
roles: [ { role: "dbOwner", db: "social" } ]
});- Enable authentication by using either of the following methods:
- Start the mongodprocess by using the --auth option.
- In the mongoconfiguration, set auth = true and restart the mongo service.
To connect the BMC Digital Workplace or Smart IT social service to mongo, change config.js in Smart_IT_MyIT/social to use the following value:
Original value
New value
mongodb://social_admin:social_adminPassword@ipAddress:portNumber/
- Restart the social service.
Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*