-
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
Support MySQL 8 Authentication #2233
Open
nwoltman
wants to merge
4
commits into
mysqljs:master
Choose a base branch
from
nwoltman:caching-sha2-password
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.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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,17 @@ | ||
module.exports = AuthMoreDataPacket; | ||
function AuthMoreDataPacket(options) { | ||
options = options || {}; | ||
|
||
this.status = 0x01; | ||
this.data = options.data; | ||
} | ||
|
||
AuthMoreDataPacket.prototype.parse = function parse(parser) { | ||
this.status = parser.parseUnsignedNumber(1); | ||
this.data = parser.parsePacketTerminatedString(); | ||
}; | ||
|
||
AuthMoreDataPacket.prototype.write = function parse(writer) { | ||
writer.writeUnsignedNumber(this.status); | ||
writer.writeString(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = ClearTextPasswordPacket; | ||
function ClearTextPasswordPacket(options) { | ||
this.data = options.data; | ||
} | ||
|
||
ClearTextPasswordPacket.prototype.write = function write(writer) { | ||
writer.writeNullTerminatedString(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module.exports = FastAuthSuccessPacket; | ||
function FastAuthSuccessPacket() { | ||
this.status = 0x01; | ||
this.authMethodName = 0x03; | ||
} | ||
|
||
FastAuthSuccessPacket.prototype.parse = function parse(parser) { | ||
this.status = parser.parseUnsignedNumber(1); | ||
this.authMethodName = parser.parseUnsignedNumber(1); | ||
}; | ||
|
||
FastAuthSuccessPacket.prototype.write = function write(writer) { | ||
writer.writeUnsignedNumber(1, this.status); | ||
writer.writeUnsignedNumber(1, this.authMethodName); | ||
}; |
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,12 @@ | ||
module.exports = HandshakeResponse41Packet; | ||
function HandshakeResponse41Packet() { | ||
this.status = 0x02; | ||
} | ||
|
||
HandshakeResponse41Packet.prototype.parse = function write(parser) { | ||
this.status = parser.parseUnsignedNumber(1); | ||
}; | ||
|
||
HandshakeResponse41Packet.prototype.write = function write(writer) { | ||
writer.writeUnsignedNumber(1, this.status); | ||
}; |
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,15 @@ | ||
module.exports = PerformFullAuthenticationPacket; | ||
function PerformFullAuthenticationPacket() { | ||
this.status = 0x01; | ||
this.authMethodName = 0x04; | ||
} | ||
|
||
PerformFullAuthenticationPacket.prototype.parse = function parse(parser) { | ||
this.status = parser.parseUnsignedNumber(1); | ||
this.authMethodName = parser.parseUnsignedNumber(1); | ||
}; | ||
|
||
PerformFullAuthenticationPacket.prototype.write = function write(writer) { | ||
writer.writeUnsignedNumber(1, this.status); | ||
writer.writeUnsignedNumber(1, this.authMethodName); | ||
}; |
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
Oops, something went wrong.
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.
this needs to be changed to rolling xor, otherwise it'll fail for password longer than 19 characters
See discussion at sidorares/node-mysql2#1044
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.
Yea, I've been working to fix this PR up over the past week and I did notice that long passwords didn't work on the new auth. There are a bunch of other little minor issues I've been finding as well. I didn't intend to list them out and was just intending to push up all the changes here then merge, but let me know if you think I should list them all out in addition to pushing up the fixes.
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.
Note that mysql2 is using slightly different api for this. No config required, and if you need to use non-defaults you pass custom configured plugin as
authPlugins: { caching_sha2_password: XXXX }
. Should not be a big problems for user migrating both ways mysql<->mysql2