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

Allow to connect with arbitrary plugin #2143

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sidorares
Copy link
Owner

@sidorares sidorares commented Jul 20, 2023

WIP

Currently mysql2 driver always tries to connect with mysql_native_password plugin. For the servers supporting PLUGIN_AUTH and configured to use plugins other than mysql_native_password initial connection is usually followed by AUTH_SWITCH_REQUEST packet and additional handshake with another plugin. This PR will allow to use plugins other than mysql_native_password in the initial client hello response. The order of preference on the plugin used during connection is:

  • if the server does not support plugin authorisation and secure auth server capability flag is set - mysql_native_password ( aka auth4.1 )
  • if the server does not support plugin authorisation and secure auth server capability flag is not set- pre auth4.1 token
  • plugin indicated by defaultAuthenticationPlugin config parameter name, if set ( error if the parameter is set but no standard or user provided plugin under this name )
  • plugin returned in auth_plugin_name server hello packet field ( error if plugin not configured )
  • "mysql_native_password" if no defaultAuthenticationPlugin or serverHello.auth_plugin_name

related issues:

@github-actions
Copy link
Contributor

Coverage report

The coverage rate is 89.2977066514253%

The branch rate is 84.63687150837988%

100% of new lines are covered.

…andshake command and calculate it based on selected auth plugin
@123FLO321
Copy link

Any update on this MR?
Currently ProxySQL does not support Auth Switch, making it fail to connect when not using mysql_native_password.
The possibility to specify the inital auth method, added in this mr, should solve this.

@sidorares
Copy link
Owner Author

@wellwelwel I'm going to resurrect work on this, hope to make some progress in the coming days.
Main benefit is that it can dramatically improve performance of short lived connections as there is no need to re-negotiate caching_sha2_password method.

Since mysql v8 and above is widely adopted now, what happens for the majority of clients is this:

S: hey, I'm mysql v9.2. I support authentication plugins, prefer connection using caching_sha2_password. Here is my random data to start handshake
C: Hello, I'm going to connect using 'mysql_native_password'!
S: No, please use caching_sha2_password. Here is my random data again to start handshake
C: Ok then ( continues caching_sha2_password sequence )

At least 1 full roundtrip can be easily avoided

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Node Express Server Using node-mysql2 Crashes Periodically Due to Reliance on Deprecated Authentication Plugin
3 participants