-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Pass credentials as parameters #753
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
Conversation
- Adding the credentials via dsn causes problems when the password contains an @ symbol
I would prefer having the username and password outside of the That way it is a bit more similar to the mysql connection configuration, and might be more obvious for new users. |
Ok, I will change that back and add the credentials to the constructor in the |
- Reverted the config changes - The credentials are now added to the MongoDB constructor if they are not already present - Also fixed failing test by changing method access level
Ok, so the changes I've made are as followed. I've reverted the readme as no changes are there and I've changed the access level of a method because it was different from the access level of the method it was overriding. But it seems I've managed to mess up the tests... I'll be fixing those next :) |
@@ -136,6 +136,14 @@ protected function createConnection($dsn, array $config, array $options) | |||
$driverOptions = $config['driver_options']; | |||
} | |||
|
|||
// Check if the credentials are not already set in the options | |||
if (!isset($options['username'])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you turn this into:
if (! isset($options['username']) && isset($config['username'])) {
$options['username'] = $config['username'];
And below as well:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I've seen that that is indeed where the problem was.
I've got the test suite running locally now as well so I can test before pushing bad code again.
I want to test the entire suite before pushing so I just need to get MySQL up and running, after that I will submit the new changes again
- If no user was given an empy user was set resulting in an error
Tests are working again. Applied the change you found as well. |
Can you squash your commits? |
Pass credentials as parameters
Ah sorry missed the notification. |
You are not checking if the credentials are empty. This resulty in an "Authentication failed." exception.
to:
Or is it just me? |
I added it back again. |
Hmm, I see what you mean. By having an empty username and password a user might be alerted for a misconfiguration in the .env file. *edit: Because this has no inpact on my way of using it what so ever I don't mind the empty check t.b.h. |
Pass credentials as parameters
These changes will pass the credentials as parameters at the creation of a new MongoDB connection instead of passing them on the DSN.
reference: #748
Username and password now need to be in the options section of the DB config