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

Mysql 8 fixes #1021

Merged
merged 26 commits into from
Oct 2, 2019
Merged

Mysql 8 fixes #1021

merged 26 commits into from
Oct 2, 2019

Conversation

sidorares
Copy link
Owner

still WIP, but tests pass and I think now it's only matter of adding docs

  • "authSwitchHandler" is deprecated in favour of "authPlugins"
  • mysql8 specific tests fixed ( mostly GRANT not creating users and standard geometry functions name update )
  • Add SSL-enabled server to test matrix and test all combos of compression + ssl
  • add default authPlugin for caching_sha2_password and mysql_native_password auth methods

this would not be possible without mysqljs/mysql#1962

cc @ruiquelhas and @johannes

some related previous API discussion:
mysqljs/mysql#1793
#560

should fix:
#906
#991

@RedactedProfile
Copy link

I know you just merged this into master 2 days ago, but might I ask when NPM will be triggered with a release for this? Thanks

@sidorares
Copy link
Owner Author

@RedactedProfile the plan is to bump major version, and just to be on the safe side release -alpha1 and have it for few days. I'll try to publish alpha release today, would be good to have you among early testers. I'll post a comment here when published

@sidorares sidorares deleted the auth-plugins branch October 26, 2019 12:06
@treyhuffine
Copy link

Thanks for the hard work in making this happen @sidorares :)

@mwalden2004
Copy link

Looks like I'm still having issues with 8.0, and sha256_password. Getting:

Error: Server requests authentication using unknown plugin sha256_password. See TODO: add plugins doco here on how to configure or author authentication plugins.

@sidorares
Copy link
Owner Author

what's your server version @mwalden2004 ? Plugin name is different from what most 8.x server report ( notice it's sha256_password and not caching_sha2_password )

@mwalden2004
Copy link

mwalden2004 commented Nov 28, 2019

Didn't notice, sorry! The version is 8.0.18. Trying everything I can to fix this error, but no matter what I change the users plugin type to, it doesn't work.

@sidorares
Copy link
Owner Author

sidorares commented Nov 28, 2019

you could manually alias it like this:

const caching_sha2_password = require('mysql2/lib/auth_plugins/caching_sha2_password.js');
const connection = mysql.createConnection({
  authPlugins: { 
      sha256_password: caching_sha2_password({})
  }
})

( didn't test that but hope you get the idea )

@mwalden2004
Copy link

Still getting the same error with that code, I made sure that I am running the latest version of mysql2. Don't know what to do from here. Thank you for the assistance so far.

@sidorares
Copy link
Owner Author

could you try to debug this lines ( with console.log or debugger ) ?

if (!authPlugin) {
authPlugin = standardAuthPlugins[pluginName];
}
if (!authPlugin) {
throw new Error(
`Server requests authentication using unknown plugin ${pluginName}. See ${'TODO: add plugins doco here'} on how to configure or author authentication plugins.`
);
}
connection._authPlugin = authPlugin({ connection, command });

check spelling and what server expects vs what is actually in authPlugins

Note that I slightly updated the example, require('mysql2/lib/auth_plugins/caching_sha2_password.js') returns plugin factory function and you need to use plugin instance in the config

@sidorares
Copy link
Owner Author

@ruiquelhas any idea what servers return sha256_password as plugin name? Is it the same as caching_sha2_password ? Should I add alias?

@mwalden2004
Copy link

Okay, looking into this now. So it looks like authSwitchRequest is called two times, the first it sends in sha256_password as the plugin name, and the second time standardAuthPlugins is undefined. After which it appears it errors out with the throw Error()

@mwalden2004
Copy link

I've added an alias inside the auth switch, and now it's trying to force me to use root! I'll look into this in the morning. Good night!

@ruiquelhas
Copy link
Contributor

ruiquelhas commented Nov 28, 2019

@sidorares sha256_password is a different plugin, but it's definitely not the default one. So, somehow, the default_authentication_plugin server option was overridden, either via config file or via the --default-authentication-plugin startup option.

https://dev.mysql.com/doc/refman/8.0/en/sha256-pluggable-authentication.html

@sidorares
Copy link
Owner Author

@mwalden2004 looks like using caching_sha2_password here is wrong approach, either you need to configure server to use different auth plugin or we need to add sha256_password support

@johannes
Copy link

Adding support for sha256_password isn't rocket science, but I would advise against usage ... it might be worthwhile with 5.7 or older servers as password storage on the server is more secure than mysql_native_password (which is relevant for threat cases where an attacker gains access to crypted passwords i.e. from a leaked server backup or something) but on 8.0 servers (thus anything new) the caching variant is notable faster, while bringing the same security benefits over the old native password.

@mwalden2004
Copy link

Well here is where this gets really interesting, I have two other projects running off this database on the server running mysql2, but this is the only one having any issues. I also am not using sha256_password, looks like it is being forced...

@sidorares
Copy link
Owner Author

auth plugin can be configured per user / ip. Are those same for two other projects?

@mwalden2004
Copy link

They are the same.

@pokurrunku
Copy link

@mwalden2004 did you find any solution for sha256_password

joe-re added a commit to joe-re/sql-language-server that referenced this pull request Jul 19, 2020
joe-re added a commit to joe-re/sql-language-server that referenced this pull request Jul 19, 2020
* add mysql environment to dev

* use mysql2 instead of mysql to support Mysql8

sidorares/node-mysql2#1021
@Pezhvak
Copy link

Pezhvak commented Sep 20, 2020

this happened to me as well, it was working fine, all of the sudden it stopped working

@sidorares
Copy link
Owner Author

Hi @Pezhvak can you clarify exactly what stopped working?

Note that we recently added support for sha256_password auth plugin and it's still relatively experimental

@Pezhvak
Copy link

Pezhvak commented Sep 21, 2020

@sidorares it started giving me that error message which i didn't get before, it turns out to be a problem with terminal which runs it, if i run it on iterm i get that error, if i run it inside phpstorm i don't get that (using run feature of the ide), i can experiment more and let you know if you will.

@johannes
Copy link

@Pezhvak are you using the same node installation? I could imagine that you might have a global installation with a different version and one node installation picks it up, giving you old code. Running console.log(require.main.paths) and console.log(require.resolve('mysql2')) could help to verify this.

@Pezhvak
Copy link

Pezhvak commented Sep 21, 2020

i will check it and get back to you @johannes

@TheDirigible
Copy link

This just started happening to me out of nowhere, after Windows Terminal updated. I don't have any plugin, I don't know what that message is talking about.

@Pezhvak
Copy link

Pezhvak commented Sep 26, 2020

this happened to me, it seems to be something related to user or where from you call your file

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.

10 participants