-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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 for tidb_sm3_password
authentication
#36193
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
Code Coverage Details: https://codecov.io/github/pingcap/tidb/commit/9db5b4de43204f3cd9f4bbabe749bc3bc14dfd6d |
Co-authored-by: djshow832 <zhangming@pingcap.com>
Here is the JDBC PR that supports SM3: pingcap/mysql-connector-j#24
We are required by our customers to support SM3 authentication. If needed, we could enhance the TLS connection in TiDB in the future, which I think is a better way. :-) |
/run-build |
tidb_sm3_password
authentication
While many MySQL authentication plugins have a client plugin and a server plugin with a matching name, this is not required. This matters in this case as the As a quick-and-dirty test I did this: diff --git a/server/conn.go b/server/conn.go
index 5fac5f199..a42546992 100644
--- a/server/conn.go
+++ b/server/conn.go
@@ -666,7 +666,8 @@ func (cc *clientConn) readOptionalSSLRequestAndHandshakeResponse(ctx context.Con
switch resp.AuthPlugin {
case mysql.AuthCachingSha2Password:
- resp.Auth, err = cc.authSha(ctx)
+ resp.Auth, err = cc.authSM3(ctx)
+ // resp.Auth, err = cc.authSha(ctx)
if err != nil {
return err
}
@@ -921,6 +922,9 @@ func (cc *clientConn) checkAuthPlugin(ctx context.Context, resp *handshakeRespon
// or if the authentication method send by the server doesn't match the authentication
// method send by the client (*authPlugin) then we need to switch the authentication
// method to match the one configured for that specific user.
+ if userplugin == mysql.AuthTiDBSM3Password {
+ userplugin = mysql.AuthCachingSha2Password
+ }
if (cc.authPlugin != userplugin) || (cc.authPlugin != resp.AuthPlugin) {
if resp.Capability&mysql.ClientPluginAuth > 0 {
authData, err := cc.authSwitchRequest(ctx, userplugin) Then as root:
And then:
This won't work with the fast/cached authentication as defined on https://dev.mysql.com/doc/dev/mysql-server/latest/page_caching_sha2_authentication_exchanges.html We could also use the cleartext client plugin for this. The benefit of using |
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.
Let's see if we can use existing client authentication plugins with tidb_sm3_password
.
Done, PTAL :-) After creating a user with |
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.
LGTM
/unhold |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 9ed13ae
|
TiDB MergeCI notify🔴 Bad News! [2] CI still failing after this pr merged.
|
What problem does this PR solve?
Issue Number: close #36192
Problem Summary:
SM3 authentication has not been supported in TiDB yet.
What is changed and how it works?
SM3()
likeSHA1()
andSHA2()
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.