diff options
author | Sergei Golubchik <serg@mariadb.org> | 2018-10-17 12:48:13 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2018-10-31 16:06:16 +0100 |
commit | 7c40996cc866ba9c6cf781776312301baa81c452 (patch) | |
tree | 8b685a88b0f3a1fbe854c2a77c2703e6bcdbdd27 /mysql-test/main/grant5.test | |
parent | 14e181a43456545380856b922051af881b1c38f8 (diff) | |
download | mariadb-git-7c40996cc866ba9c6cf781776312301baa81c452.tar.gz |
MDEV-12321 authentication plugin: SET PASSWORD support
Support SET PASSWORD for authentication plugins.
Authentication plugin API is extended with two optional methods:
* hash_password() is used to compute a password hash (or digest)
from the plain-text password. This digest will be stored in mysql.user
table
* preprocess_hash() is used to convert this digest into some memory
representation that can be later used to authenticate a user.
Build-in plugins convert the hash from hexadecimal or base64 to binary,
to avoid doing it on every authentication attempt.
Note a change in behavior: when loading privileges (on startup or on
FLUSH PRIVILEGES) an account with an unknown plugin was loaded with a
warning (e.g. "Plugin 'foo' is not loaded"). But such an account could
not be used for authentication until the plugin is installed. Now an
account like that will not be loaded at all (with a warning, still).
Indeed, without plugin's preprocess_hash() method the server cannot know
how to load an account. Thus, if a new authentication plugin is
installed run-time, one might need FLUSH PRIVILEGES to activate all
existing accounts that were using this new plugin.
Diffstat (limited to 'mysql-test/main/grant5.test')
-rw-r--r-- | mysql-test/main/grant5.test | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/mysql-test/main/grant5.test b/mysql-test/main/grant5.test index 14f2fd65020..1ab68b82066 100644 --- a/mysql-test/main/grant5.test +++ b/mysql-test/main/grant5.test @@ -23,3 +23,63 @@ show grants for foo@'%'; # user drop user test, foo; drop role foo; +# +# MDEV-12321 authentication plugin: SET PASSWORD support +# +error ER_PASSWD_LENGTH; +create user u1@h identified with 'mysql_native_password' using 'pwd'; +create user u1@h identified with 'mysql_native_password' using password('pwd'); +let p=`select password('pwd')`; +eval create user u2@h identified with 'mysql_native_password' using '$p'; +create user u3@h identified with 'mysql_native_password'; +error ER_PASSWD_LENGTH; +set password for u3@h = 'pwd'; +set password for u3@h = password('pwd'); +create user u4@h identified with 'mysql_native_password'; +eval set password for u4@h = '$p'; +error ER_PASSWD_LENGTH; +create user u5@h identified with 'mysql_old_password' using 'pwd'; +create user u5@h identified with 'mysql_old_password' using password('pwd'); +let p=`select old_password('pwd')`; +eval create user u6@h identified with 'mysql_old_password' using '$p'; +create user u7@h identified with 'mysql_old_password'; +error ER_PASSWD_LENGTH; +set password for u7@h = 'pwd'; +set password for u7@h = old_password('pwd'); +create user u8@h identified with 'mysql_old_password'; +eval set password for u8@h = '$p'; +sorted_result; +select user,host,password,plugin,authentication_string from mysql.user where host='h'; +# test with invalid entries +update mysql.user set authentication_string='bad' where user='u1'; +update mysql.user set authentication_string='bad' where user='u5'; +update mysql.user set plugin='nonexistent' where user='u8'; +flush privileges; +# invalid entries are skipped, users don't exist +error ER_PASSWORD_NO_MATCH; +show create user u1@h; +show create user u2@h; +show create user u3@h; +show create user u4@h; +error ER_PASSWORD_NO_MATCH; +show create user u5@h; +show create user u6@h; +show create user u7@h; +error ER_PASSWORD_NO_MATCH; +show create user u8@h; +#grants don't work either +error ER_PASSWORD_NO_MATCH; +grant select on *.* to u1@h; +grant select on *.* to u2@h; +grant select on *.* to u3@h; +grant select on *.* to u4@h; +error ER_PASSWORD_NO_MATCH; +grant select on *.* to u5@h; +grant select on *.* to u6@h; +grant select on *.* to u7@h; +error ER_PASSWORD_NO_MATCH; +grant select on *.* to u8@h; +select user,select_priv,plugin,authentication_string from mysql.user where user like 'u_'; + +# but they still can be dropped +drop user u1@h, u2@h, u3@h, u4@h, u5@h, u6@h, u7@h, u8@h; |