Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
CbcWestwolf committed Nov 15, 2024
1 parent 62a5b04 commit 51a9f73
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 16 deletions.
1 change: 0 additions & 1 deletion pkg/executor/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -2521,7 +2521,6 @@ func (e *SimpleExec) executeSetPwd(ctx context.Context, s *ast.SetPwdStmt) error
}
authPlugins := extensions.GetAuthPlugins()
var pwd string
// FIXME
switch authplugin {
case mysql.AuthCachingSha2Password, mysql.AuthTiDBSM3Password:
pwd = auth.NewHashPassword(s.Password, authplugin)
Expand Down
1 change: 1 addition & 0 deletions pkg/parser/ast/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,7 @@ type UserSpec struct {
AuthOpt *AuthOption
IsRole bool

// DefaultAuthPlugin is used to store the values of default_authentication_plugin
DefaultAuthPlugin string
}

Expand Down
42 changes: 32 additions & 10 deletions tests/integrationtest/r/executor/simple.result
Original file line number Diff line number Diff line change
Expand Up @@ -495,20 +495,42 @@ CREATE USER 'default_sha2_user'@'%' IDENTIFIED WITH 'tidb_sm3_password' AS '' RE
select plugin from mysql.user where user = 'default_sha2_user';
plugin
tidb_sm3_password
alter user default_sha2_user identified with 'authentication_ldap_simple';
show create user default_sha2_user;
CREATE USER for default_sha2_user@%
CREATE USER 'default_sha2_user'@'%' IDENTIFIED WITH 'authentication_ldap_simple' AS '' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT
drop user default_sha2_user;
create user default_sha2_user identified by '1234';
set password for default_sha2_user = '12345';
alter user default_sha2_user identified by '123456';
select plugin from mysql.user where user = 'default_sha2_user';
plugin
authentication_ldap_simple
alter user default_sha2_user identified with 'authentication_ldap_sasl';
show create user default_sha2_user;
CREATE USER for default_sha2_user@%
CREATE USER 'default_sha2_user'@'%' IDENTIFIED WITH 'authentication_ldap_sasl' AS '' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT
caching_sha2_password
alter user default_sha2_user identified with 'mysql_native_password' by '123456';
select plugin from mysql.user where user = 'default_sha2_user';
plugin
authentication_ldap_sasl
mysql_native_password
alter user default_sha2_user identified with 'caching_sha2_password';
select plugin from mysql.user where user = 'default_sha2_user';
plugin
caching_sha2_password
set sql_mode = '';
select @@sql_mode;
@@sql_mode

select user, host, plugin from mysql.user where user = 'non_exist_user';
user host plugin
grant select on test.* to non_exist_user;
select user, host, plugin from mysql.user where user = 'non_exist_user';
user host plugin
non_exist_user % caching_sha2_password
set @@sql_mode = default;
alter user non_exist_user identified with 'mysql_native_password';
show create user non_exist_user;
CREATE USER for non_exist_user@%
CREATE USER 'non_exist_user'@'%' IDENTIFIED WITH 'mysql_native_password' AS '' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT
update mysql.user set plugin = '' where user = 'non_exist_user';
flush privileges;
show create user non_exist_user;
CREATE USER for non_exist_user@%
CREATE USER 'non_exist_user'@'%' IDENTIFIED WITH 'caching_sha2_password' AS '' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT
drop user non_exist_user;
drop user default_sm3_user;
drop user default_sha2_user;
drop user native_plugin_user;
Expand Down
30 changes: 25 additions & 5 deletions tests/integrationtest/t/executor/simple.test
Original file line number Diff line number Diff line change
Expand Up @@ -516,15 +516,35 @@ select plugin from mysql.user where user = 'default_sha2_role';
alter user default_sha2_user identified with 'tidb_sm3_password';
show create user default_sha2_user;
select plugin from mysql.user where user = 'default_sha2_user';
drop user default_sha2_user;

alter user default_sha2_user identified with 'authentication_ldap_simple';
show create user default_sha2_user;
create user default_sha2_user identified by '1234';
set password for default_sha2_user = '12345';
alter user default_sha2_user identified by '123456';
select plugin from mysql.user where user = 'default_sha2_user';

alter user default_sha2_user identified with 'authentication_ldap_sasl';
show create user default_sha2_user;
alter user default_sha2_user identified with 'mysql_native_password' by '123456';
select plugin from mysql.user where user = 'default_sha2_user';
alter user default_sha2_user identified with 'caching_sha2_password';
select plugin from mysql.user where user = 'default_sha2_user';

# test GRANT create default user

set sql_mode = '';
select @@sql_mode;
select user, host, plugin from mysql.user where user = 'non_exist_user';
grant select on test.* to non_exist_user;
select user, host, plugin from mysql.user where user = 'non_exist_user';
set @@sql_mode = default;

# test SHOW CREATE USER

alter user non_exist_user identified with 'mysql_native_password';
show create user non_exist_user;
update mysql.user set plugin = '' where user = 'non_exist_user';
flush privileges;
show create user non_exist_user;

drop user non_exist_user;
drop user default_sm3_user;
drop user default_sha2_user;
drop user native_plugin_user;
Expand Down

0 comments on commit 51a9f73

Please sign in to comment.