Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[CONJS-248] Ensuring not importing file after pool.end() #239
  • Loading branch information
rusher committed Apr 14, 2023
1 parent ed216da commit ec33a78
Showing 1 changed file with 17 additions and 35 deletions.
52 changes: 17 additions & 35 deletions lib/cmd/handshake/handshake.js
Expand Up @@ -9,6 +9,15 @@ const Errors = require('../../misc/errors');
const Capabilities = require('../../const/capabilities');
const Collations = require('../../const/collations');

const authenticationPlugins = {
mysql_native_password: require('./auth/native-password-auth.js'),
mysql_clear_password: require('./auth/clear-password-auth'),
client_ed25519: require('./auth/ed25519-password-auth'),
dialog: require('./auth/pam-password-auth'),
sha256_password: require('./auth/sha256-password-auth'),
caching_sha2_password: require('./auth/caching-sha2-password-auth')
};

/**
* Handle handshake.
* see https://mariadb.com/kb/en/library/1-connecting-connecting/
Expand Down Expand Up @@ -199,41 +208,14 @@ class Handshake extends Command {
authReject,
multiAuthResolver
) {
let pluginAuth;
switch (pluginName) {
case 'mysql_native_password':
pluginAuth = require('./auth/native-password-auth.js');
break;

case 'mysql_clear_password':
pluginAuth = require('./auth/clear-password-auth.js');
break;

case 'client_ed25519':
pluginAuth = require('./auth/ed25519-password-auth.js');
break;

case 'dialog':
pluginAuth = require('./auth/pam-password-auth.js');
break;

case 'sha256_password':
pluginAuth = require('./auth/sha256-password-auth.js');
break;

case 'caching_sha2_password':
pluginAuth = require('./auth/caching-sha2-password-auth.js');
break;

//TODO "auth_gssapi_client"

default:
throw Errors.createFatalError(
`Client does not support authentication protocol '${pluginName}' requested by server.`,
Errors.ER_AUTHENTICATION_PLUGIN_NOT_SUPPORTED,
info,
'08004'
);
let pluginAuth = authenticationPlugins[pluginName];
if (!pluginAuth) {
throw Errors.createFatalError(
`Client does not support authentication protocol '${pluginName}' requested by server.`,
Errors.ER_AUTHENTICATION_PLUGIN_NOT_SUPPORTED,
info,
'08004'
);
}
return new pluginAuth(packSeq, compressPackSeq, pluginData, cmdParam, authResolve, authReject, multiAuthResolver);
}
Expand Down

0 comments on commit ec33a78

Please sign in to comment.