mirror of
https://github.com/MariaDB/server.git
synced 2026-05-16 20:07:13 +02:00
MDEV-6918 Create a way to see a user's default role.
Added an extra column to i_s_applicable_roles, named IS_DEFAULT. The column displays which role is the default role for the user querying the table.
This commit is contained in:
parent
bceb0b0be1
commit
4c69a6fff2
12 changed files with 434 additions and 48 deletions
|
|
@ -72,13 +72,13 @@ show grants for role4;
|
|||
Grants for role4
|
||||
GRANT USAGE ON *.* TO 'role4'
|
||||
select * from information_schema.applicable_roles;
|
||||
GRANTEE ROLE_NAME IS_GRANTABLE
|
||||
role1 role2 NO
|
||||
role1 role3 YES
|
||||
role3 role4 YES
|
||||
root@localhost role1 YES
|
||||
root@localhost role2 YES
|
||||
root@localhost role4 YES
|
||||
GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
|
||||
role1 role2 NO NULL
|
||||
role1 role3 YES NULL
|
||||
role3 role4 YES NULL
|
||||
root@localhost role1 YES NO
|
||||
root@localhost role2 YES NO
|
||||
root@localhost role4 YES NO
|
||||
grant role2 to role1 with admin option;
|
||||
revoke role1 from foo@localhost;
|
||||
revoke admin option for role4 from role3;
|
||||
|
|
@ -131,13 +131,13 @@ show grants for role4;
|
|||
Grants for role4
|
||||
GRANT USAGE ON *.* TO 'role4'
|
||||
select * from information_schema.applicable_roles;
|
||||
GRANTEE ROLE_NAME IS_GRANTABLE
|
||||
role1 role2 YES
|
||||
role1 role3 YES
|
||||
role3 role4 NO
|
||||
root@localhost role1 NO
|
||||
root@localhost role2 YES
|
||||
root@localhost role4 YES
|
||||
GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
|
||||
role1 role2 YES NULL
|
||||
role1 role3 YES NULL
|
||||
role3 role4 NO NULL
|
||||
root@localhost role1 NO NO
|
||||
root@localhost role2 YES NO
|
||||
root@localhost role4 YES NO
|
||||
grant role1 to role4;
|
||||
ERROR 28000: Access denied for user 'root'@'localhost'
|
||||
grant role1 to role4 with admin option;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
grant create user on *.* to foo@localhost;
|
||||
drop user foo@localhost;
|
||||
select * from information_schema.applicable_roles;
|
||||
GRANTEE ROLE_NAME IS_GRANTABLE
|
||||
GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
|
||||
show grants;
|
||||
ERROR 42000: There is no such grant defined for user 'foo' on host 'localhost'
|
||||
select current_user();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,80 @@
|
|||
create user foo;
|
||||
create role role1;
|
||||
create role role2;
|
||||
create role role3;
|
||||
grant role1 to foo;
|
||||
grant role2 to role1;
|
||||
grant role3 to foo;
|
||||
connect foo, localhost, foo;
|
||||
select * from information_schema.applicable_roles;
|
||||
GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
|
||||
foo@% role1 NO NO
|
||||
foo@% role3 NO NO
|
||||
role1 role2 NO NULL
|
||||
set default role role3;
|
||||
select * from information_schema.applicable_roles;
|
||||
GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
|
||||
foo@% role1 NO NO
|
||||
foo@% role3 NO YES
|
||||
role1 role2 NO NULL
|
||||
set default role role1;
|
||||
select * from information_schema.applicable_roles;
|
||||
GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
|
||||
foo@% role1 NO YES
|
||||
foo@% role3 NO NO
|
||||
role1 role2 NO NULL
|
||||
disconnect foo;
|
||||
connection default;
|
||||
select * from information_schema.applicable_roles;
|
||||
GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
|
||||
role1 role2 NO NULL
|
||||
root@localhost role1 YES NO
|
||||
root@localhost role2 YES NO
|
||||
root@localhost role3 YES NO
|
||||
set default role none for foo;
|
||||
connect foo, localhost, foo;
|
||||
select * from information_schema.applicable_roles;
|
||||
GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
|
||||
foo@% role1 NO NO
|
||||
foo@% role3 NO NO
|
||||
role1 role2 NO NULL
|
||||
disconnect foo;
|
||||
connection default;
|
||||
select * from information_schema.applicable_roles;
|
||||
GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
|
||||
role1 role2 NO NULL
|
||||
root@localhost role1 YES NO
|
||||
root@localhost role2 YES NO
|
||||
root@localhost role3 YES NO
|
||||
set default role role1;
|
||||
select * from information_schema.applicable_roles;
|
||||
GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
|
||||
role1 role2 NO NULL
|
||||
root@localhost role1 YES YES
|
||||
root@localhost role2 YES NO
|
||||
root@localhost role3 YES NO
|
||||
set default role role2;
|
||||
select * from information_schema.applicable_roles;
|
||||
GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
|
||||
role1 role2 NO NULL
|
||||
root@localhost role1 YES NO
|
||||
root@localhost role2 YES YES
|
||||
root@localhost role3 YES NO
|
||||
set default role role3;
|
||||
select * from information_schema.applicable_roles;
|
||||
GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
|
||||
role1 role2 NO NULL
|
||||
root@localhost role1 YES NO
|
||||
root@localhost role2 YES NO
|
||||
root@localhost role3 YES YES
|
||||
set default role none;
|
||||
select * from information_schema.applicable_roles;
|
||||
GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
|
||||
role1 role2 NO NULL
|
||||
root@localhost role1 YES NO
|
||||
root@localhost role2 YES NO
|
||||
root@localhost role3 YES NO
|
||||
drop role role3;
|
||||
drop role role2;
|
||||
drop role role1;
|
||||
drop user foo;
|
||||
62
mysql-test/suite/roles/i_s_applicable_roles_is_default.test
Normal file
62
mysql-test/suite/roles/i_s_applicable_roles_is_default.test
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
--enable_connect_log
|
||||
create user foo;
|
||||
create role role1;
|
||||
create role role2;
|
||||
create role role3;
|
||||
|
||||
grant role1 to foo;
|
||||
grant role2 to role1;
|
||||
grant role3 to foo;
|
||||
|
||||
|
||||
connect (foo, localhost, foo);
|
||||
--sorted_result
|
||||
select * from information_schema.applicable_roles;
|
||||
|
||||
set default role role3;
|
||||
--sorted_result
|
||||
select * from information_schema.applicable_roles;
|
||||
|
||||
set default role role1;
|
||||
--sorted_result
|
||||
select * from information_schema.applicable_roles;
|
||||
|
||||
|
||||
disconnect foo;
|
||||
connection default;
|
||||
|
||||
--sorted_result
|
||||
select * from information_schema.applicable_roles;
|
||||
|
||||
set default role none for foo;
|
||||
connect (foo, localhost, foo);
|
||||
--sorted_result
|
||||
select * from information_schema.applicable_roles;
|
||||
|
||||
disconnect foo;
|
||||
connection default;
|
||||
|
||||
--sorted_result
|
||||
select * from information_schema.applicable_roles;
|
||||
|
||||
set default role role1;
|
||||
--sorted_result
|
||||
select * from information_schema.applicable_roles;
|
||||
|
||||
set default role role2;
|
||||
--sorted_result
|
||||
select * from information_schema.applicable_roles;
|
||||
|
||||
set default role role3;
|
||||
--sorted_result
|
||||
select * from information_schema.applicable_roles;
|
||||
|
||||
|
||||
set default role none;
|
||||
--sorted_result
|
||||
select * from information_schema.applicable_roles;
|
||||
|
||||
drop role role3;
|
||||
drop role role2;
|
||||
drop role role1;
|
||||
drop user foo;
|
||||
|
|
@ -28,18 +28,18 @@ Grants for foo@localhost
|
|||
GRANT USAGE ON *.* TO 'foo'@'localhost'
|
||||
GRANT role10 TO 'foo'@'localhost'
|
||||
select * from information_schema.applicable_roles;
|
||||
GRANTEE ROLE_NAME IS_GRANTABLE
|
||||
foo@localhost role10 NO
|
||||
role10 role9 NO
|
||||
role2 role1 NO
|
||||
role4 role2 NO
|
||||
role5 role2 NO
|
||||
role5 role3 NO
|
||||
role6 role4 NO
|
||||
role6 role5 NO
|
||||
role7 role5 NO
|
||||
role9 role6 NO
|
||||
role9 role7 NO
|
||||
GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
|
||||
foo@localhost role10 NO NO
|
||||
role10 role9 NO NULL
|
||||
role2 role1 NO NULL
|
||||
role4 role2 NO NULL
|
||||
role5 role2 NO NULL
|
||||
role5 role3 NO NULL
|
||||
role6 role4 NO NULL
|
||||
role6 role5 NO NULL
|
||||
role7 role5 NO NULL
|
||||
role9 role6 NO NULL
|
||||
role9 role7 NO NULL
|
||||
show status like 'debug%';
|
||||
Variable_name Value
|
||||
grant select on *.* to role1;
|
||||
|
|
|
|||
|
|
@ -32,18 +32,18 @@ Grants for foo@localhost
|
|||
GRANT USAGE ON *.* TO 'foo'@'localhost'
|
||||
GRANT role10 TO 'foo'@'localhost'
|
||||
select * from information_schema.applicable_roles;
|
||||
GRANTEE ROLE_NAME IS_GRANTABLE
|
||||
foo@localhost role10 NO
|
||||
role10 role9 NO
|
||||
role2 role1 NO
|
||||
role4 role2 NO
|
||||
role5 role2 NO
|
||||
role5 role3 NO
|
||||
role6 role4 NO
|
||||
role6 role5 NO
|
||||
role7 role5 NO
|
||||
role9 role6 NO
|
||||
role9 role7 NO
|
||||
GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
|
||||
foo@localhost role10 NO NO
|
||||
role10 role9 NO NULL
|
||||
role2 role1 NO NULL
|
||||
role4 role2 NO NULL
|
||||
role5 role2 NO NULL
|
||||
role5 role3 NO NULL
|
||||
role6 role4 NO NULL
|
||||
role6 role5 NO NULL
|
||||
role7 role5 NO NULL
|
||||
role9 role6 NO NULL
|
||||
role9 role7 NO NULL
|
||||
show status like 'debug%';
|
||||
Variable_name Value
|
||||
Debug_role_merges_global 11
|
||||
|
|
|
|||
|
|
@ -23,15 +23,15 @@ user host
|
|||
grant select on mysql.* to test_role2;
|
||||
flush privileges;
|
||||
select * from information_schema.applicable_roles;
|
||||
GRANTEE ROLE_NAME IS_GRANTABLE
|
||||
root@localhost test_role1 YES
|
||||
root@localhost test_role2 YES
|
||||
test_role1 test_role2 NO
|
||||
GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
|
||||
root@localhost test_role1 YES NO
|
||||
root@localhost test_role2 YES NO
|
||||
test_role1 test_role2 NO NULL
|
||||
select * from information_schema.applicable_roles;
|
||||
GRANTEE ROLE_NAME IS_GRANTABLE
|
||||
test_role1 test_role2 NO
|
||||
test_user@localhost test_role1 NO
|
||||
test_user@localhost test_role2 NO
|
||||
GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
|
||||
test_role1 test_role2 NO NULL
|
||||
test_user@localhost test_role1 NO NO
|
||||
test_user@localhost test_role2 NO NO
|
||||
show grants;
|
||||
Grants for test_user@localhost
|
||||
GRANT USAGE ON *.* TO 'test_user'@'localhost'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue