You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by rm...@apache.org on 2020/12/16 04:28:09 UTC
[ranger] branch ranger-2.2 updated: RANGER-3121:HBase list command
authorization issue in Ranger
This is an automated email from the ASF dual-hosted git repository.
rmani pushed a commit to branch ranger-2.2
in repository https://gitbox.apache.org/repos/asf/ranger.git
The following commit(s) were added to refs/heads/ranger-2.2 by this push:
new 9db4888 RANGER-3121:HBase list command authorization issue in Ranger
9db4888 is described below
commit 9db488807ae8731106c8d15ce9203df0fe8579c7
Author: Ramesh Mani <rm...@cloudera.com>
AuthorDate: Tue Dec 15 15:45:23 2020 -0800
RANGER-3121:HBase list command authorization issue in Ranger
Signed-off-by: Ramesh Mani <rm...@cloudera.com>
---
.../hbase/RangerAuthorizationCoprocessor.java | 81 +++++++++++++---------
1 file changed, 49 insertions(+), 32 deletions(-)
diff --git a/hbase-agent/src/main/java/org/apache/ranger/authorization/hbase/RangerAuthorizationCoprocessor.java b/hbase-agent/src/main/java/org/apache/ranger/authorization/hbase/RangerAuthorizationCoprocessor.java
index 924c531..d9872ff 100644
--- a/hbase-agent/src/main/java/org/apache/ranger/authorization/hbase/RangerAuthorizationCoprocessor.java
+++ b/hbase-agent/src/main/java/org/apache/ranger/authorization/hbase/RangerAuthorizationCoprocessor.java
@@ -1180,44 +1180,25 @@ public class RangerAuthorizationCoprocessor implements AccessControlService.Inte
}
@Override
+ public void postGetTableNames(ObserverContext<MasterCoprocessorEnvironment> ctx, List<TableDescriptor> descriptors, String regex) throws IOException {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(String.format("==> postGetTableNames(count(descriptors)=%s, regex=%s)", descriptors == null ? 0 : descriptors.size(), regex));
+ }
+ checkAccess(ctx, "getTableNames", descriptors, regex);
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(String.format("<== postGetTableNames(count(descriptors)=%s, regex=%s)", descriptors == null ? 0 : descriptors.size(), regex));
+ }
+ }
+
+ @Override
public void postGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx, List<TableName> tableNamesList, List<TableDescriptor> descriptors, String regex) throws IOException {
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("==> postGetTableDescriptors(count(tableNamesList)=%s, count(descriptors)=%s, regex=%s)", tableNamesList == null ? 0 : tableNamesList.size(),
descriptors == null ? 0 : descriptors.size(), regex));
}
- if (CollectionUtils.isNotEmpty(descriptors)) {
- // Retains only those which passes authorization checks
- User user = getActiveUser(ctx);
- String access = _authUtils.getAccess(Action.CREATE);
- HbaseAuditHandler auditHandler = _factory.getAuditHandler(); // this will accumulate audits for all tables that succeed.
- AuthorizationSession session = new AuthorizationSession(hbasePlugin)
- .operation("getTableDescriptors")
- .otherInformation("regex=" + regex)
- .remoteAddress(getRemoteAddress())
- .auditHandler(auditHandler)
- .user(user)
- .access(access);
-
- Iterator<TableDescriptor> itr = descriptors.iterator();
- while (itr.hasNext()) {
- TableDescriptor htd = itr.next();
- String tableName = htd.getTableName().getNameAsString();
- session.table(tableName).buildRequest().authorize();
- if (!session.isAuthorized()) {
- List<AuthzAuditEvent> events = null;
- itr.remove();
- AuthzAuditEvent event = auditHandler.getAndDiscardMostRecentEvent();
- if (event != null) {
- events = Lists.newArrayList(event);
- }
- auditHandler.logAuthzAudits(events);
- }
- }
- if (descriptors.size() > 0) {
- session.logCapturedEvents();
- }
- }
+ checkAccess(ctx, "getTableDescriptors", descriptors, regex);
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("<== postGetTableDescriptors(count(tableNamesList)=%s, count(descriptors)=%s, regex=%s)", tableNamesList == null ? 0 : tableNamesList.size(),
@@ -1765,6 +1746,42 @@ public class RangerAuthorizationCoprocessor implements AccessControlService.Inte
return ret.toString();
}
+ private void checkAccess(ObserverContext<MasterCoprocessorEnvironment> ctx, String operation, List<TableDescriptor> descriptors, String regex) {
+
+ if (CollectionUtils.isNotEmpty(descriptors)) {
+ // Retains only those which passes authorization checks
+ User user = getActiveUser(ctx);
+ String access = _authUtils.getAccess(Action.CREATE);
+ HbaseAuditHandler auditHandler = _factory.getAuditHandler(); // this will accumulate audits for all tables that succeed.
+ AuthorizationSession session = new AuthorizationSession(hbasePlugin)
+ .operation(operation)
+ .otherInformation("regex=" + regex)
+ .remoteAddress(getRemoteAddress())
+ .auditHandler(auditHandler)
+ .user(user)
+ .access(access);
+
+ Iterator<TableDescriptor> itr = descriptors.iterator();
+ while (itr.hasNext()) {
+ TableDescriptor htd = itr.next();
+ String tableName = htd.getTableName().getNameAsString();
+ session.table(tableName).buildRequest().authorize();
+ if (!session.isAuthorized()) {
+ List<AuthzAuditEvent> events = null;
+ itr.remove();
+ AuthzAuditEvent event = auditHandler.getAndDiscardMostRecentEvent();
+ if (event != null) {
+ events = Lists.newArrayList(event);
+ }
+ auditHandler.logAuthzAudits(events);
+ }
+ }
+ if (descriptors.size() > 0) {
+ session.logCapturedEvents();
+ }
+ }
+ }
+
enum PredicateType {STARTROW, STOPROW, FILTER, COLUMNS, ROW};
}