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

Incompatibility with Mariaex for users with empty password #63

Closed
danxexe opened this issue Jul 3, 2019 · 2 comments

Comments

Projects
None yet
2 participants
@danxexe
Copy link

commented Jul 3, 2019

Mariaex behaviour:

iex> {:ok, pid} = Mariaex.start_link(username: "user", password: "", database: "app_test")
{:ok, #PID<0.400.0>}

MyXQL behaviour:

iex> {:ok, pid} = MyXQL.start_link(username: "user", password: "", database: "app_test")
{:ok, #PID<0.408.0>}
19:11:08.187 [error] MyXQL.Connection (#PID<0.410.0>) failed to connect: ** (MyXQL.Error) (1045) (ER_ACCESS_DENIED_ERROR) Access denied for user 'user'@'localhost' (using password: YES)

Using nil as password works as expected:

iex> {:ok, pid} = MyXQL.start_link(username: "user", password: nil, database: "app_test")
{:ok, #PID<0.416.0>}

One of the issues with this incompatibility is that it breaks using urls when configuring a repo with ecto since ecto will parse the password as an empty string for such cases:

iex> Ecto.Repo.Supervisor.parse_url("mysql://user:@127.0.0.1:3306/app_test")
[
  username: "user",
  password: "",
  database: "app_test",
  hostname: "127.0.0.1",
  port: 3306
]

The obvious workaround is to simply not use url and use password: nil instead when configuring a repo.

This behaviour is a bit surprising, I believe it should be either fixed or at least documented here.

@wojtekmach

This comment has been minimized.

Copy link
Member

commented Jul 3, 2019

iex> Ecto.Repo.Supervisor.parse_url("mysql://user:@127.0.0.1:3306/app_test")
The obvious workaround is to simply not use url and use password: nil instead when configuring a repo.

Passing the url as "mysql://user@127.0.0.1:3306/app_test" (without specifying password) would work too.

I think it makes sense to transform password "" into nil, will work on a patch.

@danxexe

This comment has been minimized.

Copy link
Author

commented Jul 3, 2019

Passing the url as "mysql://user@127.0.0.1:3306/app_test" (without specifying password) would work too.

Didn't think of that 🤦‍♂.

I think it makes sense to transform password "" into nil, will work on a patch.

Cool, it's probably best to keep it as compatible as possible with mariaex.

@wojtekmach wojtekmach closed this in cd3a5ba Jul 3, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.