geddy / model

Datastore-agnostic ORM in JavaScript
265 stars 55 forks source link

v0.4 - MongoDB adapter: Authentication does not work #114

Closed tbjers closed 11 years ago

tbjers commented 11 years ago

Since the MongoDB adapter switched from using mongodb-wrapper to the native mongodb driver, authentication has stopped working. The init method on the mongodb adapter does not set the authentication properly:

  this.init = function () {
    var config = this.config
      , server = new mongo.Server(config.host, config.port);
    this.client = new mongo.MongoClient(server, config);
  };

http://mongodb.github.io/node-mongodb-native/api-generated/mongoclient.html

The MongoDB native library does not support passing in authentication in a hash, and requires a connection string instead.

http://mongodb.github.io/node-mongodb-native/driver-articles/mongoclient.html

So we need to generate a connect string, or switch back to using mongodb-wrapper.

Any thoughts?

I figured the easiest way to do this would be to supply a url parameter with the configuration and use that in .init()

mde commented 11 years ago

Sounds like we need to switch to a connection string -- shouldn't be too hard to take the config object and generate a URL from it. Could you take a stab at doing that?

tbjers commented 11 years ago

Sure thing! What branch do you want me to work in? On Nov 16, 2013 2:45 PM, "Matthew Eernisse" notifications@github.com wrote:

Sounds like we need to switch to a connection string -- shouldn't be too hard to take the config object and generate a URL from it. Could you take a stab at doing that?

— Reply to this email directly or view it on GitHubhttps://github.com/mde/model/issues/114#issuecomment-28634144 .

mde commented 11 years ago

Release branch (v0.4) -- this is a bugfix.

tbjers commented 11 years ago

Tested and fixed in v0.4.3.