Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[CONJS-110] permit fast-authentication with 'mysql_clear_password' au…
…thentication plugin.

- fast-authentication plugin now permits 'client_ed25519', 'mysql_clear_password' or 'mysql_native_password'
- plugin 'mysql_native_password' is used by default if not matching.
- unexpected packet type during handshake result will throw a good error.
  • Loading branch information
rusher committed Feb 3, 2020
1 parent 7731ee2 commit 5417f75
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions lib/cmd/handshake/client-handshake-response.js
Expand Up @@ -22,17 +22,21 @@ module.exports.send = function send(cmd, out, opts, pluginName, info) {
info.defaultPluginName = pluginName;
const pwd = Array.isArray(opts.password) ? opts.password[0] : opts.password;
let authToken;
let authPlugin;
switch (pluginName) {
case 'mysql_native_password':
case '':
authToken = NativePasswordAuth.encryptPassword(pwd, info.seed);
break;
case 'client_ed25519':
authToken = Ed25519PasswordAuth.encryptPassword(pwd, info.seed);
authPlugin = 'client_ed25519';
break;

case 'mysql_clear_password':
authToken = Buffer.from(pwd);
authPlugin = 'mysql_clear_password';
break;

default:
authToken = Buffer.alloc(0);
authToken = NativePasswordAuth.encryptPassword(pwd, info.seed);
authPlugin = 'mysql_native_password';
break;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/cmd/handshake/handshake.js
Expand Up @@ -107,7 +107,7 @@ class Handshake extends Command {
//*********************************************************************************************************
default:
this.throwNewError(
'Unexpected type of packet during handshake phase : ' + packet.log(),
'Unexpected type of packet during handshake phase : ' + marker,
true,
info,
'42000',
Expand Down

0 comments on commit 5417f75

Please sign in to comment.