@InterfaceAudience.Private public final class AuthManager extends Object
There're following scopes: Global, Namespace, Table, Family, Qualifier, Cell. Generally speaking, higher scopes can overrides lower scopes, except for Cell permission can be granted even a user has not permission on specified table, which means the user can get/scan only those granted cells parts.
e.g, if user A has global permission R(ead), he can read table T without checking table scope permission, so authorization checks alway starts from Global scope.For each scope, not only user but also groups he belongs to will be checked.
Modifier and Type | Class and Description |
---|---|
private static class |
AuthManager.PermissionCache<T extends Permission>
Cache of permissions, it is thread safe.
|
Modifier and Type | Field and Description |
---|---|
private org.apache.hadoop.conf.Configuration |
conf |
private Map<String,GlobalPermission> |
globalCache
Cache for global permission excluding superuser and supergroup.
|
private static org.slf4j.Logger |
LOG |
private AtomicLong |
mtime |
private ConcurrentHashMap<String,AuthManager.PermissionCache<NamespacePermission>> |
namespaceCache
Cache for namespace permission.
|
(package private) AuthManager.PermissionCache<NamespacePermission> |
NS_NO_PERMISSION |
private ConcurrentHashMap<TableName,AuthManager.PermissionCache<TablePermission>> |
tableCache
Cache for table permission.
|
(package private) AuthManager.PermissionCache<TablePermission> |
TBL_NO_PERMISSION |
Constructor and Description |
---|
AuthManager(org.apache.hadoop.conf.Configuration conf) |
Modifier and Type | Method and Description |
---|---|
boolean |
accessUserTable(User user,
TableName table,
Permission.Action action)
Checks if the user has access to the full table or at least a family/qualifier for the
specified action.
|
boolean |
authorizeCell(User user,
TableName table,
Cell cell,
Permission.Action action)
Check if user has given action privilige in cell scope.
|
private boolean |
authorizeFamily(Set<TablePermission> permissions,
TableName table,
byte[] family,
Permission.Action action) |
private boolean |
authorizeGlobal(GlobalPermission permissions,
Permission.Action action) |
private boolean |
authorizeNamespace(Set<NamespacePermission> permissions,
String namespace,
Permission.Action action) |
private boolean |
authorizeTable(Set<TablePermission> permissions,
TableName table,
byte[] family,
byte[] qualifier,
Permission.Action action) |
boolean |
authorizeUserFamily(User user,
TableName table,
byte[] family,
Permission.Action action)
Check if user has given action privilige in table:family scope.
|
boolean |
authorizeUserGlobal(User user,
Permission.Action action)
Check if user has given action privilige in global scope.
|
boolean |
authorizeUserNamespace(User user,
String namespace,
Permission.Action action)
Check if user has given action privilige in namespace scope.
|
boolean |
authorizeUserTable(User user,
TableName table,
byte[] family,
byte[] qualifier,
Permission.Action action)
Check if user has given action privilige in table:family:qualifier scope.
|
boolean |
authorizeUserTable(User user,
TableName table,
byte[] family,
Permission.Action action)
Check if user has given action privilige in table:family scope.
|
boolean |
authorizeUserTable(User user,
TableName table,
Permission.Action action)
Check if user has given action privilige in table scope.
|
private void |
clearCache(AuthManager.PermissionCache cacheToUpdate) |
long |
getMTime()
Last modification logical time n
|
private boolean |
hasAccessTable(Set<TablePermission> permissions,
Permission.Action action) |
void |
refreshNamespaceCacheFromWritable(String namespace,
byte[] data)
Update acl info for namespace.
|
void |
refreshTableCacheFromWritable(TableName table,
byte[] data)
Update acl info for table.
|
void |
removeNamespace(byte[] ns)
Remove given namespace from AuthManager's namespace cache.
|
void |
removeTable(TableName table)
Remove given table from AuthManager's table cache.
|
private void |
updateCache(org.apache.hbase.thirdparty.com.google.common.collect.ListMultimap<String,? extends Permission> newPermissions,
AuthManager.PermissionCache cacheToUpdate) |
private void |
updateGlobalCache(org.apache.hbase.thirdparty.com.google.common.collect.ListMultimap<String,Permission> globalPerms)
Updates the internal global permissions cache.
|
private void |
updateNamespaceCache(String namespace,
org.apache.hbase.thirdparty.com.google.common.collect.ListMultimap<String,Permission> nsPerms)
Updates the internal namespace permissions cache for specified namespace.
|
private void |
updateTableCache(TableName table,
org.apache.hbase.thirdparty.com.google.common.collect.ListMultimap<String,Permission> tablePerms)
Updates the internal table permissions cache for specified table.
|
AuthManager.PermissionCache<NamespacePermission> NS_NO_PERMISSION
AuthManager.PermissionCache<TablePermission> TBL_NO_PERMISSION
private Map<String,GlobalPermission> globalCache
private ConcurrentHashMap<String,AuthManager.PermissionCache<NamespacePermission>> namespaceCache
private ConcurrentHashMap<TableName,AuthManager.PermissionCache<TablePermission>> tableCache
private static final org.slf4j.Logger LOG
private org.apache.hadoop.conf.Configuration conf
private final AtomicLong mtime
AuthManager(org.apache.hadoop.conf.Configuration conf)
public void refreshTableCacheFromWritable(TableName table, byte[] data) throws IOException
table
- name of tabledata
- updated acl dataIOException
- exception when deserialize datapublic void refreshNamespaceCacheFromWritable(String namespace, byte[] data) throws IOException
namespace
- namespacedata
- updated acl dataIOException
- exception when deserialize dataprivate void updateGlobalCache(org.apache.hbase.thirdparty.com.google.common.collect.ListMultimap<String,Permission> globalPerms)
globalPerms
- new global permissionsprivate void updateTableCache(TableName table, org.apache.hbase.thirdparty.com.google.common.collect.ListMultimap<String,Permission> tablePerms)
table
- updated table nametablePerms
- new table permissionsprivate void updateNamespaceCache(String namespace, org.apache.hbase.thirdparty.com.google.common.collect.ListMultimap<String,Permission> nsPerms)
namespace
- updated namespacensPerms
- new namespace permissionsprivate void clearCache(AuthManager.PermissionCache cacheToUpdate)
private void updateCache(org.apache.hbase.thirdparty.com.google.common.collect.ListMultimap<String,? extends Permission> newPermissions, AuthManager.PermissionCache cacheToUpdate)
public boolean authorizeUserGlobal(User user, Permission.Action action)
user
- user nameaction
- one of action in [Read, Write, Create, Exec, Admin]private boolean authorizeGlobal(GlobalPermission permissions, Permission.Action action)
public boolean authorizeUserNamespace(User user, String namespace, Permission.Action action)
user
- user namenamespace
- namespaceaction
- one of action in [Read, Write, Create, Exec, Admin]private boolean authorizeNamespace(Set<NamespacePermission> permissions, String namespace, Permission.Action action)
public boolean accessUserTable(User user, TableName table, Permission.Action action)
user
- user nametable
- table nameaction
- action in one of [Read, Write, Create, Exec, Admin]private boolean hasAccessTable(Set<TablePermission> permissions, Permission.Action action)
public boolean authorizeUserTable(User user, TableName table, Permission.Action action)
user
- user nametable
- table nameaction
- one of action in [Read, Write, Create, Exec, Admin]public boolean authorizeUserTable(User user, TableName table, byte[] family, Permission.Action action)
user
- user nametable
- table namefamily
- family nameaction
- one of action in [Read, Write, Create, Exec, Admin]public boolean authorizeUserTable(User user, TableName table, byte[] family, byte[] qualifier, Permission.Action action)
user
- user nametable
- table namefamily
- family namequalifier
- qualifier nameaction
- one of action in [Read, Write, Create, Exec, Admin]private boolean authorizeTable(Set<TablePermission> permissions, TableName table, byte[] family, byte[] qualifier, Permission.Action action)
public boolean authorizeUserFamily(User user, TableName table, byte[] family, Permission.Action action)
user
- user nametable
- table namefamily
- family namesaction
- one of action in [Read, Write, Create, Exec, Admin]private boolean authorizeFamily(Set<TablePermission> permissions, TableName table, byte[] family, Permission.Action action)
public boolean authorizeCell(User user, TableName table, Cell cell, Permission.Action action)
user
- user nametable
- table namecell
- cell to be checkedaction
- one of action in [Read, Write, Create, Exec, Admin]public void removeNamespace(byte[] ns)
ns
- namespacepublic void removeTable(TableName table)
table
- table namepublic long getMTime()
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.