Skip to content

Commit fd18ce4

Browse files
author
zhengsicheng
committed
HBASE-26208 Supports revoke @ns single permission
1 parent 4b0a640 commit fd18ce4

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

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

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,21 @@ def revoke(user, table_name = nil, family = nil, qualifier = nil)
9999
# Namespace should exist first.
100100
namespace_name = table_name[1...table_name.length]
101101
raise(ArgumentError, "Can't find a namespace: #{namespace_name}") unless namespace_exists?(namespace_name)
102-
103-
tablebytes = table_name.to_java_bytes
104-
org.apache.hadoop.hbase.security.access.AccessControlClient.revoke(
105-
@connection, namespace_name, user
106-
)
102+
if (!family.nil? and isPermissionType?(family))
103+
permission = family[1...family.length-1]
104+
perm = org.apache.hadoop.hbase.security.access.Permission.new(
105+
permission.to_java_bytes
106+
)
107+
puts "revoke #{permission} permission"
108+
org.apache.hadoop.hbase.security.access.AccessControlClient.revoke(
109+
@connection, namespace_name, user, perm.getActions
110+
)
111+
else
112+
tablebytes = table_name.to_java_bytes
113+
org.apache.hadoop.hbase.security.access.AccessControlClient.revoke(
114+
@connection, namespace_name, user
115+
)
116+
end
107117
else
108118
# Table should exist
109119
raise(ArgumentError, "Can't find a table: #{table_name}") unless exists?(table_name)
@@ -181,6 +191,10 @@ def isNamespace?(table_name)
181191
table_name.start_with?('@')
182192
end
183193

194+
def isPermissionType?(permission_type)
195+
permission_type.start_with?('{')
196+
end
197+
184198
def isTablePermission?(permission)
185199
permission.java_kind_of?(org.apache.hadoop.hbase.security.access.TablePermission)
186200
end

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def help
3333
3434
hbase> revoke 'bobsmith'
3535
hbase> revoke '@admins'
36-
hbase> revoke 'bobsmith', '@ns1'
36+
hbase> revoke 'bobsmith', '@ns1', '{permissions}'
3737
hbase> revoke 'bobsmith', 't1', 'f1', 'col1'
3838
hbase> revoke 'bobsmith', 'ns1:t1', 'f1', 'col1'
3939
EOF

0 commit comments

Comments
 (0)