assertion 13 not authorized for query on
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 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:
db.system.users.find({user:<the relevant user>})
Also, you might want to consider upgrading to the latest in the 3.0.x series, which currently is 3.0.11 for bugfixes and improvements.
Best regards,
Kevin
auth: function(dbName){ var deferred = q.defer(); var DbServerRef = DbServer.db(dbName); var dbConfig = Config.getConfigItem(dbName); DbServerRef.authenticate(dbConfig.user, dbConfig.pwd, function(err, result) { if(err)console.log(err); //console.log(DbServerRef); DbConns[DbServerRef.s.databaseName] = DbServerRef; console.log('Auth DB: '+DbServerRef.s.databaseName+' - OK'); deferred.resolve(true); });
return deferred.promise;}
getDatabase: function(dbName){DbReference = DbConns[dbName]; return DbReference;
},
Hi Soorya,
I am facing the same issue.Can anyone tell how to resolve this problem?
Could you please open a new thread with your issue, along with:
Please note that the original thread is about Node.js driver version 2.1, and the current version of the driver is 2.2.10. If you’re having this issue with driver version 2.0, it might be worth checking if your issue is resolved with the new driver.
Best regards,
Kevin