MongoDB Native NodeJS Driver: Authentication does not work every timeHow does the SQL injection from the “Bobby Tables” XKCD comic work?MongoDB, sharding problems: fail mongos process after config server was crashedMongoDB Security issueThere are no preallocated journal files created in specified folder when mongod start up at first timeCreated mongod replication Set but fail to connectubuntu sudo service mongod status shows failed but mongo is workingMongoDB replica sets with arbiterMongoDB conf in absence of Arbiter to host election to choosing a primaryUnable to start MongoDB shell for mongos daemonMongoDB replica set on windows facing some basic issues

a sore throat vs a strep throat vs strep throat

How to pronounce 'c++' in Spanish

Did the BCPL programming language support floats?

Is it idiomatic to construct against `this`

"The cow" OR "a cow" OR "cows" in this context

Mistake in years of experience in resume?

Can't get 5V 3A DC constant

Is the claim "Employers won't employ people with no 'social media presence'" realistic?

As an international instructor, should I openly talk about my accent?

Was there a shared-world project before "Thieves World"?

Like totally amazing interchangeable sister outfits II: The Revenge

Is there a way to generate a list of distinct numbers such that no two subsets ever have an equal sum?

Why was the Spitfire's elliptical wing almost uncopied by other aircraft of World War 2?

Dynamic SOQL query relationship with field visibility for Users

What term is being referred to with "reflected-sound-of-underground-spirits"?

Critique of timeline aesthetic

What makes accurate emulation of old systems a difficult task?

How to limit Drive Letters Windows assigns to new removable USB drives

Was there a Viking Exchange as well as a Columbian one?

Do I have an "anti-research" personality?

How exactly does Hawking radiation decrease the mass of black holes?

How to denote matrix elements succinctly?

Pre-plastic human skin alternative

Can someone publish a story that happened to you?



MongoDB Native NodeJS Driver: Authentication does not work every time


How does the SQL injection from the “Bobby Tables” XKCD comic work?MongoDB, sharding problems: fail mongos process after config server was crashedMongoDB Security issueThere are no preallocated journal files created in specified folder when mongod start up at first timeCreated mongod replication Set but fail to connectubuntu sudo service mongod status shows failed but mongo is workingMongoDB replica sets with arbiterMongoDB conf in absence of Arbiter to host election to choosing a primaryUnable to start MongoDB shell for mongos daemonMongoDB replica set on windows facing some basic issues






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I launch my replica set with these commands:



./mongod --auth --keyFile /home/a/keyfile --replSet mydb --logpath rs1/logs.log --logappend --dbpath rs1/ --port 26381 --bind_ip 0.0.0.0 &
./mongod --auth --keyFile /home/a/keyfile --replSet mydb --logpath rs2/logs.log --logappend --dbpath rs2/ --port 26382 --bind_ip 0.0.0.0 &
./mongod --auth --keyFile /home/a/keyfile --replSet mydb --logpath rs3/logs.log --logappend --dbpath rs3/ --port 26383 --bind_ip 0.0.0.0 &


And I connect my nodejs app to mongo with this piece of code:



const url = "mongodb://"+credentials+ip1+":"+port1+","+ip2+":"+port2+","+ip3+":"+port3+"/"+dbName+"?replicaSet="+replicaSetName+"&w=2&readPreference=secondary&slaveOk=true";
MongoClient.connect(url, useNewUrlParser: true , function(err, client)
console.log("SOMETIMES UNREACHABLE CODE");
assert.equal(null, err);
assert.ok(client != null);
client.db(dbName).collection('users').find().toArray(function(err, result)
console.log(err, result);
client.close();
);
);


Sometimes it works, sometimes it doesn't even when I restart the replica set entirely. I think it's because I often restart my application for test purpose but I didn't find anything about blocking the database after several authentication attempts. Furthermore, it works everytime with the mongo client.



Is it really usefull to add authentication if I use a firewall to protect the database?










share|improve this question
























  • The last major version 3.2.0 (2019-03-21) of the driver seems to have fixed this bug.

    – kopbuc
    Mar 23 at 17:23

















0















I launch my replica set with these commands:



./mongod --auth --keyFile /home/a/keyfile --replSet mydb --logpath rs1/logs.log --logappend --dbpath rs1/ --port 26381 --bind_ip 0.0.0.0 &
./mongod --auth --keyFile /home/a/keyfile --replSet mydb --logpath rs2/logs.log --logappend --dbpath rs2/ --port 26382 --bind_ip 0.0.0.0 &
./mongod --auth --keyFile /home/a/keyfile --replSet mydb --logpath rs3/logs.log --logappend --dbpath rs3/ --port 26383 --bind_ip 0.0.0.0 &


And I connect my nodejs app to mongo with this piece of code:



const url = "mongodb://"+credentials+ip1+":"+port1+","+ip2+":"+port2+","+ip3+":"+port3+"/"+dbName+"?replicaSet="+replicaSetName+"&w=2&readPreference=secondary&slaveOk=true";
MongoClient.connect(url, useNewUrlParser: true , function(err, client)
console.log("SOMETIMES UNREACHABLE CODE");
assert.equal(null, err);
assert.ok(client != null);
client.db(dbName).collection('users').find().toArray(function(err, result)
console.log(err, result);
client.close();
);
);


Sometimes it works, sometimes it doesn't even when I restart the replica set entirely. I think it's because I often restart my application for test purpose but I didn't find anything about blocking the database after several authentication attempts. Furthermore, it works everytime with the mongo client.



Is it really usefull to add authentication if I use a firewall to protect the database?










share|improve this question
























  • The last major version 3.2.0 (2019-03-21) of the driver seems to have fixed this bug.

    – kopbuc
    Mar 23 at 17:23













0












0








0








I launch my replica set with these commands:



./mongod --auth --keyFile /home/a/keyfile --replSet mydb --logpath rs1/logs.log --logappend --dbpath rs1/ --port 26381 --bind_ip 0.0.0.0 &
./mongod --auth --keyFile /home/a/keyfile --replSet mydb --logpath rs2/logs.log --logappend --dbpath rs2/ --port 26382 --bind_ip 0.0.0.0 &
./mongod --auth --keyFile /home/a/keyfile --replSet mydb --logpath rs3/logs.log --logappend --dbpath rs3/ --port 26383 --bind_ip 0.0.0.0 &


And I connect my nodejs app to mongo with this piece of code:



const url = "mongodb://"+credentials+ip1+":"+port1+","+ip2+":"+port2+","+ip3+":"+port3+"/"+dbName+"?replicaSet="+replicaSetName+"&w=2&readPreference=secondary&slaveOk=true";
MongoClient.connect(url, useNewUrlParser: true , function(err, client)
console.log("SOMETIMES UNREACHABLE CODE");
assert.equal(null, err);
assert.ok(client != null);
client.db(dbName).collection('users').find().toArray(function(err, result)
console.log(err, result);
client.close();
);
);


Sometimes it works, sometimes it doesn't even when I restart the replica set entirely. I think it's because I often restart my application for test purpose but I didn't find anything about blocking the database after several authentication attempts. Furthermore, it works everytime with the mongo client.



Is it really usefull to add authentication if I use a firewall to protect the database?










share|improve this question
















I launch my replica set with these commands:



./mongod --auth --keyFile /home/a/keyfile --replSet mydb --logpath rs1/logs.log --logappend --dbpath rs1/ --port 26381 --bind_ip 0.0.0.0 &
./mongod --auth --keyFile /home/a/keyfile --replSet mydb --logpath rs2/logs.log --logappend --dbpath rs2/ --port 26382 --bind_ip 0.0.0.0 &
./mongod --auth --keyFile /home/a/keyfile --replSet mydb --logpath rs3/logs.log --logappend --dbpath rs3/ --port 26383 --bind_ip 0.0.0.0 &


And I connect my nodejs app to mongo with this piece of code:



const url = "mongodb://"+credentials+ip1+":"+port1+","+ip2+":"+port2+","+ip3+":"+port3+"/"+dbName+"?replicaSet="+replicaSetName+"&w=2&readPreference=secondary&slaveOk=true";
MongoClient.connect(url, useNewUrlParser: true , function(err, client)
console.log("SOMETIMES UNREACHABLE CODE");
assert.equal(null, err);
assert.ok(client != null);
client.db(dbName).collection('users').find().toArray(function(err, result)
console.log(err, result);
client.close();
);
);


Sometimes it works, sometimes it doesn't even when I restart the replica set entirely. I think it's because I often restart my application for test purpose but I didn't find anything about blocking the database after several authentication attempts. Furthermore, it works everytime with the mongo client.



Is it really usefull to add authentication if I use a firewall to protect the database?







node.js mongodb security






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 9 at 9:00







kopbuc

















asked Mar 9 at 8:52









kopbuckopbuc

63




63












  • The last major version 3.2.0 (2019-03-21) of the driver seems to have fixed this bug.

    – kopbuc
    Mar 23 at 17:23

















  • The last major version 3.2.0 (2019-03-21) of the driver seems to have fixed this bug.

    – kopbuc
    Mar 23 at 17:23
















The last major version 3.2.0 (2019-03-21) of the driver seems to have fixed this bug.

– kopbuc
Mar 23 at 17:23





The last major version 3.2.0 (2019-03-21) of the driver seems to have fixed this bug.

– kopbuc
Mar 23 at 17:23












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55075595%2fmongodb-native-nodejs-driver-authentication-does-not-work-every-time%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55075595%2fmongodb-native-nodejs-driver-authentication-does-not-work-every-time%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

1928 у кіно

Захаров Федір Захарович

Ель Греко