Closed athoune closed 2 years ago
🚧 Never link to branches, share a permalink 🚧
y
NOTE: edit your post and fix it with a permalink!
ok, it's more readable with permalinks, sorry.
I can authenticate with an ugly hack in config.php :
$mongo_hostname = getenv('XHGUI_MONGO_HOSTNAME') ?: '127.0.0.1';
$mongo_port = getenv('XHGUI_MONGO_PORT') ?: 27017;
$mongo_username = getenv('XHGUI_MONGO_USER') ?: 'xhprof';
$mongo_password = getenv('XHGUI_MONGO_PASSWORD') ?: 'pazzword';
return [
'db.host' => "mongodb://$mongo_username:$mongo_password@$mongo_hostname:$mongo_port",
// lots of config here
];
The point of permalinks is that links stay working if code is changed.
From this changeset:
I read that password should go under 'options'. Did you try that?
you seem to be using old db.host
syntax, you should use new syntax that the PR introduced, and is present as an example in config as well: config/config.default.php
.
hum, I mess something with too many moving parts, mongodb image changed its behavior. I didn't notice when user wasn't created in mongodb, and when I put username/password in the wrong place (outside 'options').
'mongodb' => [
'options' => [
'username' => getenv('XHGUI_MONGO_USER') ?: 'xhprof',
'password' => getenv('XHGUI_MONGO_PASSWORD') ?: 'pazzword',
],
]
It works.
Sorry for the noise.
@athoune please close the issue if problem solved!
@athoune what you think can the 'username'/'password' filled by default with null
or false
, or that will break setups where authentication is not enabled?
I was thinking, that maybe setup to config/config.default.php
:
'mongodb' => [
'options' => [
'username' => getenv('XHGUI_MONGO_USERNAME') ?: null,
'password' => getenv('XHGUI_MONGO_PASSWORD') ?: null,
],
]
@athoune hallo?
Your patch is nice, thanks.
@athoune can you please answer the question I asked you?
@athoune?
@athoune where did you go?
please answer the question:
Pity, when the user wants something, the developer needs to respond, but when the developer wants contribution back the user disappears.
XHGui use https://github.com/alcaeus/mongo-php-adapter, and it says :
In https://github.com/perftools/xhgui/blob/99d2d88f70d4a54f4a161dece9b106c3eb72e349/src/ServiceProvider/MongoStorageProvider.php#L46 the
MongoClient
is configured without username/password.I set auth in
config.php
as suggested here https://github.com/perftools/xhgui/blob/99d2d88f70d4a54f4a161dece9b106c3eb72e349/config/config.default.php#L30 but this error happensMongoDB\Driver\Exception\ServerException: command find requires authentication in /var/www/vendor/mongodb/mongodb/src/Operation/Find.php:280
Is it possible to uses mongodb with a username/password ?