🐳 docs: How to Authenticate MongoDB (#1724)

* refactor: remove `--noauth` flag from `mongod` command

* docs: add mongodb auth instructions

* Update manage_your_database.md

* chore: add example

* Update manage_your_database.md
This commit is contained in:
Danny Avila 2024-02-04 16:52:52 -05:00 committed by GitHub
parent e7f6b22b5d
commit 7b38586716
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 324 additions and 1 deletions

View file

@ -40,7 +40,23 @@ services:
restart: always
```
3. **Security Notice:** Before using this configuration, replace `admin` and `password` with a unique username and password for accessing Mongo Express. These credentials should be strong and not easily guessable to prevent unauthorized access.
3. **Security Notice:**
- a. Before using this configuration, replace `admin` and `password` with a unique username and password for accessing Mongo Express. These credentials should be strong and not easily guessable to prevent unauthorized access.
- b. You can also add native authentication to your database. See the [`docker-compose.override` guide](../install/configuration/docker_override.md#mongodb-authentication) for instructions on how to do so
- After following the guide to authenticate MongoDB, you will need these variables under the environment section for mongo-express:
```yaml
environment:
ME_CONFIG_MONGODB_SERVER: mongodb
ME_CONFIG_BASICAUTH_USERNAME: admin
ME_CONFIG_BASICAUTH_PASSWORD: password
# database authentication variables, using example credentials from guide
ME_CONFIG_MONGODB_URL: 'mongodb://adminUser:securePassword@mongodb:27017'
ME_CONFIG_MONGODB_ADMINUSERNAME: adminUser
ME_CONFIG_MONGODB_ADMINPASSWORD: securePassword
```
- c. If using authentication for your database, make sure the admin user has the "clusterAdmin" and "readAnyDatabase" permissions as detailed in the [`docker-compose.override` guide](../install/configuration/docker_override.md#step-1-creating-an-admin-user)
4. Save the `docker-compose.override.yml` file and run the following command from the directory where your `docker-compose.yml` file is located to start Mongo-Express along with your other Docker services: