Skip to content
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

server: change the compatibility of tidb_sm3_password #37909

Merged
merged 6 commits into from
Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions server/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -923,11 +923,6 @@ func (cc *clientConn) checkAuthPlugin(ctx context.Context, resp *handshakeRespon
// method to match the one configured for that specific user.
if (cc.authPlugin != userplugin) || (cc.authPlugin != resp.AuthPlugin) {
if resp.Capability&mysql.ClientPluginAuth > 0 {
// For compatibility, since most mysql client doesn't support 'tidb_sm3_password',
// they can connect to TiDB using a `tidb_sm3_password` user with a 'caching_sha2_password' plugin.
if userplugin == mysql.AuthTiDBSM3Password {
userplugin = mysql.AuthCachingSha2Password
}
authData, err := cc.authSwitchRequest(ctx, userplugin)
if err != nil {
return nil, err
Expand Down
6 changes: 3 additions & 3 deletions server/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,7 @@ func TestHandleAuthPlugin(t *testing.T) {
}
err = cc.handleAuthPlugin(ctx, &resp)
require.NoError(t, err)
require.Equal(t, []byte(mysql.AuthCachingSha2Password), resp.Auth)
require.Equal(t, []byte(mysql.AuthTiDBSM3Password), resp.Auth)
require.NoError(t, failpoint.Disable("github.com/pingcap/tidb/server/FakeAuthSwitch"))

// 8.0 or newer client trying to authenticate with caching_sha2_password
Expand All @@ -1311,7 +1311,7 @@ func TestHandleAuthPlugin(t *testing.T) {
}
err = cc.handleAuthPlugin(ctx, &resp)
require.NoError(t, err)
require.Equal(t, []byte(mysql.AuthCachingSha2Password), resp.Auth)
require.Equal(t, []byte(mysql.AuthTiDBSM3Password), resp.Auth)
require.NoError(t, failpoint.Disable("github.com/pingcap/tidb/server/FakeAuthSwitch"))

// client trying to authenticate with tidb_sm3_password
Expand All @@ -1334,7 +1334,7 @@ func TestHandleAuthPlugin(t *testing.T) {
}
err = cc.handleAuthPlugin(ctx, &resp)
require.NoError(t, err)
require.Equal(t, []byte(mysql.AuthCachingSha2Password), resp.Auth)
require.Equal(t, []byte(mysql.AuthTiDBSM3Password), resp.Auth)
require.NoError(t, failpoint.Disable("github.com/pingcap/tidb/server/FakeAuthSwitch"))

// MySQL 5.1 or older client, without authplugin support
Expand Down