diff --git a/src/box/lua/schema.lua b/src/box/lua/schema.lua index a5d0c6ff268b01c05d113fe870382ea72d05c8ae..694c77ba1c41e058bfb19aaf6057d8d3af710a2c 100644 --- a/src/box/lua/schema.lua +++ b/src/box/lua/schema.lua @@ -1016,6 +1016,11 @@ box.schema.user.drop = function(name) for k, tuple in pairs(funcs) do box.schema.func.drop(tuple[1]) end + -- if this is a role, revoke grants of this role + grants = _priv.index.object:select{'role', uid} + for k, tuple in pairs(grants) do + box.schema.user.revoke(tuple[2], uid) + end box.space[box.schema.USER_ID]:delete{uid} end diff --git a/test/box/role.result b/test/box/role.result index 37f2f9f9c0e20b06eb289c4db823e61ef293b79b..3114636230cd695cd1fe10911ecda9c767a59a94 100644 --- a/test/box/role.result +++ b/test/box/role.result @@ -133,3 +133,24 @@ box.schema.role.drop('c') box.schema.role.drop('a') --- ... +-- check that when dropping a role, it's first revoked +-- from whoever it is granted +box.schema.role.create('a') +--- +... +box.schema.role.create('b') +--- +... +box.schema.user.grant('b', 'a') +--- +... +box.schema.role.drop('a') +--- +... +box.schema.user.info('b') +--- +- [] +... +box.schema.role.drop('b') +--- +... diff --git a/test/box/role.test.lua b/test/box/role.test.lua index fd08324200406c4c7cdd8bcaf3859b226681cda1..33e5039248f7d7c502439571190213985a9e9226 100644 --- a/test/box/role.test.lua +++ b/test/box/role.test.lua @@ -42,3 +42,11 @@ box.schema.role.drop('d') box.schema.role.drop('b') box.schema.role.drop('c') box.schema.role.drop('a') +-- check that when dropping a role, it's first revoked +-- from whoever it is granted +box.schema.role.create('a') +box.schema.role.create('b') +box.schema.user.grant('b', 'a') +box.schema.role.drop('a') +box.schema.user.info('b') +box.schema.role.drop('b')