Skip to content

Commit 205d616

Browse files
author
SiCheng-Zheng
committed
HBASE-26208 Supports revoke @ns specified permission
1 parent 5cf728d commit 205d616

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

hbase-shell/src/main/ruby/hbase/security.rb

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,21 @@ def revoke(user, table_name = nil, family = nil, qualifier = nil)
100100
namespace_name = table_name[1...table_name.length]
101101
raise(ArgumentError, "Can't find a namespace: #{namespace_name}") unless namespace_exists?(namespace_name)
102102

103-
tablebytes = table_name.to_java_bytes
104-
org.apache.hadoop.hbase.security.access.AccessControlClient.revoke(
105-
@connection, namespace_name, user
106-
)
103+
if (!family.nil?)
104+
permission = family[1...family.length-1]
105+
perm = org.apache.hadoop.hbase.security.access.Permission.new(
106+
permission.to_java_bytes
107+
)
108+
puts "revoke #{permission} permission"
109+
org.apache.hadoop.hbase.security.access.AccessControlClient.revoke(
110+
@connection, namespace_name, user, perm.getActions
111+
)
112+
else
113+
tablebytes = table_name.to_java_bytes
114+
org.apache.hadoop.hbase.security.access.AccessControlClient.revoke(
115+
@connection, namespace_name, user
116+
)
117+
end
107118
else
108119
# Table should exist
109120
raise(ArgumentError, "Can't find a table: #{table_name}") unless exists?(table_name)

hbase-shell/src/main/ruby/shell/commands/revoke.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def help
3434
hbase> revoke 'bobsmith'
3535
hbase> revoke '@admins'
3636
hbase> revoke 'bobsmith', '@ns1'
37+
hbase> revoke 'bobsmith', '@ns1', 'RWXCA'
3738
hbase> revoke 'bobsmith', 't1', 'f1', 'col1'
3839
hbase> revoke 'bobsmith', 'ns1:t1', 'f1', 'col1'
3940
EOF

hbase-shell/src/test/ruby/hbase/security_admin_test.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ def teardown
5050
assert_equal(1, security_admin.user_permission(@test_name).length)
5151
security_admin.revoke(user, @test_name)
5252
assert_equal(0, security_admin.user_permission(@test_name).length)
53+
security_admin.grant(test_grant_revoke_user,"RW", @test_name)
54+
security_admin.revoke(test_grant_revoke_user,"R", @test_name)
55+
assert_equal(1, security_admin.user_permission(@test_name).length)
5356
end
5457

5558
define_test "Grant should set access rights appropriately" do

0 commit comments

Comments
 (0)