Skip to content

Commit

Permalink
Fix authentication with MySQL 5.1 and older clients
Browse files Browse the repository at this point in the history
  • Loading branch information
dveeden authored and bb7133 committed Nov 15, 2021
1 parent 70cbb55 commit 2eeac32
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions server/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,20 @@ func (cc *clientConn) handleAuthPlugin(ctx context.Context, resp *handshakeRespo
}
} else {
logutil.Logger(ctx).Warn("Client without Auth Plugin support; Please upgrade client")
if cc.ctx == nil {
err := cc.openSession()
if err != nil {
return err
}
}
userplugin, err := cc.ctx.AuthPluginForUser(&auth.UserIdentity{Username: cc.user, Hostname: cc.peerHost})
if err != nil {
return err
}
if userplugin != mysql.AuthNativePassword && userplugin != "" {
return errNotSupportedAuthMode
}
resp.AuthPlugin = mysql.AuthNativePassword
}
return nil
}
Expand Down
1 change: 1 addition & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ var (
errSecureTransportRequired = dbterror.ClassServer.NewStd(errno.ErrSecureTransportRequired)
errMultiStatementDisabled = dbterror.ClassServer.NewStd(errno.ErrMultiStatementDisabled)
errNewAbortingConnection = dbterror.ClassServer.NewStd(errno.ErrNewAbortingConnection)
errNotSupportedAuthMode = dbterror.ClassServer.NewStd(errno.ErrNotSupportedAuthMode)
)

// DefaultCapability is the capability of the server when it is created using the default configuration.
Expand Down

0 comments on commit 2eeac32

Please sign in to comment.