adminer icon indicating copy to clipboard operation
adminer copied to clipboard

Mongo: different login on php5 and php7

Open sinacek opened this issue 6 years ago • 14 comments

Hi, with image dockette/adminer:full I'm not able connect to Mongo, because it returns Database does not support password..

I haven't allowed login without password.

I tried the same issue on version dockette/adminer:full-php5 and it works. I was not able find out how to fix it :/

Main problem is, that wrong connection doesn't throw exception.

I'm not sure if report it here or on the adminer repo.

sinacek avatar Aug 15 '19 14:08 sinacek

Well, I've verified it in my image but I think it's not problem in there. Do you have any updates?

f3l1x avatar Aug 28 '19 07:08 f3l1x

Unfortunately not. It still doesn't work with PHP 7.

sinacek avatar Aug 28 '19 08:08 sinacek

How about now @sinacek ?

f3l1x avatar Feb 21 '20 18:02 f3l1x

Still doesn't work. docker run -ti --rm -p 80:80 -e MONGO_AUTH_SOURCE=admin dockette/adminer:full

sinacek avatar Feb 24 '20 08:02 sinacek

What is MONGO_AUTH_SOURCE? Could you point me to php doc somewhere?

f3l1x avatar Jul 26 '20 17:07 f3l1x

It's variable for authentication collection in Mongo. see https://github.com/vrana/adminer/pull/358

https://docs.mongodb.com/manual/reference/connection-string/#urioption.authSource

sinacek avatar Jul 27 '20 07:07 sinacek

image:dockette/adminer:full add env MONGO_AUTH_SOURCE=admin Still not useful. But use image:dockette/adminer:full-php5 is ok

dream-mo avatar Aug 31 '20 15:08 dream-mo

It looks like change in php versions. I don't know where is the problem now. :(

f3l1x avatar Aug 31 '20 15:08 f3l1x

https://github.com/vrana/adminer/blob/master/adminer/drivers/mongo.inc.php#L622

Is there a bug in the logic of the latest adminer code? It's just my guess. It feels weird anyway

$connection->_link = $connection->connect("mongodb://$server", $options);
if ($password != "") {       
	$options["password"] = "";
	try {
		$connection->connect("mongodb://$server", $options);
		return lang('Database does not support password.');                 // why return?
	} catch (Exception $ex) {
		// this is what we want
	}
}
return $connection;

dream-mo avatar Aug 31 '20 17:08 dream-mo

https://github.com/vrana/adminer/blob/master/adminer/drivers/mongo.inc.php#L622

Is there a bug in the logic of the latest adminer code? It's just my guess. It feels weird anyway

$connection->_link = $connection->connect("mongodb://$server", $options);
if ($password != "") {       
	$options["password"] = "";
	try {
		$connection->connect("mongodb://$server", $options);
		return lang('Database does not support password.');                 // why return?
	} catch (Exception $ex) {
		// this is what we want
	}
}
return $connection;

I try to move "return lang..." into catch, and now I'm able to connect to MongoDB. Many thanks !

GaetanNaulin avatar Sep 03 '20 13:09 GaetanNaulin

adminer-mongodb is not unstable, let's wait for it to stabilize later.

dream-mo avatar Sep 04 '20 10:09 dream-mo

Hello all, Do you have some new about adminer-mongodb? In fact, I have an authentication problem when I'm using Adminer 4.7.7. However, when I'm using Adminer 4.8, i succeded to authenticate my self, to add some data. Nevertheless, I'm not able to create a new database or a new Collection. Thanks in advance for the response.

SellamiRami avatar May 25 '21 10:05 SellamiRami

Hi @SellamiRami. Have you tried to use phar version of Adminer (https://github.com/vrana/adminer/releases/tag/v4.8.1)? We should locate this issue, if it's in adminer itself or in dockette/adminer.

f3l1x avatar May 31 '21 11:05 f3l1x

Can you please test latest version?

f3l1x avatar Aug 11 '21 14:08 f3l1x