Challenge - 5 Problems
MongoDB Authentication Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
Output of user authentication command
What is the output of the following MongoDB command when authenticating a user with correct credentials?
MongoDB
db.auth('username', 'correct_password')
Attempts:
2 left
💡 Hint
The auth() method returns 1 on successful authentication.
✗ Incorrect
In MongoDB, the auth() method returns 1 if the username and password are correct, indicating successful authentication.
🧠 Conceptual
intermediate2:00remaining
Default authentication mechanism in MongoDB
Which authentication mechanism does MongoDB use by default when authentication is enabled?
Attempts:
2 left
💡 Hint
SCRAM is a challenge-response mechanism used by default.
✗ Incorrect
MongoDB uses SCRAM-SHA-256 as the default authentication mechanism since version 4.0 for secure password-based authentication.
📝 Syntax
advanced2:00remaining
Correct syntax for creating a user with SCRAM authentication
Which of the following commands correctly creates a user with SCRAM authentication in MongoDB?
MongoDB
db.createUser({user: 'alice', pwd: 'password123', roles: ['readWrite']})Attempts:
2 left
💡 Hint
The correct keys are 'user' and 'pwd' for username and password.
✗ Incorrect
The createUser method requires 'user' and 'pwd' keys to specify username and password respectively. Other keys like 'username' or 'password' are invalid.
🔧 Debug
advanced2:00remaining
Identify the cause of authentication failure
A user tries to authenticate with db.auth('bob', 'wrongpass') but always gets 0. What is the most likely cause?
Attempts:
2 left
💡 Hint
db.auth returns 0 when authentication fails due to wrong credentials.
✗ Incorrect
If the user exists but the password is wrong, db.auth returns 0. If the user does not exist, it also returns 0, but the most common cause is wrong password.
❓ optimization
expert2:00remaining
Best practice to secure MongoDB authentication in production
Which option is the best practice to enhance security of MongoDB authentication in a production environment?
Attempts:
2 left
💡 Hint
Combining strong authentication with encrypted connections improves security.
✗ Incorrect
Enabling SCRAM-SHA-256 ensures strong password authentication, and TLS encrypts data in transit, protecting credentials and data from interception.