8000 Support `caching_sha2_password` authentication mode by KarboniteKream · Pull Request #358 · jasync-sql/jasync-sql · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
merged 5 commits into from
Jan 15, 2023

Conversation

KarboniteKream
Copy link
Contributor
@KarboniteKream KarboniteKream commented Jan 14, 2023

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

  • Added CachingSha2PasswordAuthentication and Sha256PasswordAuthentication.
  • Added 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.
  • Fixed decoder for AuthenticationSwitchRequest to consume all bytes.
  • Fixed OldPasswordAuthentication to handle native authentication handshakes.
  • Updated container tests to run against MySQL 8.0

@KarboniteKream KarboniteKream force-pushed the feat/caching-sha2-password branch from 8ac79ea to 6873171 Compare January 15, 2023 04:25
SELECT routine_name FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name="remTest" SELECT routine_name as routine_name FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name="remTest"
Copy link
Contributor Author

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

@KarboniteKream KarboniteKream marked this pull request as ready for review January 15, 2023 04:26
@KarboniteKream
Copy link
Contributor Author

@oshai Ready for review. Please take a look when you have time.

Copy link
Contributor
@oshai oshai left a 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?

@KarboniteKream
Copy link
Contributor Author

Do you think it worth adding tests for all auth methods supported?

I'll try to add something to cover all of them. 👍

Comment on lines +17 to +23
// 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
}
Copy link
Contributor Author
@KarboniteKream KarboniteKream Jan 15, 2023

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.

@oshai
Copy link
Contributor
oshai commented Jan 15, 2023

Let me know once it's ready, thanks!

@KarboniteKream
Copy link
Contributor Author

Ready for another review! I've added a TODO, which I'll resolve in the next PR.

@oshai
Copy link
Contributor
oshai commented Jan 15, 2023

LGTM!

@oshai oshai merged commit 8ff9583 into jasync-sql:master Jan 15, 2023
@oshai
Copy link
Contributor
oshai commented Jan 15, 2023

Thanks for the effort! Released 2.1.12 with the PR.

@KarboniteKream KarboniteKream deleted the feat/caching-sha2-password branch January 16, 2023 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unknown authentication method
2 participants
0