-
-
Notifications
You must be signed in to change notification settings - Fork 138
Support caching_sha2_password
authentication mode
#358
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 caching_sha2_password
authentication mode
#358
Conversation
b68c826
to
8ac79ea
Compare
8ac79ea
to
6873171
Compare
...c/src/main/java/com/github/jasync/sql/db/mysql/decoder/AuthenticationSwitchRequestDecoder.kt
Outdated
Show resolved
Hide resolved
mysql-async/src/main/java/com/github/jasync/sql/db/mysql/codec/MySQLFrameDecoder.kt
Show resolved
Hide resolved
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.
Workaround for a breaking change in MySQL 8.0. Reference
@oshai Ready for review. Please take a look when you have time. |
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.
Thanks for the PR! it's awesome!
Left some few minor comments.
One question about testing - IIUC we now moved to caching_sha2_password
for all tests (because of the upgrade to mysql8).
Do you think it worth adding tests for all auth methods supported?
mysql-async/src/main/java/com/github/jasync/sql/db/mysql/codec/MySQLFrameDecoder.kt
Show resolved
Hide resolved
...nc/src/main/java/com/github/jasync/sql/db/mysql/encoder/auth/Sha256PasswordAuthentication.kt
Outdated
Show resolved
Hide resolved
I'll try to add something to cover all of them. 👍 |
// The native authentication handshake will provide a 20-byte challenge. | ||
// Use the first 8 bytes as the old password authentication challenge. | ||
val challenge = if (seed.length == 20) { | ||
seed.copyOf(8) | ||
} else { | ||
seed | ||
} |
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.
Without this, a "bad handshake" error is thrown. Reference
If the server announces Native Authentication in the
Protocol::Handshake
packet the client may use the first 8 bytes of its 20-byte auth_plugin_data as input.
Let me know once it's ready, thanks! |
Ready for another review! I've added a TODO, which I'll resolve in the next PR. |
LGTM! |
Thanks for the effort! Released 2.1.12 with the PR. |
Description
This PR implements partial support for
caching_sha2_password
mode. Closes #297.Specifically, it supports the fast authentication path, while the full authentication path is over SSL only.
See
priority #1
described on this page. This should hopefully cover the majority of cases using this authentication mode. I'll try to implement the rest in a separate PR.Detailed changes
CachingSha2PasswordAuthentication
andSha256PasswordAuthentication
.AuthMoreDataMessage
and the necessary decoders. This is required to switch from fast to full authentication mode when the password is not cached yet on the server.AuthenticationSwitchRequest
to consume all bytes.OldPasswordAuthentication
to handle native authentication handshakes.