How to Configure MongoDB Atlas IAM Authentication
You set up mongodb atlas iam authentication by linking your cloud roles to database users. The database then checks your cloud identity before it lets you log in. Teams often use this setup to get rid of static passwords in their apps. They create one cloud role and attach it to a broad database role. When that role has too much power, any person using it can change or delete production data. How mongodb atlas iam authentication works This login method replaces standard passwords with cloud i
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 set up mongodb atlas iam authentication by linking your cloud roles to database users. The database then checks your cloud identity before it lets you log in. Teams often use this setup to get rid of static passwords in their apps. They create one cloud role and attach it to a broad database role. When that role has too much power, any person using it can change or delete production data.
How mongodb atlas iam authentication works
This login method replaces standard passwords with cloud identity tokens. Your app or user asks the cloud provider for a temporary login token. The client sends this token to the database cluster during the login step. The cluster checks the token against the cloud identity service to confirm who you are. Once the check passes, the database looks up the matching internal user record.
Every cloud identity maps to one or more database roles inside the cluster. MongoDB grants access through these roles on specific databases and collections. A role defines the exact actions a user can run on a resource. You can scope these rules down to a single collection in a database. Atlas database users have their own built-in roles made from standard privilege actions.
Most teams pick between the built-in read role and the readWrite role. The read role lets a user run find and listCollections on non-system collections. It also allows listIndexes, dbStats, collStats, and changeStream actions on that database. It blocks insert, update, remove, and dropCollection actions. The readWrite role adds the power to insert, update, and remove data. It also lets users create or drop collections and indexes.
What native cloud login solves and what it misses
Linking cloud identities to database roles solves the problem of shared static passwords. Engineers no longer need to store long-lived database secrets in config files. When someone leaves the team, you disable their cloud account in one place. Their database login stops working right away without a password rotation.
Yet this setup only decides who can open a session to the cluster. It does not inspect what individual queries do once the session starts. A role grants the same power for the whole life of the login. If an engineer needs to fix one record, they often get the readWrite role. That role also lets them run dropCollection or remove all rows by mistake by default.
MongoDB Authentication & Authorization + Service-to-Service Authentication: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Database roles also operate down to the collection level, not the field level. A user with the read role on a customer collection can read every field. If those documents hold emails, phone numbers, or card numbers, the query returns them all. Native roles cannot rewrite matched fields in query results on the fly. They also cannot pause a single dangerous command for peer approval before it runs.
Scoping database roles for daily work
To reduce risk, split human roles from app roles in your cloud account. Give your apps custom roles that only touch the collections they need. Avoid giving the readWrite role across an entire database when one collection will do. Keep human users on read roles for daily checks and debugging work.
Even with tight roles, teams still need to run data fixes in production. When you grant higher roles for a task, you open a wide window of risk. You also lack a clear log that ties each query to a person. Teams need a way to control single statements and mask sensitive fields in results.
Check MongoDB commands and documents on the wire
MongoDB roles and SCRAM login decide who opens a session. They do not check single commands or redact sensitive fields inside returned documents. With hoop.dev, you run an open-source proxy, a sidecar for your MongoDB, inline in the MongoDB wire protocol. On every command an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.
Before a command runs, hoop.dev guardrails check its effect and refuse banned drops or writes with MongoDB error code 13, or hold risky commands for approval. On the way back, hoop.dev data masking rewrites sensitive fields in returned documents in memory, and every verdict is logged. See the open-source code on GitHub.
Frequently asked questions
Does mongodb atlas iam authentication replace database roles?
No, it only handles the login check at the start of a session. You still must assign MongoDB roles to decide what data the user can read or write.
Can the built-in read role hide sensitive fields like emails or card numbers?
No, MongoDB roles work down to the collection level. If a user can read a collection, their find queries return every field in those documents.
What is the main risk of giving engineers the readWrite role through IAM?
The readWrite role includes dropCollection, remove, and dropIndex actions. An engineer who only needs to update one document could drop a whole collection by mistake.
Related guides
In this post