-
-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enabling support for the caching_sha2_password auth plugin
- Loading branch information
Showing
5 changed files
with
410 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,12 +95,13 @@ type ServerAuthenticationTest struct { | |
|
||
// ServerAuthenticationTestAssertion is within a ServerAuthenticationTest to assert functionality. | ||
type ServerAuthenticationTestAssertion struct { | ||
Username string | ||
Password string | ||
Query string | ||
ExpectedErr bool | ||
ExpectedErrKind *errors.Kind | ||
ExpectedErrStr string | ||
Username string | ||
Password string | ||
Query string | ||
ExpectedErr bool | ||
ExpectedErrKind *errors.Kind | ||
ExpectedErrStr string | ||
ExpectedAuthPlugin string | ||
} | ||
|
||
// UserPrivTests test the user and privilege systems. These tests always have the root account available, and the root | ||
|
@@ -740,7 +741,37 @@ var UserPrivTests = []UserPrivilegeTest{ | |
}, | ||
}, | ||
}, | ||
|
||
{ | ||
Name: "Migrate a user from mysql_native_password to caching_sha2_password", | ||
SetUpScript: []string{ | ||
"CREATE USER testuser1@`127.0.0.1` identified with mysql_native_password by 'pass1';", | ||
}, | ||
Assertions: []UserPrivilegeTestAssertion{ | ||
{ | ||
Query: "select user, host, plugin, authentication_string from mysql.user where user='testuser1';", | ||
Expected: []sql.Row{{"testuser1", "127.0.0.1", "mysql_native_password", "*22A99BA288DB55E8E230679259740873101CD636"}}, | ||
}, | ||
{ | ||
Query: "ALTER USER [email protected] IDENTIFIED WITH caching_sha2_password BY 'pass1';", | ||
Expected: []sql.Row{}, | ||
}, | ||
{ | ||
// caching_sha2_password auth uses a random salt to create the authentication | ||
// string. Since it's not a consistent value during each test run, we just sanity | ||
// check the first bytes of metadata (digest type, iterations) in the auth string. | ||
Query: "select user, host, plugin, authentication_string like '$A$005$%' from mysql.user where user='testuser1';", | ||
Expected: []sql.Row{{"testuser1", "127.0.0.1", "caching_sha2_password", true}}, | ||
}, | ||
{ | ||
Query: "ALTER USER [email protected] IDENTIFIED WITH caching_sha2_password;", | ||
Expected: []sql.Row{}, | ||
}, | ||
{ | ||
Query: "select user, host, plugin, authentication_string from mysql.user where user='testuser2';", | ||
Expected: []sql.Row{{"testuser1", "127.0.0.1", "caching_sha2_password", ""}}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
Name: "Dynamic privilege support", | ||
SetUpScript: []string{ | ||
|
@@ -2604,10 +2635,10 @@ var ServerAuthTests = []ServerAuthenticationTest{ | |
}, | ||
Assertions: []ServerAuthenticationTestAssertion{ | ||
{ | ||
Username: "rand_user", | ||
Password: "rand_pass", | ||
Query: "SELECT * FROM mysql.user;", | ||
ExpectedErr: false, | ||
Username: "rand_user", | ||
Password: "rand_pass", | ||
Query: "SELECT * FROM mysql.user;", | ||
ExpectedAuthPlugin: "mysql_native_password", | ||
}, | ||
{ | ||
Username: "rand_user", | ||
|
@@ -2630,17 +2661,17 @@ var ServerAuthTests = []ServerAuthenticationTest{ | |
}, | ||
}, | ||
{ | ||
Name: "Create User with plugin specification", | ||
Name: "Create User explicitly with mysql_native_password plugin", | ||
SetUpScript: []string{ | ||
"CREATE USER ranuse@localhost IDENTIFIED WITH mysql_native_password BY 'ranpas';", | ||
"GRANT ALL ON *.* TO ranuse@localhost WITH GRANT OPTION;", | ||
}, | ||
Assertions: []ServerAuthenticationTestAssertion{ | ||
{ | ||
Username: "ranuse", | ||
Password: "ranpas", | ||
Query: "SELECT * FROM mysql.user;", | ||
ExpectedErr: false, | ||
Username: "ranuse", | ||
Password: "ranpas", | ||
Query: "SELECT * FROM mysql.user;", | ||
ExpectedAuthPlugin: "mysql_native_password", | ||
}, | ||
{ | ||
Username: "ranuse", | ||
|
@@ -2656,6 +2687,103 @@ var ServerAuthTests = []ServerAuthenticationTest{ | |
}, | ||
}, | ||
}, | ||
{ | ||
Name: "Create User explicitly with caching_sha2_password plugin", | ||
SetUpScript: []string{ | ||
// testuser1 is created with a password | ||
"CREATE USER testuser1@localhost IDENTIFIED WITH caching_sha2_password BY 'mypassword3';", | ||
"GRANT ALL ON *.* TO testuser1@localhost WITH GRANT OPTION;", | ||
// testuser2 is created without a password | ||
"CREATE USER testuser2@localhost IDENTIFIED WITH caching_sha2_password;", | ||
"GRANT ALL ON *.* TO testuser2@localhost WITH GRANT OPTION;", | ||
}, | ||
Assertions: []ServerAuthenticationTestAssertion{ | ||
{ | ||
Username: "testuser1", | ||
Password: "mypassword3", | ||
Query: "SELECT * FROM mysql.user;", | ||
ExpectedAuthPlugin: "caching_sha2_password", | ||
}, | ||
{ | ||
Username: "testuser1", | ||
Password: "what", | ||
Query: "SELECT * FROM mysql.user;", | ||
ExpectedErr: true, | ||
ExpectedErrStr: "Error 1045 (28000): Access denied for user 'testuser1'", | ||
}, | ||
{ | ||
Username: "testuser1", | ||
Password: "", | ||
Query: "SELECT * FROM mysql.user;", | ||
ExpectedErr: true, | ||
ExpectedErrStr: "Error 1045 (28000): Access denied for user 'testuser1'", | ||
}, | ||
{ | ||
Username: "testuser2", | ||
Password: "wrong", | ||
Query: "SELECT * FROM mysql.user;", | ||
ExpectedErr: true, | ||
ExpectedErrStr: "Error 1045 (28000): Access denied for user 'testuser2'", | ||
}, | ||
{ | ||
Username: "testuser2", | ||
Password: "", | ||
Query: "SELECT * FROM mysql.user;", | ||
ExpectedErr: false, | ||
ExpectedAuthPlugin: "caching_sha2_password", | ||
}, | ||
}, | ||
}, | ||
{ | ||
Name: "Migrate user from mysql_native_password to caching_sha2_password", | ||
SetUpScript: []string{ | ||
// testuser1 is created with a password | ||
"CREATE USER testuser1@localhost IDENTIFIED WITH mysql_native_password BY 'mypassword3';", | ||
"GRANT ALL ON *.* TO testuser1@localhost WITH GRANT OPTION;", | ||
}, | ||
Assertions: []ServerAuthenticationTestAssertion{ | ||
{ | ||
Username: "testuser1", | ||
Password: "mypassword3", | ||
Query: "SELECT * FROM mysql.user;", | ||
ExpectedAuthPlugin: "mysql_native_password", | ||
}, | ||
{ | ||
Username: "root", | ||
Query: "ALTER USER testuser1@localhost IDENTIFIED WITH caching_sha2_password BY 'pass1';", | ||
}, | ||
{ | ||
Username: "testuser1", | ||
Password: "pass1", | ||
Query: "SELECT * FROM mysql.user;", | ||
ExpectedAuthPlugin: "caching_sha2_password", | ||
}, | ||
{ | ||
Username: "testuser1", | ||
Password: "wrong", | ||
Query: "SELECT * FROM mysql.user;", | ||
ExpectedErr: true, | ||
ExpectedErrStr: "Error 1045 (28000): Access denied for user 'testuser1'", | ||
}, | ||
{ | ||
Username: "root", | ||
Query: "ALTER USER testuser1@localhost IDENTIFIED WITH caching_sha2_password;", | ||
}, | ||
{ | ||
Username: "testuser1", | ||
Password: "", | ||
Query: "SELECT * FROM mysql.user;", | ||
ExpectedAuthPlugin: "caching_sha2_password", | ||
}, | ||
{ | ||
Username: "testuser1", | ||
Password: "wrong", | ||
Query: "SELECT * FROM mysql.user;", | ||
ExpectedErr: true, | ||
ExpectedErrStr: "Error 1045 (28000): Access denied for user 'testuser1'", | ||
}, | ||
}, | ||
}, | ||
{ | ||
Name: "Create User with jwt plugin specification", | ||
SetUpScript: []string{ | ||
|
@@ -2668,22 +2796,25 @@ var ServerAuthTests = []ServerAuthenticationTest{ | |
}, | ||
Assertions: []ServerAuthenticationTestAssertion{ | ||
{ | ||
Username: "test-user", | ||
Password: "what", | ||
Query: "SELECT * FROM mysql.user;", | ||
ExpectedErr: true, | ||
Username: "test-user", | ||
Password: "what", | ||
Query: "SELECT * FROM mysql.user;", | ||
ExpectedErr: true, | ||
ExpectedErrStr: "Error 1045 (28000): Access denied for user 'test-user'", | ||
}, | ||
{ | ||
Username: "test-user", | ||
Password: "", | ||
Query: "SELECT * FROM mysql.user;", | ||
ExpectedErr: true, | ||
Username: "test-user", | ||
Password: "", | ||
Query: "SELECT * FROM mysql.user;", | ||
ExpectedErr: true, | ||
ExpectedErrStr: "Error 1045 (28000): Access denied for user 'test-user'", | ||
}, | ||
{ | ||
Username: "test-user", | ||
Password: "right-password", | ||
Query: "SELECT * FROM mysql.user;", | ||
ExpectedErr: false, | ||
|
||
Username: "test-user", | ||
Password: "right-password", | ||
Query: "SELECT * FROM mysql.user;", | ||
ExpectedAuthPlugin: "authentication_dolt_jwt", | ||
}, | ||
}, | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIErDCCApQCCQCP9IKGyBYVUDANBgkqhkiG9w0BAQsFADAYMRYwFAYDVQQKDA1E | ||
b2x0SHViLCBJbmMuMB4XDTIyMDcyMTE5NTUyN1oXDTI2MDcyMDE5NTUyN1owGDEW | ||
MBQGA1UECgwNRG9sdEh1YiwgSW5jLjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCC | ||
AgoCggIBAMRNMquL4n2bAMQmoedUFcT/zI42ThW5o9qxh9U8MhsDqKBet7JL7ruh | ||
3FRj/yaU+3ax2lGgapcTnSJHWHPUX6MzUpqkwrLzKxqMrKQYnU2F96n3GOflllsB | ||
8ISKBy0TIipLWKupndc893qk+j6HUQ9OrtFHwroZ6/Tg32h4LcJvhkwILb8EHZpI | ||
fSSzi637msnXWqln1WYmX+v4ARUVVSwl5kkPGZ4PxMDQRX3ioqy2d27GbHYSo01K | ||
tSScQvnFJeddu09l7hNTSFixRz+XU+F+jYna8xUtqHMawEpfGw8Gsu8sMV9PUfUx | ||
6WrMb1tcyWEDvHwH6RUlhNa085eCRFznHLDZNxrgBwrslII9d9xW/JaRq43d4M0q | ||
e7F+BazB3rImMo2QHFvtvq55N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----- |
Oops, something went wrong.