mongeez / mongeez

MongoDB Easy Change Management
http://secondmarket.github.io/mongeez/
222 stars 109 forks source link

version 0.9.6 authentication to mongos cluster with mongo.uri not working #63

Open chiemseesurfer opened 8 years ago

chiemseesurfer commented 8 years ago

Hey,

I use version 0.9.6 and want to authenticate to a mongos cluster through mongo.uri

my config part (application.yml) looks like the following: spring: profiles: active: prod data: mongodb: uri: mongodb://USER:PWD@mongos01:27017,mongos02:27017/?maxpoolsize=100&waitqueuemultiple=3&waitqueuetimeoutms=30000&connecttimeoutms=10000&sockettimeoutms=0&autoconnectretry=true&slaveok=true&readpreference=primaryPreferred&safe=true&w=1&wtimeout=10000&fsync=false&j=false authentication-database: admin database: MYDATABASE

Everytime I try to start the application, I get a not authorized exception in the logs. Other applications are working with that mongo uri and without mongeez. I thought the authentication was fixed with version 0.9.5?

Without the authentication everything is working (on mongodb 2.8 and 3.0). Do I also have to upgrade spring-boot? Right now I'm using 1.2.6.RELEASE.

The Exception: Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongeez' defined in class path resource [PATH/TO/DatabaseConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Fail ed to instantiate [org.mongeez.Mongeez]: Factory method 'mongeez' threw exception; nested exception is com.mongodb.CommandFailureException: { "serverUsed" : "mongos01:27017" , "ok" : 0.0 , "errmsg" : "not authorized on MYDATABASE to execute command { update: \"mongeez\", ordered: true, updates: [ { q: { type: { $exists: false } }, u: { $set: { type: \"changeSetExecution\" } }, multi: true } ] }" , "code" : 13} at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1119) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1014) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:687) at org.springframework.boot.SpringApplication.run(SpringApplication.java:321) at org.springframework.boot.context.web.SpringBootServletInitializer.run(SpringBootServletInitializer.java:133) at org.springframework.boot.context.web.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:124) at org.springframework.boot.context.web.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:81) at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:175) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5210) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ... 10 more

cheers Max

merikan commented 7 years ago

I ran into this yesterday. I have been using Mongeez for a while now but only in development. Unfortunately I didn't have authorization enabled in development and when moving to staging I ran into big trouble. Realized that Mongeez was using db.eval() to execute changesets. According to mongodb documentation "If authorization is enabled, you must have access to all actions on all resources" and also "db.eval() is deprecated since version 3.0". It's unacceptable for me to run a database without authorization enabled. With that in mind plus the fact that this project seems abandoned I'm in the process migrating to MongoBee.