Connections

Authentication

Configure MongoDB authentication methods in Sutido.

Overview

Sutido supports multiple authentication methods to connect to your MongoDB databases securely. Choose the method that matches your database configuration.

Authentication Methods

No Authentication

For local development environments where authentication is disabled. Not recommended for production databases.

mongodb://localhost:27017

SCRAM-SHA-256

The recommended authentication mechanism for MongoDB 4.0 and later. Uses salted challenge-response authentication with SHA-256 hashing.

mongodb://user:password@localhost:27017/mydb?authMechanism=SCRAM-SHA-256

SCRAM-SHA-1

Legacy authentication method. Use this for older MongoDB deployments or when required for compatibility.

mongodb://user:password@localhost:27017/mydb?authMechanism=SCRAM-SHA-1

Authentication Configuration

Required Fields

Field Description
Username Your MongoDB username
Password Your MongoDB password
Auth Database The database containing user credentials (usually "admin")

Auth Database

The authentication database is where your user account is stored. This is typically:

  • admin - For users with cluster-wide access
  • A specific database - For users limited to that database

Common Issue: If authentication fails, double-check the auth database. Most MongoDB deployments store users in the admin database.

Password Security

Sutido stores your passwords securely using your operating system's native credential storage:

  • Windows: Windows Credential Manager
  • macOS: Keychain (coming soon)
  • Linux: Secret Service API (coming soon)

Passwords are never stored in plain text configuration files.

Creating MongoDB Users

To create a user in MongoDB, connect with admin privileges and run:

use admin
db.createUser({
  user: "myuser",
  pwd: "mypassword",
  roles: [
    { role: "readWrite", db: "mydb" },
    { role: "read", db: "otherdb" }
  ]
})

Common Roles

Role Description
read Read-only access to a database
readWrite Read and write access to a database
dbAdmin Administrative tasks on a database
userAdmin Manage users for a database
clusterAdmin Cluster-wide administrative access
root Superuser access (use carefully)

Troubleshooting Authentication

Authentication Failed

  • Verify username and password are correct
  • Check the auth database setting
  • Ensure the user exists in the specified auth database
  • Confirm the authentication mechanism matches the server configuration

Not Authorized

You're authenticated, but lack permissions for the operation. Check your user's roles and ensure they include the required permissions.

Connection String Issues

  • Special characters in passwords must be URL-encoded
  • @ becomes %40
  • : becomes %3A
  • / becomes %2F

MongoDB Atlas Authentication

For MongoDB Atlas connections:

  1. Create a database user in the Atlas dashboard
  2. Add your IP address to the IP Access List
  3. Use the connection string provided by Atlas

Atlas uses SCRAM-SHA-256 by default. The connection string includes the auth source automatically.

Next Steps

Learn how to connect to MongoDB Atlas and other cloud providers.