So the current mongo guide on the wiki is a bit off... and I was able to get the install working up until another issue with the default theme... but more on that in a different bug report.
Authentication worked, but mongo was not letting the user nodebb do anything. This lead me to researching the role 'userAdmin' and I discovered a few things...
- For 'userAdmin' or 'userAdminAnyDatabase' roles to work, you need to have an admin database where these roles should be defined. These roles should ultimately be reserved for administrative users, not a service like nodebb. Also defining these inside another database will have no effect. (which is pretty much what broke the install)
- the role "readWrite" is sufficient for nodebb service. It is also the most secure default role available for a connecting service such as nodebb.
- the wiki assumes the mongo is being installed for the first time. New installs should include the addition of an administrative user under the admin database, otherwise once auth is on, mongo is locked down and would have to be unlocked again for any further administrative work.
- the wiki is also using depreciated commands. addUser is now createUser
Here are the commands I ran after installing mongo:
(mongo shell)
use admin;
db.createUser({ user: "mongoadmin", pwd: "password", roles: ["userAdminAnyDatabase"] });
use nodebb;
db.createUser({ user: "nodebbsvc", pwd: "password", roles: ["readWrite"] });
exit;
then edit /etc/mongo.conf and uncomment "auth=true"
restart mongo service (service mongod restart)
You can test the authentication by loading the mongo shell and typing the following command:
use nodebb;
db.auth('nodebbsvc','password');
It should return a '1';
I hope this helps anyone else having issues with mongo and nodebb.