Skip to content
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

Connection DSN can omit password #971

Merged
merged 1 commit into from
Mar 2, 2022
Merged

Conversation

DarkSide666
Copy link
Member

We can have connection string with empty password and in such case password is not set in dsn array.
This should fix that.

For example

'dsn' => "mysql://root@localhost:3307/my_dbase;charset=utf8mb4",

@@ -52,7 +52,7 @@ public static function connect($dsn, string $user = null, string $password = nul
case 'pdo_sqlsrv':
case 'pdo_oci':
case 'oci8':
$persistence = new Persistence\Sql($dsn, $dsn['user'], $dsn['password'], $args);
$persistence = new Persistence\Sql($dsn, $dsn['user'] ?? null, $dsn['password'] ?? null, $args);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

connection string with empty password and in such case password is not set in dsn array

why $dsn['user'] ?? null then?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, why not to use http://username:@example.com as DSN for empty password?

Copy link
Member Author

@DarkSide666 DarkSide666 Mar 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http://username:@ also don't set password key in dsn array and using ?? null to avoid exception in case password (or user) keys are not set in dsn array.
Maybe we need to do this validation in Connection class instead and always pass user and password keys even if they are null (not set).

@mvorisek
Copy link
Member

mvorisek commented Mar 2, 2022

PR LGTM, especially for sqlite DSN

@mvorisek mvorisek changed the title connection strings can omit password Connection DSC can omit password Mar 2, 2022
@mvorisek mvorisek changed the title Connection DSC can omit password Connection DSN can omit password Mar 2, 2022
@mvorisek mvorisek merged commit fd25cb8 into develop Mar 2, 2022
@mvorisek mvorisek deleted the feature/fix_empty_password branch March 2, 2022 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants