User Management

For MongoDB clusters, you must manage users through the IONOS CLOUD API and you cannot create users inside the database. The document shows you in detail how to create, view, and delete users.

Roles

In MongoDB most roles are scoped to a database. For example you grant readWrite permissions on database mydb. The exception are roles that grant permissions to all databases, for example readAnyDatabase.

Assignable roles have several restrictions to avoid customers breaking out of their database or breaking internal stuff:

  • Currently, you can only assign built-in roles. Out of those currently only read, readWrite, readAnyDatabase, readWriteAnyDatabase, dbAdmin, dbAdminAnyDatabase and clusterMonitor are supported.

  • Roles with the suffix *AnyDatabase are granted only on the admin database, which is the main user management database.

  • Roles read, readWrite and dbAdmin cannot be granted on config and local databases.

Add a user

When creating a user you need to consider the following:

  • All users are created in the admin database.

  • The combination of username and database must be unique within the MongoDB cluster.

  • You can only change the assigned roles and the password of a user.

  • You cannot have more than 100 users in a cluster.

To add users to a MongoDB cluster, use the POST request for each user.

Endpoint

Use the following endpoint to add a user: https://api.ionos.com/databases/mongodb/clusters/{clusterId}/users

Note: The sample cluster UUID is 498ae72f-411f-11eb-9d07-046c59cc737e.

Request

Response

Delete a user

To delete a user from MongoDB cluster, use the DELETE request.

Endpoint

To delete a user from MongoDB cluster, use the DELETE request as follows: Use the following endpoint to delete a user: https://api.ionos.com/databases/mongodb/clusters/{clusterId}/users/{username}

Note: The sample cluster UUID is 498ae72f-411f-11eb-9d07-046c59cc737e.

Request

Response

Get all users

To get a list of all users defined in MongoDB cluster, use the GET request.

Endpoint

Use the following endpoint to get all users: https://api.ionos.com/databases/mongodb/clusters/{clusterId}/users

Note: The sample cluster UUID is 498ae72f-411f-11eb-9d07-046c59cc737e.

Request

Response

Get a single user

To get a specific user in a MongoDB cluster, use the GET request.

Endpoint

Use the following endpoint to get a single user: https://api.ionos.com/databases/mongodb/clusters/{clusterId}/users{username}

Note: The sample cluster UUID is 498ae72f-411f-11eb-9d07-046c59cc737e.

Request

Response

Modify a single user

Change the password

To update the password of a specific user in a MongoDB cluster, use the PATCH request.

Endpoint

Use the following endpoint to change the password: https://api.ionos.com/databases/mongodb/clusters/{clusterId}/users/{username}

Note: The sample cluster UUID is 498ae72f-411f-11eb-9d07-046c59cc737e.

Request

Response

Update the roles

To update the assigned roles of a specific user in a MongoDB cluster, use the PATCH request with the new list of assigned roles. Note that the request replaces the old role list, meaning that any existing roles missing from the patch will be deleted.

Endpoint

Use the following endpoint to update the roles: https://api.ionos.com/databases/mongodb/clusters/{clusterId}/users/{username}

Note: The sample cluster UUID is 498ae72f-411f-11eb-9d07-046c59cc737e.

Request

Response

Last updated

Was this helpful?