dboissier / mongo4idea

MongoDB integration in Intellij
Apache License 2.0
976 stars 109 forks source link

Authentication fails #114

Closed dbeckwith closed 9 years ago

dbeckwith commented 9 years ago

I'm trying to connect to a database on my localhost. I can connect just fine from the command line, but when I try with the WebStorm plugin it's not working. I enter the credentials and information like so: screenshot - 06162015 - 08 55 20 pm When I press "Test Connection" it says it's successful. But when I save the configuration and try to connect to the database my IDE hangs for 30 seconds and I get this error:

8:54:42 PM MongoTimeoutException: Error when collecting Mongo databases: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSecurityException: Exception authenticating}, caused by {com.mongodb.MongoCommandException: Command failed with error 18: 'auth failed' on server localhost:27017. The full response is { "ok" : 0.0, "errmsg" : "auth failed", "code" : 18 }}}]

Not sure why auth failed, I definitely have the right credentials. Any help?

dboissier commented 9 years ago

Hi,

If you have only access to website, you may need to check Use this database as 'My Single database' option.

Regards,

dbeckwith commented 9 years ago

I also have access to the admin database, but I had the same issue connecting to that. But I'll try checking that.

spectravp commented 9 years ago

Same issue here. Pressing "Test Connection" seems to do nothing since I can enter completely incorrect information and it still says connection successful. Can successfully connect from command line, but not with the plugin.

dbeckwith commented 9 years ago

I am still having this issue as well. Seems like no matter what settings I put in, I always get that error.

spectravp commented 9 years ago

Agreed. Plugin is worthless.

rhhamburg commented 9 years ago

The problem is the new authentication mechanism from mongoDB 3. MongoDB use now SCRAM-SHA-1 and no longer MONGODB-CR.

After I changed the authentication mechanism back to MONGODB-CR in my mongoDB the plugin works perfect.


Changed in version 3.0.

MongoDB supports multiple authentication mechanisms. MongoDB’s default authentication method is a challenge and response mechanism (SCRAM-SHA-1). Previously, MongoDB used MongoDB Challenge and Response (MONGODB-CR) as the default.

http://docs.mongodb.org/manual/core/authentication

dboissier commented 9 years ago

Hi,

Thanks @rhhamburg for the info. I will add an auth mecanism option based on this list.

Thanks all for your patience. I have just come back for holidays ;)

RBLU commented 9 years ago

same issue here - getting the following exception after upgrading our server to v3.0.5 when opening a DB from the sidebar (on doubleclick). TestConnection in the Settings says ok, but seems to say that always regardless of user and password...

Error when collecting Mongo databases: Timed out after 30000 ms while waiting for a server that 
matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is
 {type=UNKNOWN, servers=[{address=<snipsnap ask via PM for URL to test>:27017, type=UNKNOWN,
state=CONNECTING, exception={com.mongodb.MongoSecurityException: Exception authenticating},
caused by {com.mongodb.MongoCommandException: Command failed with error 18: 'auth failed' on
server <snipsnap ask via PM for URL to test>:27017. The full response is { "ok" : 0.0,
 "errmsg" : "auth failed", "code" : 18}}}]

I had a look into the sources but could not find a simple solution - no experience with MongoDb Java driver nor Intellij PluginAPI and rusty Java knowhow makes it tough.

rhhamburg commented 9 years ago

@RBLU - MongoDB changed the authentication mechanism in version 3. The current plugin use the old MONGODB-CR and not the new SCRAM-SHA-1. To use the current plugin with MongoDB v3 you must change the authentication mechanism in your MongoDB to MONGODB-CR or you wait for an update of the plugin.

dboissier commented 9 years ago

Hi,

please install manually this SNAPSHOT version and tell me if it works on your side.

Thanks.

RBLU commented 9 years ago

sorry, can't really help with testing, we switched our mongod instances to use MONGODB-CR

rhhamburg commented 9 years ago

For me it works. But if I change the Authentication method later, the change will not saved.

dboissier commented 9 years ago

@rhhamburg Thanks for reporting this bug. I am working on it

dboissier commented 9 years ago

@rhhamburg Hi. I uploaded now snapshot that may fix configuration persistence issue.

folkengine commented 9 years ago

The SNAPSHOT version fixed the issue for me. Thanks!