MongoDB Atlas User Permissions

Published
Length
3 min read

Luis Felipe Dias

All posts

You control mongodb atlas user permissions by assigning built-in or custom roles to database users. Each role defines the exact actions a user or app can run on specific databases and collections. Teams use these roles to separate read traffic from write traffic in production. Clear role boundaries stop accidental drops and keep data safe during daily work. How mongodb atlas user permissions work in practice MongoDB uses role-based rules to control who can do what inside a database. A role p

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You control mongodb atlas user permissions by assigning built-in or custom roles to database users. Each role defines the exact actions a user or app can run on specific databases and collections.

Teams use these roles to separate read traffic from write traffic in production. Clear role boundaries stop accidental drops and keep data safe during daily work.

How mongodb atlas user permissions work in practice

MongoDB uses role-based rules to control who can do what inside a database. A role pairs a set of allowed actions with a target resource. A role works on the database where you define it. It can grant access down to the collection level. Cloud database users have different built-in roles than self-hosted users. Both rely on the same base privilege actions.

Two common roles are the read role and the readWrite role. The read role lets a user read all non-system collections in a database. It also covers the system JavaScript collection. It allows actions like finding documents, listing collections, and checking index or database stats. It also allows opening a change stream. It does not allow inserting, updating, removing, or dropping collections.

The readWrite role includes every action in the read role plus data changes. Users with this role can insert, update, and remove documents. They can also create or drop collections and indexes. Engineers and AI agents rely on these roles when they run queries or fix bugs.

Security tradeoffs of static roles and active sessions

Role-based rules stop unauthorized actions at the database layer. A user with the read role cannot drop a collection or delete rows. Still, collection-level roles do not filter the fields inside a returned document.

When an engineer or AI agent runs a find query, the database sends the whole document. That document often holds sensitive fields like emails, phone numbers, card numbers, or national IDs. Static database credentials also stay active until someone rotates or deletes them. If a team shares a readWrite login for debugging, every query in that session carries full write power.

User Provisioning (SCIM) + MongoDB Authentication & Authorization: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Teams also face limits when they manage many databases across cloud clusters. Granting broad roles makes setup fast, but it widens the blast radius of a bad command. Creating custom roles per collection takes time and adds work whenever schemas change. Security teams must balance strict role setup with fast daily debugging.

Separating human access from app credentials

Apps need steady roles to run constant workloads without breaking. Human engineers and AI tools have very different access needs. Humans usually need short read access to check a bug or run one fix. Giving a human a permanent readWrite account creates lingering risk.

A better pattern links database sessions to your single sign-on identity provider. Instead of handing out passwords, you check every query before it hits the cluster. You can require peer approval for write actions while letting read queries pass right through. Adding data masking in transit rewrites matched fields like emails or card numbers in query results. This approach keeps collection roles simple while protecting raw fields during live sessions.

Add command guardrails and field masking beside MongoDB

Collection roles and IP rules control who connects to MongoDB. Yet an active client or agent session can still run a pipeline that writes data or reads raw personal fields. In practice, hoop.dev sits inline in the wire protocol beside your database as a sidecar for your MongoDB. For every command an agent or human sends in production, hoop.dev decides to pass, mask, block, or escalate it for review.

Using hoop.dev MongoDB controls, guardrails refuse banned commands before they run or hold risky calls for approval, and data masking rewrites matched fields in returned documents in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and generates evidence for GDPR, HIPAA, and PCI DSS programs. View the project on GitHub.

Frequently asked questions

What is the lowest level of access for a MongoDB role?

A role applies to the database where you define it and can control access down to the collection level. Built-in roles do not restrict access to specific fields or single documents on their own.

What is the difference between the read and readWrite roles?

The read role lets users view non-system collections, list indexes, check stats, and watch change streams. The readWrite role adds actions to insert, update, and remove data, plus create or drop collections and indexes.

Do read-only roles hide sensitive fields like emails or card numbers?

No, a read role returns the full document from any allowed collection. To hide emails, phone numbers, card numbers, or national IDs, you must apply data masking to rewrite matched fields in the results.

The query runs. The emails stay hidden.