Database
...
MongoDB
Examples of authorization sett...

Setting up authorization in Linux

9min

Connecting and creating a user in MongoDB

Connection to shell

Connect to the MongoDB shell:

Shell


Creating a user

Switch to database — admin:

Shell


Create a user by changing the Login (user) and Password (pwd) of the user:

Shell


In MongoDB, you cannot use the characters — .,@,$,:,%,",',/,\,| in the username and password, as this can cause failures and connection of the application server to MongoDB.

If a MongoDB replica set is used, you must add the cluster manager role to the user:

Shell


Enabling authorisation and connecting Passwork

Enabling authorization in MongoDB

You need to edit the MongoDB config file to enable authorisation, run the following commands in the shell to get the location:

Shell


Edit the resulting configuration file by adding a line:

Shell


Save the changes and restart the MongoDB service:

Shell


To test, connect to the shell with authorisation:

PowerShell


Setting up and connecting Passwork with authorization

You need to edit the Passwork configuration file — /var/www/app/config/config.ini section [mongo] specifying the login (user) and password (pwd) of the created user:

Shell


Save the changes and refresh the Passwork web interface page to test the connection with MongoDB authorisation.