The principle of least privilege (PoLP) means giving each user, application, or system only the access needed for its tasks. Limiting permissions reduces accidental or intentional misuse and the potential damage from errors or breaches. section 20.3.1
Start with the task, then choose the narrowest appropriate access:
- For a user who only reads one database, grant read access to that database—not write or administrative access. section 20.3.1 section 20.3.3
- For a backup service, grant access only to the databases it backs up. section 20.3.1
- Use a custom role when a built-in role permits more than the task requires. Custom roles can restrict actions to particular collections. section 20.3.3
Apply PoLP both to permissions in Atlas and to roles within MongoDB databases. An atlasAdmin database user has broad administrative privileges, so it is not a default choice for every user. Dedicated users or service accounts for each application keep permissions isolated and make actions easier to track. section 2.4 section 20.8
atlas customDbRoles create customReadUpdateRole \ --privilege 'UPDATE@sample_training.routes' \ --privilege 'FIND@sample_supplies.sales'
This Atlas CLI command creates a custom database role with UPDATE on sample_training.routes and FIND on sample_supplies.sales, illustrating permissions tied to specific actions and collections. section 20.3.3
Check role scope as well as permitted actions. A role created in the admin database is available across databases; a role created in a particular application database is valid only there. Choose the scope that matches the task. section 20.3.3
















