Support AuthSwitchRequest
to switch authentication plugin
#208
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.
This changeset adds support for the
AuthSwitchRequest
to switch authentication plugins. The MySQL server can send this packet to ask the client to use another authentication method (https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_connection_phase_packets_protocol_auth_switch_request.html).For instance, this is required to make Amazon RDS work in my tests. In my tests, the server first requests
mysql_native_password
which is then fulfilled by the client, and next switches tocaching_sha2_password
afterwards, asking the client to authenticate again. While I agree this may look strange, it may make sense depending on server configuration internals and is completely in line with the MySQL protocol specification.With these changes applied, I can successfully connect to my Amazon RDS server and process any queries as usual. Prior to applying these changes, I would get a protocol exception instead:
The affected code has 100% code coverage and has been tested against a number of MySQL server versions. The tests confirm it should continue to work for legacy servers not using authentication plugins or newer MySQL server versions using the existing
mysql_native_password
authentication or newercaching_sha2_password
authentication. As discussed in #196 and elsewhere, I'll follow-up with a separate PR to add more MySQL server versions to our test matrix, but I've yet to find a combination that requires theAuthSwitchRequest
.Builds on top of #207 and #206