Managed MongoDB Credentials
A managed MongoDB on Quave One comes with a root user whose password is
stored in the database environment's env vars. This page explains which
variables you can change, how to change the root password, how to give each
app its own user, and what to do when a password leaks.
Users and variables
Open the database environment and go to Env. vars. You will see these variables:
| Variable | What it is | Can you change it? |
|---|---|---|
DB_USER_ADMIN | Name of the admin user, root by default. | No. Keep the value it was created with. |
DB_PASS_ADMIN | Password of the admin user. | Yes. See Change the root password. |
DB_PASS_QC_ADMIN | Password of qcClusterAdmin, a Quave One user used for monitoring and for query analysis (Slow Queries). It can only monitor and manage the cluster, and it cannot read or write your data. It is separate from the root password. | No. Leave it as is. |
VERSION | MongoDB version the database runs. Not a credential. | Leave it as is when you change passwords. |
Quave One also creates internal users for monitoring and, when it is enabled, MongoDB Search. They are managed for you and you do not need to touch them.
Quave One manages these users: the values in Env. vars are the source of
truth. Users you create yourself with createUser are yours. Quave One does
not change or remove them.
Change the root password
- Open the database environment, go to Env. vars, and edit
DB_PASS_ADMIN. - Click Apply changes.
Quave One updates the password of the root user inside MongoDB. Connections
that log in with the old password are refused after that.
Applying a new DB_PASS_ADMIN restarts the database members, like other
changes that redeploy the database. A database with one member is
unavailable for a few minutes (2 to 5 minutes in our tests),
and every app connected to it loses its connection until it comes back. With
more than one member, the members restart one at a time.
Plan the change for a time with little traffic, or give each app its own user first (next section) so that no app has to change its settings during the restart.
Do not change the root password from a MongoDB client, for example with
db.changeUserPassword('root', ...). Quave One sets the password back to the
value in DB_PASS_ADMIN within seconds. Always change it in Env. vars.
Create a user per app
Your apps should not connect as root. Give each app its own user with access
only to its own database. If one app's password leaks, only that database is
exposed, and you can change the root password without touching the apps.
-
Connect to the database as
root. The connection string is in the Hosts tab of the database environment. Clients outside Quave One need the Quave One Root CA. -
Create one user per app in the
admindatabase, withreadWriteon the app's database:use admin
db.createUser({
user: 'my-app',
pwd: passwordPrompt(),
roles: [{ role: 'readWrite', db: 'my_app_db' }],
})readWritelets the app read, write and create indexes onmy_app_db, and nothing else. Creating the user inadminkeepsauthSource=adminin the connection string valid. -
In the app environment, update the connection string env var (for example
MONGO_URL) to use the new user. Change only the user and the password and keep the rest of the URL:mongodb://my-app:<password>@<hosts from the Hosts tab>/my_app_db?authSource=admin&ssl=true&replicaSet=<replica set>If the password has characters such as
@,:or/, URL-encode them. -
Click Apply changes on the app and check that it starts and reads its data. Do one app at a time.
Users you create keep working across restarts and root password changes.
Change an app user's password
App users are not managed by Quave One, so you change them from a MongoDB client, and the database does not restart. To avoid any login failures, replace the user instead of changing it in place:
- Create a new user for the app, for example
my-app-2, as in Create a user per app. - Switch the app's connection string to the new user and apply.
- Once the app runs on the new user, remove the old one with
db.getSiblingDB('admin').dropUser('my-app').
If a password leaks
-
Give each app its own user if they still connect as
root(see Create a user per app). This avoids any app settings change during the restart. -
Change the leaked password. For root, edit
DB_PASS_ADMINand apply, at a time with little traffic if the database has one member. For an app user, follow Change an app user's password. -
Check. Try to connect with the old password. It must be refused. Then look at who is connected:
db.getSiblingDB('admin').aggregate([
{ $currentOp: { allUsers: true } },
{ $group: { _id: '$effectiveUsers.user', connections: { $sum: 1 } } },
])Only your app users should appear, plus the Quave One internal users.
-
Limit who can reach the database. If only your apps on Quave One use the database, connect them through the internal host in the Hosts tab and restrict the external host with the IP allowlist.
If you need help with any of these steps, contact support.