Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support mysql_native_password auth switch request for Azure
- Loading branch information
1 parent
525960c
commit e8fea70
Showing
10 changed files
with
157 additions
and
7 deletions.
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,20 @@ | ||
module.exports = AuthSwitchRequestPacket; | ||
function AuthSwitchRequestPacket(options) { | ||
options = options || {}; | ||
|
||
this.status = 0xfe; | ||
this.authMethodName = options.authMethodName; | ||
this.authMethodData = options.authMethodData; | ||
} | ||
|
||
AuthSwitchRequestPacket.prototype.parse = function parse(parser) { | ||
this.status = parser.parseUnsignedNumber(1); | ||
this.authMethodName = parser.parseNullTerminatedString(); | ||
this.authMethodData = parser.parsePacketTerminatedBuffer(); | ||
}; | ||
|
||
AuthSwitchRequestPacket.prototype.write = function write(writer) { | ||
writer.writeUnsignedNumber(1, this.status); | ||
writer.writeNullTerminatedString(this.authMethodName); | ||
writer.writeBuffer(this.authMethodData); | ||
}; |
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,14 @@ | ||
module.exports = AuthSwitchResponsePacket; | ||
function AuthSwitchResponsePacket(options) { | ||
options = options || {}; | ||
|
||
this.data = options.data; | ||
} | ||
|
||
AuthSwitchResponsePacket.prototype.parse = function parse(parser) { | ||
this.data = parser.parsePacketTerminatedBuffer(); | ||
}; | ||
|
||
AuthSwitchResponsePacket.prototype.write = function write(writer) { | ||
writer.writeBuffer(this.data); | ||
}; |
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
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,36 @@ | ||
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 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.handshake({ | ||
user : connection.config.user, | ||
password : connection.config.password, | ||
authMethodName : 'mysql_native_password', | ||
authMethodData : Buffer.from('00112233445566778899AABBCCDDEEFF0102030400', 'hex') | ||
}); | ||
}); | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
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(); | ||
|
||
server.listen(common.fakeServerPort, function (err) { | ||
assert.ifError(err); | ||
|
||
connection.connect(function (err) { | ||
assert.ok(err); | ||
assert.equal(err.code, 'UNSUPPORTED_AUTH_METHOD'); | ||
assert.equal(err.fatal, true); | ||
assert.ok(/foo_plugin_password/.test(err.message)); | ||
|
||
connection.destroy(); | ||
server.destroy(); | ||
}); | ||
}); | ||
|
||
server.on('connection', function(incomingConnection) { | ||
incomingConnection.handshake({ | ||
user : connection.config.user, | ||
password : connection.config.password, | ||
authMethodName : 'foo_plugin_password', | ||
authMethodData : Buffer.alloc(0) | ||
}); | ||
}); |