From 62d82191ac85610830970d6a603ee732220efd98 Mon Sep 17 00:00:00 2001 From: Simon J Mudd Date: Wed, 16 May 2018 23:39:14 +0200 Subject: [PATCH 1/2] Change ErrUnknownPlugin to a func which can take the plugin name MySQL 8.0 brings a new authentication plugin which is enabled by default. This plugin is not yet handled by the go driver. The error message which is returned is somewhat vague and this is likely to cause confusion. The change provides the same error message but includes the plugin name which will be easier for people to lookup. So rather than returning the error: this authentication plugin is not supported we return something like: authentication plugin "caching_sha2_password" is not supported --- errors.go | 6 +++++- packets.go | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/errors.go b/errors.go index 857854e14..3520c6ee9 100644 --- a/errors.go +++ b/errors.go @@ -25,7 +25,6 @@ var ( ErrCleartextPassword = errors.New("this user requires clear text authentication. If you still want to use it, please add 'allowCleartextPasswords=1' to your DSN") ErrNativePassword = errors.New("this user requires mysql native password authentication.") ErrOldPassword = errors.New("this user requires old password authentication. If you still want to use it, please add 'allowOldPasswords=1' to your DSN. See also https://github.com/go-sql-driver/mysql/wiki/old_passwords") - ErrUnknownPlugin = errors.New("this authentication plugin is not supported") ErrOldProtocol = errors.New("MySQL server does not support required protocol 41+") ErrPktSync = errors.New("commands out of sync. You can't run this command now") ErrPktSyncMul = errors.New("commands out of sync. Did you run multiple statements at once?") @@ -33,6 +32,11 @@ var ( ErrBusyBuffer = errors.New("busy buffer") ) +// ErrUnknownPlugin returns an error with the name of the plugin that is not supported +func ErrUnknownPlugin(name string) error { + return fmt.Errorf("authentication plugin %q is not supported", name) +} + var errLog = Logger(log.New(os.Stderr, "[mysql] ", log.Ldate|log.Ltime|log.Lshortfile)) // Logger is used to log critical error messages. diff --git a/packets.go b/packets.go index 41b4d3d55..1c5f974ac 100644 --- a/packets.go +++ b/packets.go @@ -496,7 +496,7 @@ func (mc *mysqlConn) readResultOK() ([]byte, error) { // using mysql default authentication method return cipher, ErrNativePassword } else { - return cipher, ErrUnknownPlugin + return cipher, ErrUnknownPlugin(plugin) } } else { // https://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::OldAuthSwitchRequest From 04bab56b0b4060c5d0f34a15e2013495050f3b89 Mon Sep 17 00:00:00 2001 From: Simon J Mudd Date: Wed, 16 May 2018 23:49:06 +0200 Subject: [PATCH 2/2] Add myself to AUTHORS --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index a6b845f72..b718b5918 100644 --- a/AUTHORS +++ b/AUTHORS @@ -46,6 +46,7 @@ Olivier Mengué Paul Bonser Peter Schultz Runrioter Wung +Simon J Mudd Soroush Pour Stan Putrya Stanley Gunawan