abcdRepliaSet:PRIMARY> use abcd
switched to db abcd
show users
abcdRepliaSet:PRIMARY> show users
{
"_id" : "abcd.abcdAppUser",
"user" : "abcdAppUser",
"db" : "abcd",
"roles" : [
{
"role" : "readWrite",
"db" : "abcd"
}
]
}
mongo adbcd-mongo-mms.cloudapp.net:57002 -u adbcd AppUser -p hidden --authenticationDatabase adbcd
MongoClient.connect("mongodb://abcdAppUser:hid...@abcd-mongo-mms.cloudapp.net:57001,abcd-mongo-mms.cloudapp.net:57002,abcd-mongo-mms.cloudapp.net:57003/abcd?replicaSet=abcdRepliaSet&authSource=abcd&authMechanism=SCRAM-SHA-1", function(err, db) {
if(err) throw err;
else console.log(db);
});
db.system.users.find({user:"abcdAppUser"}).pretty()
2015-12-22T13:31:33.823+0000 I ACCESS [conn30286] SCRAM-SHA-1 authentication failed for abcdAppUser on abcd from client 10.0.0.10 ; AuthenticationFailed SCRAM-SHA-1 authentication failed, storedKey mismatch
2015-12-22T13:31:33.894+0000 I ACCESS [conn30288] SCRAM-SHA-1 authentication failed for abcdAppUser on abcd from client 10.0.0.10 ; AuthenticationFailed SCRAM-SHA-1 authentication failed, storedKey mismatch
2015-12-22T13:31:34.051+0000 I ACCESS [conn30287] SCRAM-SHA-1 authentication failed for abcdAppUser on abcd from client 10.0.0.10 ; AuthenticationFailed SCRAM-SHA-1 authentication failed, storedKey mismatch
2015-12-22T13:31:34.124+0000 I ACCESS [conn30289] SCRAM-SHA-1 authentication failed for abcdAppUser on abcd from client 10.0.0.10 ; AuthenticationFailed SCRAM-SHA-1 authentication failed, storedKey mismatch
2015-12-22T13:31:34.206+0000 I ACCESS [conn30290] SCRAM-SHA-1 authentication failed for abcdAppUser on abcd from client 10.0.0.10 ; AuthenticationFailed SCRAM-SHA-1 authentication failed, storedKey mismatch
2015-12-22T13:31:34.263+0000 I NETWORK [conn30288] end connection 94.61.85.76:53102 (17 connections now open)
2015-12-22T13:31:34.264+0000 I NETWORK [conn30286] end connection 94.61.85.76:61293 (17 connections now open)
2015-12-22T13:31:34.263+0000 I NETWORK [conn30287] end connection 94.61.85.76:58194 (17 connections now open)
2015-12-22T13:31:34.263+0000 I NETWORK [conn30289] end connection 94.61.85.76:58537 (17 connections now open)
2015-12-22T13:31:34.264+0000 I NETWORK [conn30290] end connection 94.61.85.76:57720 (13 connections now open)
2015-12-22T13:31:37.185+0000 I NETWORK [conn30281] end connection 10.0.0.8:34322 (12 connections now open)
{
"_id" : "abcd. abcdAppUser",
"user" : "abcdAppUser",
"db" : "abcd",
"credentials" : {
"SCRAM-SHA-1" : {
"iterationCount" : 10000,
"salt" : "90Ay1lAKpaq2GoEHh3hzkQ==",
"storedKey" : "hidden=",
"serverKey" : "alsoHidden="
}
},
"roles" : [
{
"role" : "readWrite",
"db" : "abcd"
}
]
}
and I can successfully connect to it via mongo shell:
mongo adbcd-mongo-mms.cloudapp.net:57002 -u adbcd AppUser -p hidden —authenticationDatabase adbcd
Hi Pedro,
For the shell connection test you have posted a slightly different information:
Can you please confirm whether the above are just a typing error when posting ?
I am also pretty sure my authMechanism is SCRAM-SHA-1 as I’ve added the user using mongoldb v. 3.0.7
Can you confirm that your deployment is still running MongoDB v3.0.7 ?
Also can you run a couple of tests:
Try changing the connection string to a single node :MongoClient.connect("mongodb://abcdAppUser:hid...@abcd-mongo-mms.cloudapp.net:57001/abcd", function(err, db) ...
Try connecting with a different username/password. i.e. admin
Regards,
Wan.
Hi Pedro,
Unfortunately I can’t replicate the authentication problem that you are seeing. My test environment is:
node v5.10, mongodb driver v2.1.2, MongoDB replica set v3.2.0 (auth SCRAM-SHA-1).
Did you start a new v3.0.7 installation without any users ?
Or did you upgrade from v2.6 with existing users and then create new users in v3.0.7?
If you are upgrading from v2.6 with existing users, to use SCRAM-SHA-1 please follow the upgrade steps for v2.6 MONGODB-CR Users to SCRAM-SHA-1.
Another test that you should try is separating the connection code with the authentication code. See code snippet below for an example:
var Db = require('mongodb').Db;
var Server = require('mongodb').Server;
var dbname = 'abcd';
var host = 'abcd-mongo-mms.cloudapp.net';
var port = 57001;
var user = 'abcdAppUser';
var pwd = 'hidden';
var db = new Db(dbname, new Server(host, port));
db.open(function(err, db){
if (err) throw err;
console.log('Connected');
db.authenticate(user, pwd, function(err, result){
if (err) throw err;
console.log('Authenticated');
db.close();
});
});
If you are able to connect but not authenticate, please check that your username and password are correct.
The below log entry normally indicates that the password is incorrect. Incorrect database or user would result in a different log entry.
2016-01-05T13:21:38.127+1100 I ACCESS [conn75] SCRAM-SHA-1 authentication failed for abcdAppUser on abcd from client 10.8.1.191 ; AuthenticationFailed SCRAM-SHA-1 authentication failed, storedKey mismatch
Regards,
Wan.
Hello everybody,I am trying to authenticate to my replica set, which was deployed via Mongo Cloud Manager, but I can not figure out why it fails.Here are my users on database abcd:
abcdRepliaSet:PRIMARY> use abcd
switched to db abcd
show users
abcdRepliaSet:PRIMARY> show users
{
"_id" : "abcd.abcdAppUser",
"user" : "abcdAppUser",
"db" : "abcd",
"roles" : [
{
"role" : "readWrite",
"db" : "abcd"
}
]
}and I can successfully connect to it via mongo shell:
mongo adbcd-mongo-mms.cloudapp.net:57002 -u adbcd AppUser -p hidden --authenticationDatabase adbcdHowever, I can not using this simple code:
MongoClient.connect("mongodb://abcdAppUser:hidden@abcd-mongo-mms.cloudapp.net:57001,abcd-mongo-mms.cloudapp.net:57002,abcd-mongo-mms.cloudapp.net:57003/abcd?replicaSet=abcdRepliaSet&authSource=abcd&authMechanism=SCRAM-SHA-1",
function(err, db) {
if(err) throw err;
else console.log(db);
});