marcesher / cfmongodb

MongoDB client wrapper for ColdFusion
89 stars 34 forks source link

Patch/mongo3 authentication #51

Open jclausen opened 9 years ago

jclausen commented 9 years ago

This patch addresses Issue #50 and authentication against Mongo 3.0+ databases. It also implements an optional key in the config auth structure for an authenticationDB key in the hosts array as well as credentials. Third party mongo providers, such as MongoLab, use the client db for authentication on low-level plans, while switching to the Mongo default "admin" db on higher level plans.

Implementation example (backward compatibility is maintained):

var javaloaderFactory = createObject('component','cfmongodb.core.JavaloaderFactory').init();
var configStruct.MongoDB = {
    hosts       = [
                     {
                        serverName='ds01234.mongolab.com',
                        serverPort='1234',
                        username="unitTestUser",
                        password="SecurePa55w0rD",
                        authenticationDB="cbmongo_unit_tests"
                     }
                  ],
    db  = "cbmongo_unit_tests"
};
var MongoConfig = createObject('component','cfmongodb.config.MongoConfig').init(hosts=configStruct.MongoDB.hosts,dbName=configStruct.MongoDB.db, mongoFactory=javaloaderFactory);
marcesher commented 9 years ago

@jclausen Thanks for the PR.

I'm not sure what's up with this PR, but MongoClient looks like a completely new file. Please fix the PR so that it reflects only what's actually changing.

When you say backwards compatible, what versions of Mongo and ColdFusion have you tested this against? And do all unit tests continue to work?

Finally, do these changes require additional unit tests, or do the existing tests adequately cover the changes?

Thanks.