According to the documentation at http://docs.mongodb.org/meta-driver/latest/legacy/implement-authentication-in-driver/:
The driver then runs the authenticate command for the database on which to authenticate. The authenticate command has the following syntax:
db.runCommand( { authenticate : 1, user : <username>, nonce : <nonce>, key : <digest> }
<username>
is a username in the database’s system.users collection.
<nonce>
is the nonce returned from a previous getnonce step.
<digest>
is the hex encoding of an MD5 message digest.The MD5 message digest is the MD5 hash of the concatenation of
<nonce>
,<username>
,<password_digest>
.The
<password_digest>
is the value in thepwd
field associated with the<username>
in the database'ssystem.users
collection. Thepwd
is the hex encoding ofMD5( <username> + ":mongo:" + <password_text> )
.
This means that the hashing is actually done client-side, as the driver is part of the client for the database connection. In order to authenticate, the client does not need to demonstrate knowledge of the password but of the stored hash. So, the real password is the stored hash, which just happens to have been generated through hashing something. That real password is stored in plaintext in the pwd
field of system.users
.
Am I reading that wrong? Is there a way to secure this authentication?