0
0
MongoDBquery~20 mins

Authentication mechanisms in MongoDB - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
MongoDB Authentication Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2: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')
A1
B0
Cnull
Dthrows an error
Attempts:
2 left
💡 Hint
The auth() method returns 1 on successful authentication.
🧠 Conceptual
intermediate
2:00remaining
Default authentication mechanism in MongoDB
Which authentication mechanism does MongoDB use by default when authentication is enabled?
AX.509 certificates
BSCRAM-SHA-256
CKerberos
DLDAP
Attempts:
2 left
💡 Hint
SCRAM is a challenge-response mechanism used by default.
📝 Syntax
advanced
2: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']})
Adb.addUser('alice', 'password123', ['readWrite'])
Bdb.createUser({username: 'alice', password: 'password123', roles: ['readWrite']})
Cdb.createUser({user: 'alice', pwd: 'password123', roles: ['readWrite']})
Ddb.createUser({user: 'alice', password: 'password123', roles: ['readWrite']})
Attempts:
2 left
💡 Hint
The correct keys are 'user' and 'pwd' for username and password.
🔧 Debug
advanced
2: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?
AThe password is incorrect
BThe user 'bob' does not exist
CThe database is not running
DThe user 'bob' has no roles assigned
Attempts:
2 left
💡 Hint
db.auth returns 0 when authentication fails due to wrong credentials.
optimization
expert
2: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?
AUse default settings without authentication for faster access
BDisable authentication and rely on network firewall only
CStore passwords in plain text for easy retrieval
DEnable SCRAM-SHA-256 and use TLS encryption for connections
Attempts:
2 left
💡 Hint
Combining strong authentication with encrypted connections improves security.