-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Username and password not used or should we use only auth_database
#2448
Comments
Ok, I think I figured it out. |
Noted that you resolved the issue while I was typing this, but posting it anyways for the benefit of others: While you can add username and password to the connection string for MongoDB, these can also be passed via the The |
Description:
In
mongodb/src/Connection.php
There is those lines
Where
username
andpassword
are considered as options if they exist in the database configuration.But later in
When composing the DSN to be used, then
username
andpassword
are not inserted or used at all.Actually I did not find anywhere where those values are actually used.
Steps to reproduce
Add the
username
andpassword
configuration entries.2.
Try a query
3.
Authentication fails (as the credentials are not passed on the DSN
Expected behaviour
username
and `password should be used when resolving the DSN.Actual behaviour
Authentication fails so fails the query
Logs:
[2022-09-15 06:47:47] local.ERROR: Authentication failed. {"exception":"[object] (MongoDB\\Driver\\Exception\\AuthenticationException(code: 11): Authentication failed. at /srv/lrvl.dev.timesofmalta.com/source/1/vendor/mongodb/mongodb/src/Operation/Find.php:317) [stacktrace] #0 /srv/lrvl.dev.timesofmalta.com/source/1/vendor/mongodb/mongodb/src/Operation/Find.php(317): MongoDB\\Driver\\Server->executeQuery() #1 /srv/lrvl.dev.timesofmalta.com/source/1/vendor/mongodb/mongodb/src/Collection.php(666): MongoDB\\Operation\\Find->execute() #2 [internal function]: MongoDB\\Collection->find() #3 /srv/lrvl.dev.timesofmalta.com/source/1/vendor/jenssegers/mongodb/src/Collection.php(45): call_user_func_array() #4 /srv/lrvl.dev.timesofmalta.com/source/1/vendor/jenssegers/mongodb/src/Query/Builder.php(410): Jenssegers\\Mongodb\\Collection->__call() #5 /srv/lrvl.dev.timesofmalta.com/source/1/vendor/jenssegers/mongodb/src/Query/Builder.php(201): Jenssegers\\Mongodb\\Query\\Builder->getFresh() #6 /srv/lrvl.dev.timesofmalta.com/source/1/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(699): Jenssegers\\Mongodb\\Query\\Builder->get() #7 /srv/lrvl.dev.timesofmalta.com/source/1/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(683): Illuminate\\Database\\Eloquent\\Builder->getModels() #8 /srv/lrvl.dev.timesofmalta.com/source/1/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php(296): Illuminate\\Database\\Eloquent\\Builder->get() #9 /srv/lrvl.dev.timesofmalta.com/source/1/app/Http/Controllers/ArticleController.php(17): Illuminate\\Database\\Eloquent\\Builder->first() #10 /srv/lrvl.dev.timesofmalta.com/source/1/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): App\\Http\\Controllers\\ArticleController->index() #11 /srv/lrvl.dev.timesofmalta.com/source/1/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction() #12 /srv/lrvl.dev.timesofmalta.com/source/1/vendor/laravel/fThe text was updated successfully, but these errors were encountered: