Re: MONGODB NODE.JS DRIVER 2.1

From: Kevin Adistambha <kevinadi@xxxxxxxxxxx>
To: mongodb-user <mongodb-user@xxxxxxxxxxxxxxxx>
Date: Thu, 28 Apr 2016 21:00:04 -0700 (PDT)
Why ads?


Hi Roland,

2016-04-19T16:03:57.865+0200 I ACCESS [conn2] Successfully authenticated as 
principal xxx2

Unauthorized not authorized on xxx2 to execute command { update: xxx

This sequence of message means that the user successfully authenticated to 
the server, but seems to lack authorization to perform the operation. I 
cannot seem to reproduce your issue by using MongoDB 3.0.3 and node.js 
driver versions 2.0.48 and 2.1.18.

I created a user named user with readWrite access to the test database:

use admin
db.system.users.find({user:"user"})
{
  "_id": "test.user",
  "user": "user",
  "db": "test",
  "credentials": {
    "SCRAM-SHA-1": {
      "iterationCount": 10000,
      "salt": "UY7iL204+Gl8PlxfZe3t/g==",
      "storedKey": "s2dgGPJ1ozsr/BQVltT7xvTxLFA=",
      "serverKey": "ilWGxBehJf89czrWeseQbenOH10="
    }
  },
  "roles": [
    {
      "role": "readWrite",
      "db": "test"
    }
  ]
}

and was able to successfully insert into a collection in the test database:

var MongoClient = require('mongodb').MongoClient;var url = 'mongodb://localhost:27017/test';
MongoClient.connect(url, function(err, db) {
  assert.equal(null, err);
  console.log('Connected to server.');
  db.authenticate('user', 'password', function(err, res) {
    assert.equal(null, err);
    console.log('Authentication successful.');
    db.collection('test').insert({hello:'world'}, function(err, res) {
      assert.equal(null, err);
      console.log('Insert successful.');
      db.close();
    })
  })
});

Could you please double check if the user has the proper authorization 
<https://docs.mongodb.org/v3.0/core/authorization/> to perform the required 
operation, and if anything has changed in your application code other than 
upgrading to the more recent node.js driver? If you are still having 
issues, it will be helpful to provide:

   - the output of db.system.users.find({user:<the relevant user>}) 
   - the operation you need to perform that fails authorization 

Also, you might want to consider upgrading to the latest in the 3.0.x 
series, which currently is 3.0.11 
<https://docs.mongodb.org/manual/release-notes/3.0/#mar-31-2016> for 
bugfixes and improvements.

Best regards,
Kevin


-- 
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.org/manual/support/
--- 
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+unsubscribe@xxxxxxxxxxxxxxxx.
To post to this group, send email to mongodb-user@xxxxxxxxxxxxxxxx.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/e4c7ed84-7e39-4f48-a58d-544713c20d12%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Why ads?