spring-cloud / spring-cloud-connectors

Library to let cloud applications connect to services
Apache License 2.0
185 stars 161 forks source link

Allow authSource in the Mongo URI to be passed along to the Mongo DB Factory #112

Closed rob-baily closed 9 years ago

rob-baily commented 9 years ago

I was doing some development using the local connector for Mongo and I found that parameters in the URI are not passed along. I was most interested in the authSource as I had consolidated users into the admin database and there was no way to tell the Mongo client where the auth database was. The authSource may be different than other parameters as it involves calling a different constructor in the SimpleMongoDbFactory class.

I can take a shot at this but I wanted to get any feedback on why this might have already been considered and rejected for any design reasons.

rob-baily commented 9 years ago

I've taken a shot at this and will create a pull request. What I found is that the Mongo portion was compiling against Spring Data Mongo 1.2.4 which is older. I upgraded that version to 1.6.2 (I also tried 1.5.5 and that works as well) and now use the MongoCredentials class to get the auth source. Not sure if there is a reason for using the much older version of Spring Data Mongo so please comment if so. I also changed a test that was using deprecated methods based on the version upgrade.

One last thing, I modified the propdeps-plugin version from 0.0.5 to 0.0.7 as this was causing issues running in IntelliJ. It seems that newer versions of Gradle need this version of the plugin to build properly.

ramnivas commented 9 years ago

@rob-baily Generally, we keep the oldest version that can possibly work as the main dependency. Please see https://github.com/spring-cloud/spring-cloud-connectors/pull/95 for reason behind it.

rob-baily commented 9 years ago

Then @ramnivas do you have a suggestion on how to incorporate new features (like Mongo auth source) into the spring cloud connectors so that they can be supported? Wouldn't it make sense to encourage new underlying libraries as you increase the versions? This could be for a new major or minor version which supports new features in the underlying services.

ramnivas commented 9 years ago

@rob-baily The core idea is to use "the oldest version that can possibly work". In your case it looks like 1.5.5 will work (possibly even an older version). So if you find the oldest version that will be sufficient for your work, you could upgrade to just that (and add newer versions including the latest in the test matrix).

rob-baily commented 9 years ago

Got it. Let me do a little research to see what version this would work with and add a new pull request.

rob-baily commented 9 years ago

I found out that it works with Spring Data Mongo 1.4 but not 1.3. I set the minimum Spring Data Mongo version to 1.4.3 and updated the test matrix to go from 1.4.3 to 1.7.0. Please check it out @ramnivas and let me know if this looks better. Thanks for your guidance!

scottfrederick commented 9 years ago

Fixed via #113