-
Notifications
You must be signed in to change notification settings - Fork 680
Feat/341/rework password logic #1436
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
base: main
Are you sure you want to change the base?
Conversation
|
@rolandwalker
For the first point, this moves the -p logic to the earliest possible place. It's at best a minuscule amount faster, but barely noticeable. The majority of the delay is the "startup" time, which just takes a bit. But with this, any improvements we do make in the future to speed up the startup time will further reduce the time until password prompt. For the second point, -p will now be usable by itself (just -p) to open a password prompt. It can also be used to enter the password in cleartext, like "-pMYPASS or -p MYPASS". That is the one difference with the vendor client; with the vendor client you can't do "-p MYPASS" as it treats the value as the DB when there is a space in between. I could not duplicate that functionality with click. I don't believe that's a big deal, but wanted to point it out anyway. |
…w that -p exists.
|
This is great, but it gives |
…was different than I originally thought.
While testing examples for my reply I realized the vendor client actually will prompt you if you give it --password without a value, so that changes this a little bit. So I updated the code; let me know if this is any better, and if not, what you actually don't like about it. Behavior with this PR: mycli --password = prompt for password, matches vendor So at this point the PR basically gets us the ability to prompt for the password without failing connection first, and moves the prompt to the earliest possible point. |
|
I didn't think it was possible to make |
|
One regression is that used to fail internally and then retry with a password prompt. Now there is a hard failure. Another issue is that a DSN is a positional argument. But if one writes then the DSN is incorrectly consumed as the password. That's probably survivable. We can just advertise that |
@rolandwalker This was intentional, that is vendor client behavior. I can add a check back in, but it gets wonky dealing with empty passwords. But if you would prefer that I can take another look to see what's possible.
This I'll have to think about more to see if there might be a way to deal with that. |
If we were starting fresh it could be reasonable to follow the vendor client strictly. But we aren't, and making that change now would inevitably break people's current workflows. I suppose the behavior is as if |
No problem, I'll take a look at that as well and duplicate the original functionality. |
|
@rolandwalker As you probably guessed the issue with this is that there is no way to tell if the user is trying to specify a database/DNS or a password when the password options can act as both a flag (no arg given) and a normal option (arg given). I.e. So if we want to have the You did not seem to care for that option though (different behavior/semantics between Possible behavior would be: mycli -p = prompt user for password None of these would work: Let me know what you think. |
Description
Updates the password handling functionality as follows:
1. -p / --pass/--password CLI options
2. envvar (MYSQL_PWD)
3. DSN (mysql://user:password)
4. cnf (.my.cnf / etc)
6. --password-file CLI option
Closes #341
Checklist
changelog.md.AUTHORSfile (or it's already there).uv run ruff check && uv run ruff format && uv run mypy --install-types .to lint and format the code.