-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add support for 'mysql_clear_password - continued #2327
Open
ZJONSSON
wants to merge
10
commits into
mysqljs:master
Choose a base branch
from
ZJONSSON:master-nmggithub
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+114
−5
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8688bea
change handling of user-set flags
nmggithub cced61f
add support for 'mysql_clear_password' auth plugin
nmggithub fe3cef2
add tests
nmggithub 9fb9c88
Delete test as it only passes for specific servers
nmggithub 56428eb
Add unit test
ZJONSSON 6a785ae
Ensure that `mysql_clear_password` is never used over insecure connec…
ZJONSSON 65368e4
Rename this._tls to this.secureConnection and fold into options
ZJONSSON 810dfb0
* Revert generic SSL flag
ZJONSSON 63f6bfe
Revert flag merging to use blacklist
ZJONSSON 6753e1b
use safe-buffer (compatibility with older node versions)
ZJONSSON File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
var assert = require('assert'); | ||
var common = require('../../common'); | ||
|
||
common.getTestConnection({ flags: ['+PLUGIN_AUTH'] }, function (err, connection) { | ||
assert.ifError(err, 'got error'); | ||
connection.destroy(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
var assert = require('assert'); | ||
var Buffer = require('safe-buffer').Buffer; | ||
var common = require('../../common'); | ||
var connection = common.createConnection({ | ||
port : common.fakeServerPort, | ||
password : 'authswitch' | ||
}); | ||
|
||
var server = common.createFakeServer(); | ||
|
||
var error; | ||
server.listen(common.fakeServerPort, function (err) { | ||
assert.ifError(err); | ||
|
||
connection.connect(function (err) { | ||
error = err; | ||
connection.destroy(); | ||
server.destroy(); | ||
}); | ||
}); | ||
|
||
server.on('connection', function(incomingConnection) { | ||
incomingConnection.on('authSwitchResponse', function (packet) { | ||
this._sendAuthResponse(packet.data, Buffer.from('authswitch')); | ||
}); | ||
|
||
incomingConnection.on('clientAuthentication', function () { | ||
this.authSwitchRequest({ | ||
authMethodName : 'mysql_clear_password', | ||
authMethodData : Buffer.alloc(0) | ||
}); | ||
}); | ||
|
||
incomingConnection.handshake(); | ||
}); | ||
|
||
process.on('exit', function() { | ||
assert.equal(error.message, 'Authentication method mysql_clear_password not supported on insecure connections'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
var assert = require('assert'); | ||
var Buffer = require('safe-buffer').Buffer; | ||
var common = require('../../common'); | ||
var connection = common.createConnection({ | ||
port : common.fakeServerPort, | ||
password : 'authswitch', | ||
ssl : { | ||
rejectUnauthorized: false | ||
} | ||
}); | ||
|
||
var server = common.createFakeServer(); | ||
|
||
var connected; | ||
server.listen(common.fakeServerPort, function (err) { | ||
assert.ifError(err); | ||
|
||
connection.connect(function (err, result) { | ||
assert.ifError(err); | ||
|
||
connected = result; | ||
|
||
connection.destroy(); | ||
server.destroy(); | ||
}); | ||
}); | ||
|
||
server.on('connection', function(incomingConnection) { | ||
incomingConnection.on('authSwitchResponse', function (packet) { | ||
this._sendAuthResponse(packet.data, Buffer.from('authswitch')); | ||
}); | ||
|
||
incomingConnection.on('clientAuthentication', function () { | ||
this.authSwitchRequest({ | ||
authMethodName : 'mysql_clear_password', | ||
authMethodData : Buffer.alloc(0) | ||
}); | ||
}); | ||
|
||
incomingConnection.handshake({ | ||
serverCapabilities1: 512 | 1 << 11 // PROTOCOL_41 and SSL | ||
}); | ||
}); | ||
|
||
process.on('exit', function() { | ||
assert.equal(connected.fieldCount, 0); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get where this is coming from, but is probably going to be limiting to users in the long run. What about just adding an option the user can use to enable / disable this? I'm thinking along the lines of our
insecureAuth
option (perhapsclearAuth
?) and how themysql
command line program requires a flag to enable it (https://dev.mysql.com/doc/refman/8.0/en/mysql-command-options.html#option_mysql_enable-cleartext-plugin).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the
--enable-cleartext-plugin
is just to enable the plugin itself. Are you thinking theinsecureAuth
would allow clear_password even if we are not on a tls socket?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking to have it behave inline with the
mysql
command line program: add an option (like perhapsclearAuth
?) that that user must enable to use the clear password auth. That would be the only requirement -- the user can choose to use that over SSL or not as their own choice, just like in themysql
command line program.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand. Looking at the python module, if you specify
auth_plugin='mysql_clear_password'
then cleartext is used whether SSL is on or not. So maybe that would be the expected behavior.I still think there is a big difference between saying: I want to use cleartext only inside secure channel, vs I want to use cleartext no matter what. For example, some of the GUI Sql clients I tested would bail on cleartext if SSL is not turned on.
Maybe the right way is to use
clearAuth = true
to enable it for secure channel, andinsecureAuth
to allow clear to be in an unencrypted socket?