runner36 / rock-php

Automatically exported from code.google.com/p/rock-php
0 stars 0 forks source link

MongoHQ - MongoDB authenticate failed. Please check your username and password from your mongo administrator. #229

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Follow the wiki exactly
2. Try to login to mongohq with either auth method

What is the expected output? What do you see instead?

Expecting to login. Instead I get "MongoDB authenticate failed. Please check 
your username and password from your mongo administrator."

RockMongo Version (1.1.0, ...)

Latest

Operation System (Windows/CentOS, ...)

kubuntu

PHP Version (5.1.6, ...)
5.3

php_mongo Version (1.0.9, ...)
1.3.0beta2

MongoDB version (1.8.5, ...)
2.2

No error logs in logs folder.

Original issue reported on code.google.com by scottada...@gmail.com on 25 Oct 2012 at 1:44

GoogleCodeExporter commented 8 years ago
This worked for me (after studying rockmongo source code):

// ./config.php

$MONGO["servers"][$i]["mongo_auth"] = false;
$MONGO["servers"][$i]["control_auth"] = false;
$MONGO["servers"][$i]["mongo_name"] = "Your host name";
$MONGO["servers"][$i]["mongo_host"] = "your.host.com"; // or IP address (eg 
localhost: 127.0.0.1)
$MONGO["servers"][$i]["mongo_port"] = "27017"; // or any other port
$MONGO["servers"][$i]["mongo_db"] = "your_db_name"; // default "admin"
$MONGO["servers"][$i]["mongo_user"] = "your_username";
$MONGO["servers"][$i]["mongo_pass"] = "your_password";

In case of no success try debugging ./app/models/MServer#auth() method (look 
for user/pass values passed).

Good luck!

Original comment by stankovi...@gmail.com on 18 Nov 2012 at 11:31

GoogleCodeExporter commented 8 years ago
same problem with :
MongoDB 2.2.1
PHP 5.2.17
php_mongo 1.3.0

Original comment by ghislain...@gmail.com on 29 Nov 2012 at 9:18

GoogleCodeExporter commented 8 years ago
Indeed the authenticate method is deprecated with new driver (1.3)
Authentication has to be inserted in the connection string.
Ex : mongodb://username:password@host:port

Original comment by thomas.r...@gmail.com on 29 Nov 2012 at 9:52

GoogleCodeExporter commented 8 years ago
My setup:
Ubuntu 12.04
PHP 5.3.17
MongoDB 2.2.2 (from the official PPA)
PHP mongo driver 1.3.0 (from PECL)
RockMongo 1.1.3

I think the issue has to do with the RockMongo script not working with the 1.3 
series of the PHP mongo driver. I ran into this same issue when I updated my 
development machine from 1.2.12 to 1.3.0 of the driver and I was no longer able 
to login to the server with RockMongo.

I have a separate laptop that also has RockMongo 1.1.3, PHP 5.3.17, MongoDB 
2.2.2, and the PHP mongo driver. Except on my laptop I am still on the 1.2.12 
version of the mongo driver and I am able to login with RockMongo and edit my 
databases as it should.

Original comment by tegskywa...@gmail.com on 29 Nov 2012 at 4:33

GoogleCodeExporter commented 8 years ago
                $server = $this->_mongoHost . ":" . $this->_mongoPort;
                if (!$this->_mongoPort) {
                        $server = $this->_mongoHost;
                }

if ($this->_mongoAuth) $server = 'mongodb://' . $username . ':' . $password . 
'@' . $server . '/' . $db;

                try {
                        $this->_mongo = new Mongo($server, $this->_mongoOptions);
                        $this->_mongo->setSlaveOkay(true);
                }
                catch(Exception $e) {
                        echo "Unable to connect MongoDB, please check your configurations. MongoDB said:" . $e->getMessage() . ".";
                        exit();
                }

                // changing timeout to the new value
                MongoCursor::$timeout = $this->_mongoTimeout;

if ($this->_mongoAuth) return $this->_mongo;

                //auth by rock
                else if ($this->_controlAuth) {
                        if (!isset($this->_controlUsers[$username]) || $this->_controlUsers[$username] != $password) {
                                return false;
                        }

Issue is in the "models/MServer.php" code inside the auth() function.  

Original comment by nicho...@hellohunter.com on 30 Nov 2012 at 8:22

GoogleCodeExporter commented 8 years ago
So I fixed it with the removal of a block of code and the addition of two 
lines.  Now everything works properly.  See my code changes above.  The lines 
that aren't tabbed in are the new ones.

Original comment by nicho...@hellohunter.com on 30 Nov 2012 at 8:23

GoogleCodeExporter commented 8 years ago
Your fix for the MServer.php file worked. Be sure to get in contact with the 
maintainer of the project about your fix so he can put in a newer RockMongo as 
soon as possible. Will this code change also work with the 1.2 series of the 
PHP mongo extension? If so, he can release a new version that covers both the 
old and new versions of the PECL extension without having to put in extra code 
to check for versions and then apply the new code or keep the old.

Original comment by tegskywa...@gmail.com on 30 Nov 2012 at 5:17

GoogleCodeExporter commented 8 years ago
how should the config look when applying the MServer fix above?

Original comment by sc...@mtrlog.com on 30 Nov 2012 at 6:03

GoogleCodeExporter commented 8 years ago
Sorry all, but what should I specifically to change to patch this problem? I'd 
definitely loving see this fixes as soon as possible.

Original comment by jaakko.t...@gmail.com on 8 Dec 2012 at 1:13

GoogleCodeExporter commented 8 years ago
Hi, i am RockMongo maintainer, In fact, wen i try to connect MongoDB (mongo 
1.3.0) using "mongodb://username:password@host/db", my web server will be 
crashed, mongo driver should be a bug.

Original comment by iwind....@gmail.com on 13 Dec 2012 at 10:07

GoogleCodeExporter commented 8 years ago
There are too many segfault issue in MongoDB php driver after 1.3.0, so every 
one is not encouraged to this version. 

Original comment by iwind....@gmail.com on 13 Dec 2012 at 10:21

GoogleCodeExporter commented 8 years ago
http://pecl.php.net/package-changelog.php?package=mongo

Original comment by iwind....@gmail.com on 13 Dec 2012 at 10:24