Skip to content

Commit 2d5db04

Browse files
committed
HBASE-26208 Supports revoke @ns specified permission
1 parent 5cf728d commit 2d5db04

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ def teardown
6363
assert_match(eval("/WRITE/"), permission.to_s)
6464
end
6565

66-
security_admin.grant(test_grant_revoke_user,"RX", @test_name)
66+
security_admin.grant(test_grant_revoke_user,"RXCA", @test_name)
67+
security_admin.revoke(test_grant_revoke_user, @test_name, "CA")
6768
found_permission = false
6869
security_admin.user_permission(@test_name) do |user, permission|
6970
if user == "test_grant_revoke"

0 commit comments

Comments
 (0)