Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-638

Cannot authenticate database user with utf-8 password

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Blocker - P1 Blocker - P1
    • 2.1.5
    • Affects Version/s: None
    • Component/s: MongoDB 3.2
    • Environment:
      linux x86_64

      Hello

      I have a database user with: username == 'user' and password == 'passwordUtfééùù'.

      var db = new Db('test', new Server('localhost', 27017));
      db.open(function(err, db) {
      db.authenticate('user', 'passwordUtfééùù', function(err, result)

      { console.log(err); db.close(); }

      );
      });

      The output is:

      { [MongoError: auth fails] name: 'MongoError', message: 'auth fails', code: 18, ok: 0, errmsg: 'auth fails' }

      Somewere in the lib code (in 4 places in node_modules/mongodb) you can find md5.update(username + ":mongo:" + password); but if you change it to md5.update(username + ":mongo:" + password, 'utf8'); it will authenticate with success

      md5.update doc: https://nodejs.org/api/crypto.html#crypto_hash_update_data_input_encoding

      In mongoshell it works with db.auth function.

      node mongodb version: "^2.1.4"
      nodejs version: v0.12.7
      mongodb version: 2.4.6

      Thanks

            Assignee:
            christkv Christian Amor Kvalheim
            Reporter:
            florin.popescu0110 Florin Marius Popescu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: