marcello3d / node-mongolian

[project inactive] Mongolian DeadBeef is an awesome Mongo DB driver for node.js
https://groups.google.com/group/node-mongolian
zlib License
350 stars 50 forks source link

Authentication support #9

Closed tarqd closed 13 years ago

tarqd commented 13 years ago

I added authentication support and it seems to be pretty stable. Usage is as follows

db.auth(user, pass)

After that any command that needs to be sent after authentication will be queued if the authentication proccess hasn't finished, and if it fails it will trigger an error for all queued commands.

For example:

db.auth("wrong", "password")
someCollection.find().forEach(function(doc){ // won't execute until after db.auth does it's thing
    // do something
},
function(err){
// error will be triggered here after authentication failed
}

It will also re-authenticate after the connection timesout or is closed

Another thing I fixed was that for some reason new MongolianError("anything") actually returned a blank object ({}) because of the call to Error.apply. I changed this out and now it works fine but it looks a bit ugly.

tarqd commented 13 years ago

I also added all the commits from your latest commit manually

marcello3d commented 13 years ago

looks like a good start, but I'd like a cleaner set of commits before I merge it into the master

marcello3d commented 13 years ago

Alright, I've added in what I think should work, but haven't got a good way to test it. I'm also not sure how to add it to the vows tests, since you need a specially configured server for it to even work.

tarqd commented 13 years ago

Thanks! I'd test it myself but I'm currently away but you can use this for testing if oyu want

Server: flame.mongohq.com:27028 Database Name: mongolian_test Username: mongolian Password: passw0rd

or there's always mongohq.com that uses authentication

marcello3d commented 13 years ago

Ok, it's definite not working right now, I just get "auth fails" back from the server.

marcello3d commented 13 years ago

Apparently I'm also getting "db assertion failure".

marcello3d commented 13 years ago

Alright. Figured it out. It's working now. :-)