1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
INSTALL COMPONENT "file://component_validate_password";
SELECT @@global.validate_password.check_user_name;
@@global.validate_password.check_user_name
1
# Should fail: not a session variable
SET @@session.validate_password.check_user_name= ON;
ERROR HY000: Variable 'validate_password.check_user_name' is a GLOBAL variable and should be set with SET GLOBAL
# Should fail: not a session variable
SET validate_password.check_user_name= ON;
ERROR HY000: Variable 'validate_password.check_user_name' is a GLOBAL variable and should be set with SET GLOBAL
SET @@global.validate_password.policy=LOW;
SET @@global.validate_password.mixed_case_count=0;
SET @@global.validate_password.number_count=0;
SET @@global.validate_password.special_char_count=0;
SET @@global.validate_password.length=0;
SET @@global.validate_password.check_user_name= ON;
# Must pass: password the same as the the user name, but run by root
CREATE USER "base_user"@localhost IDENTIFIED BY 'base_user';
GRANT ALL PRIVILEGES ON test.* TO "base_user"@localhost;
# Must pass: password the same as the user name, but run by root
SET PASSWORD FOR "base_user"@localhost = 'base_user';
# Must pass: password the same as the user name, but run by root
ALTER USER "base_user"@localhost IDENTIFIED BY 'base_user';
# Must fail: password is root
CREATE USER foo@localhost IDENTIFIED BY 'root';
ERROR HY000: Your password does not satisfy the current policy requirements
# Must return 0 : same as the user name
SELECT VALIDATE_PASSWORD_STRENGTH('root') = 0;
VALIDATE_PASSWORD_STRENGTH('root') = 0
1
# Must return 0 : same as the user name
SELECT VALIDATE_PASSWORD_STRENGTH('toor') = 0;
VALIDATE_PASSWORD_STRENGTH('toor') = 0
1
# Must return non-0: upper case in user name
SELECT VALIDATE_PASSWORD_STRENGTH('Root') <> 0;
VALIDATE_PASSWORD_STRENGTH('Root') <> 0
1
# Must return non-0: upper case in reverse user name
SELECT VALIDATE_PASSWORD_STRENGTH('Toor') <> 0;
VALIDATE_PASSWORD_STRENGTH('Toor') <> 0
1
# Must return non-0: different name
SELECT VALIDATE_PASSWORD_STRENGTH('fooHoHo%1') <> 0;
VALIDATE_PASSWORD_STRENGTH('fooHoHo%1') <> 0
1
# connect as base_user
# Should fail: password the same as the user name
SET PASSWORD='base_user';
ERROR HY000: Your password does not satisfy the current policy requirements
# Should pass: uppercase in U
SET PASSWORD='base_User';
# Should fail: password the same as the login user name
ALTER USER "base_user"@localhost IDENTIFIED BY 'base_user';
ERROR HY000: Your password does not satisfy the current policy requirements
# Must be 0: user name matches the password
SELECT VALIDATE_PASSWORD_STRENGTH('base_user') = 0;
VALIDATE_PASSWORD_STRENGTH('base_user') = 0
1
# Must be 0: reverse of user name matches the password
SELECT VALIDATE_PASSWORD_STRENGTH('resu_esab') = 0;
VALIDATE_PASSWORD_STRENGTH('resu_esab') = 0
1
# Must pass: empty password is ok
SET PASSWORD='';
# back to default connection
REVOKE ALL PRIVILEGES ON test.* FROM "base_user"@localhost;
DROP USER "base_user"@localhost;
# test effective user name
CREATE USER ""@localhost;
GRANT ALL PRIVILEGES ON test.* TO ""@localhost;
# connect as the login_user
SELECT USER(),CURRENT_USER();
USER() CURRENT_USER()
login_user@localhost @localhost
# Should return 0: login user id matches
SELECT VALIDATE_PASSWORD_STRENGTH('login_user') = 0;
VALIDATE_PASSWORD_STRENGTH('login_user') = 0
1
# Should return 0: reverse login user id matches
SELECT VALIDATE_PASSWORD_STRENGTH('resu_nigol') = 0;
VALIDATE_PASSWORD_STRENGTH('resu_nigol') = 0
1
# back to default connection
REVOKE ALL PRIVILEGES ON test.* FROM ""@localhost;
DROP USER ""@localhost;
SET @@global.validate_password.policy=default;
SET @@global.validate_password.length=default;
SET @@global.validate_password.mixed_case_count=default;
SET @@global.validate_password.number_count=default;
SET @@global.validate_password.special_char_count=default;
SET @@global.validate_password.check_user_name= default;
UNINSTALL COMPONENT "file://component_validate_password";
|