Class AccessChecker
java.lang.Object
org.apache.hadoop.hbase.security.access.AccessChecker
- Direct Known Subclasses:
NoopAccessChecker
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A temporary user class to instantiate User instance based on the name and groups. -
Field Summary
Modifier and TypeFieldDescriptionprivate static final org.slf4j.Logger
private final AuthManager
private static org.apache.hadoop.security.Groups
Group service to retrieve the user group informationprivate static final org.slf4j.Logger
-
Constructor Summary
ConstructorDescriptionAccessChecker
(org.apache.hadoop.conf.Configuration conf) Constructor with existing configuration -
Method Summary
Modifier and TypeMethodDescriptionvoid
checkLockPermissions
(User user, String namespace, TableName tableName, RegionInfo[] regionInfos, String reason) getUserGroups
(String user) Retrieve the groups of the given user.boolean
hasUserPermission
(User user, String request, Permission permission) Authorizes that if the current user has the given permissions.private void
initGroupService
(org.apache.hadoop.conf.Configuration conf) static boolean
isAuthorizationSupported
(org.apache.hadoop.conf.Configuration conf) static void
logResult
(AuthResult result) private Map<byte[],
? extends Collection<byte[]>> makeFamilyMap
(byte[] family, byte[] qualifier) void
performOnSuperuser
(String request, User caller, String userToBeChecked) Check if caller is granting or revoking superusers's or supergroups's permissions.private AuthResult
permissionGranted
(String request, User user, Permission.Action permRequest, TableName tableName, byte[] family, byte[] qualifier) permissionGranted
(String request, User user, Permission.Action permRequest, TableName tableName, Map<byte[], ? extends Collection<?>> families) Check the current user for authorization to perform a specific action against the given set of row data.void
requireAccess
(User user, String request, TableName tableName, Permission.Action... permissions) Authorizes that the current user has any of the given permissions to access the table.void
requireGlobalPermission
(User user, String request, Permission.Action perm, String namespace) Checks that the user has the given global permission.void
requireGlobalPermission
(User user, String request, Permission.Action perm, TableName tableName, Map<byte[], ? extends Collection<byte[]>> familyMap, String filterUser) Checks that the user has the given global permission.void
requireNamespacePermission
(User user, String request, String namespace, String filterUser, Permission.Action... permissions) Checks that the user has the given global or namespace permission.void
requireNamespacePermission
(User user, String request, String namespace, TableName tableName, Map<byte[], ? extends Collection<byte[]>> familyMap, Permission.Action... permissions) Checks that the user has the given global or namespace permission.void
requirePermission
(User user, String request, String filterUser, Permission.Action perm) Authorizes that the current user has global privileges for the given action.void
requirePermission
(User user, String request, TableName tableName, byte[] family, byte[] qualifier, String filterUser, Permission.Action... permissions) Authorizes that the current user has any of the given permissions for the given table, column family and column qualifier.void
requireTablePermission
(User user, String request, TableName tableName, byte[] family, byte[] qualifier, Permission.Action... permissions) Authorizes that the current user has any of the given permissions for the given table, column family and column qualifier.validateCallerWithFilterUser
(User caller, TablePermission tPerm, String inputUserName)
-
Field Details
-
LOG
-
AUDITLOG
-
authManager
-
groupService
Group service to retrieve the user group information
-
-
Constructor Details
-
AccessChecker
Constructor with existing configuration- Parameters:
conf
- Existing configuration to use
-
-
Method Details
-
isAuthorizationSupported
-
getAuthManager
-
requireAccess
public void requireAccess(User user, String request, TableName tableName, Permission.Action... permissions) throws IOException Authorizes that the current user has any of the given permissions to access the table.- Parameters:
user
- Active user to which authorization checks should be appliedrequest
- Request type.tableName
- Table requestedpermissions
- Actions being requested- Throws:
IOException
- if obtaining the current user failsAccessDeniedException
- if user has no authorization
-
requirePermission
public void requirePermission(User user, String request, String filterUser, Permission.Action perm) throws IOException Authorizes that the current user has global privileges for the given action.- Parameters:
user
- Active user to which authorization checks should be appliedrequest
- Request typefilterUser
- User name to be filtered from permission as requestedperm
- The action being requested- Throws:
IOException
- if obtaining the current user failsAccessDeniedException
- if authorization is denied
-
requireGlobalPermission
public void requireGlobalPermission(User user, String request, Permission.Action perm, TableName tableName, Map<byte[], ? extends Collection<byte[]>> familyMap, String filterUser) throws IOExceptionChecks that the user has the given global permission. The generated audit log message will contain context information for the operation being authorized, based on the given parameters.- Parameters:
user
- Active user to which authorization checks should be appliedrequest
- Request typeperm
- Action being requestedtableName
- Affected table name.familyMap
- Affected column families.filterUser
- User name to be filtered from permission as requested- Throws:
IOException
-
requireGlobalPermission
public void requireGlobalPermission(User user, String request, Permission.Action perm, String namespace) throws IOException Checks that the user has the given global permission. The generated audit log message will contain context information for the operation being authorized, based on the given parameters.- Parameters:
user
- Active user to which authorization checks should be appliedrequest
- Request typeperm
- Action being requestednamespace
- The given namespace- Throws:
IOException
-
requireNamespacePermission
public void requireNamespacePermission(User user, String request, String namespace, String filterUser, Permission.Action... permissions) throws IOException Checks that the user has the given global or namespace permission.- Parameters:
user
- Active user to which authorization checks should be appliedrequest
- Request typenamespace
- Name space as requestedfilterUser
- User name to be filtered from permission as requestedpermissions
- Actions being requested- Throws:
IOException
-
requireNamespacePermission
public void requireNamespacePermission(User user, String request, String namespace, TableName tableName, Map<byte[], ? extends Collection<byte[]>> familyMap, Permission.Action... permissions) throws IOExceptionChecks that the user has the given global or namespace permission.- Parameters:
user
- Active user to which authorization checks should be appliedrequest
- Request typenamespace
- The given namespacetableName
- Table requestedfamilyMap
- Column family map requestedpermissions
- Actions being requested- Throws:
IOException
-
requirePermission
public void requirePermission(User user, String request, TableName tableName, byte[] family, byte[] qualifier, String filterUser, Permission.Action... permissions) throws IOException Authorizes that the current user has any of the given permissions for the given table, column family and column qualifier.- Parameters:
user
- Active user to which authorization checks should be appliedrequest
- Request typetableName
- Table requestedfamily
- Column family requestedqualifier
- Column qualifier requestedfilterUser
- User name to be filtered from permission as requestedpermissions
- Actions being requested- Throws:
IOException
- if obtaining the current user failsAccessDeniedException
- if user has no authorization
-
requireTablePermission
public void requireTablePermission(User user, String request, TableName tableName, byte[] family, byte[] qualifier, Permission.Action... permissions) throws IOException Authorizes that the current user has any of the given permissions for the given table, column family and column qualifier.- Parameters:
user
- Active user to which authorization checks should be appliedrequest
- Request typetableName
- Table requestedfamily
- Column family paramqualifier
- Column qualifier param- Throws:
IOException
- if obtaining the current user failsAccessDeniedException
- if user has no authorization
-
performOnSuperuser
public void performOnSuperuser(String request, User caller, String userToBeChecked) throws IOException Check if caller is granting or revoking superusers's or supergroups's permissions.- Parameters:
request
- request namecaller
- calleruserToBeChecked
- target user or group- Throws:
IOException
- AccessDeniedException if target user is superuser
-
checkLockPermissions
public void checkLockPermissions(User user, String namespace, TableName tableName, RegionInfo[] regionInfos, String reason) throws IOException - Throws:
IOException
-
logResult
-
validateCallerWithFilterUser
public User validateCallerWithFilterUser(User caller, TablePermission tPerm, String inputUserName) throws IOException - Throws:
IOException
-
initGroupService
-
getUserGroups
Retrieve the groups of the given user.- Parameters:
user
- User name
-
hasUserPermission
Authorizes that if the current user has the given permissions.- Parameters:
user
- Active user to which authorization checks should be appliedrequest
- Request typepermission
- Actions being requested- Returns:
- True if the user has the specific permission
-
permissionGranted
private AuthResult permissionGranted(String request, User user, Permission.Action permRequest, TableName tableName, byte[] family, byte[] qualifier) -
permissionGranted
public AuthResult permissionGranted(String request, User user, Permission.Action permRequest, TableName tableName, Map<byte[], ? extends Collection<?>> families) Check the current user for authorization to perform a specific action against the given set of row data.Note: Ordering of the authorization checks has been carefully optimized to short-circuit the most common requests and minimize the amount of processing required.
- Parameters:
request
- User requestuser
- User namepermRequest
- the action being requestedtableName
- Table namefamilies
- the map of column families to qualifiers present in the request- Returns:
- an authorization result
-
makeFamilyMap
-