You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ranger.apache.org by "fateh288 (via GitHub)" <gi...@apache.org> on 2024/11/26 23:27:22 UTC
[PR] RANGER-4670: (hbase plugin) Config to support disabling column authorization for fully authorized column families [ranger]
fateh288 opened a new pull request, #417:
URL: https://github.com/apache/ranger/pull/417
## What changes were proposed in this pull request?
A property/flag can be set via hbase service configs wherein during column level authorization, it can be used to determine if an authorization at column family can be used to determine if column authorization can be shortcircuited as an optimization (there will be audit behavior changes in this case). This is useful for improving performance especially for multiget and multiput workloads wherein thousands of columns can come in the authorization request and just checking column family level access can improve performance drastically
## How was this patch tested?
Existing test cases work
New test cases have been added for hbase. The test cases cover the scan operation bug addressed in RANGER-4977 and also covers new unit test cases for testing correctness of column authorization shortcircuiting. These minicluster cased test cases do not work on master branch (because they are ignored using junit ignore annotation -- currently being tracked at https://issues.apache.org/jira/browse/RANGER-4686 and was caused due to hadoop version upgrades)
I have verified that the new added test cases work on my private fork.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@ranger.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RANGER-4670: (hbase plugin) Config to support disabling column authorization for fully authorized column families [ranger]
Posted by "fateh288 (via GitHub)" <gi...@apache.org>.
fateh288 merged PR #417:
URL: https://github.com/apache/ranger/pull/417
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@ranger.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RANGER-4670: (hbase plugin) Config to support disabling column authorization for fully authorized column families [ranger]
Posted by "fateh288 (via GitHub)" <gi...@apache.org>.
fateh288 commented on PR #417:
URL: https://github.com/apache/ranger/pull/417#issuecomment-2513292483
@mneethiraj
I have added performance analysis numbers for multiput workload and audits generated with/without the optimization enabled
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@ranger.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RANGER-4670: (hbase plugin) Config to support disabling column authorization for fully authorized column families [ranger]
Posted by "mneethiraj (via GitHub)" <gi...@apache.org>.
mneethiraj commented on code in PR #417:
URL: https://github.com/apache/ranger/pull/417#discussion_r1866737222
##########
agents-common/src/main/java/org/apache/ranger/authorization/hadoop/constants/RangerHadoopConstants.java:
##########
@@ -51,6 +51,7 @@ public class RangerHadoopConstants {
public static final String HBASE_UPDATE_RANGER_POLICIES_ON_GRANT_REVOKE_PROP = "xasecure.hbase.update.xapolicies.on.grant.revoke";
public static final boolean HBASE_UPDATE_RANGER_POLICIES_ON_GRANT_REVOKE_DEFAULT_VALUE = true;
+ public static final String HBASE_COLUMN_AUTH_OPTIMIZATION = "ranger.plugin.hbase.column.auth.optimization";
Review Comment:
`ranger.plugin.hbase.column.auth.optimization` => `ranger.plugin.hbase.column.auth.optimized`
##########
hbase-agent/src/main/java/org/apache/ranger/authorization/hbase/RangerAuthorizationCoprocessor.java:
##########
@@ -90,19 +91,28 @@ public class RangerAuthorizationCoprocessor implements AccessControlService.Inte
private static final String GROUP_PREFIX = "@";
private UserProvider userProvider;
- private RegionCoprocessorEnvironment regionEnv;
+ private RegionCoprocessorEnvironment regionEnv;
private Map<InternalScanner, String> scannerOwners = new MapMaker().weakKeys().makeMap();
/** if we should check EXEC permissions */
private boolean shouldCheckExecPermission;
-
+
/*
* These are package level only for testability and aren't meant to be exposed outside via getters/setters or made available to derived classes.
*/
final HbaseFactory _factory = HbaseFactory.getInstance();
final HbaseUserUtils _userUtils = _factory.getUserUtils();
final HbaseAuthUtils _authUtils = _factory.getAuthUtils();
private static volatile RangerHBasePlugin hbasePlugin = null;
-
+
+ public void setColumnAuthOptimizationEnabled(boolean enable) throws Exception {
+ if (hbasePlugin!=null) {
Review Comment:
Assign RangerAuthorizationCoprocessor. hbasePlugin to a local variable before accessing it:
```
RangerHBasePlugin plugn = RangerAuthorizationCoprocessor.hbasePlugin;
if (plugin != null) {
plugin. setColumnAuthOptimizationEnabled(enable);
}
```
##########
hbase-agent/src/main/java/org/apache/ranger/authorization/hbase/RangerAuthorizationCoprocessor.java:
##########
@@ -491,14 +515,52 @@ ColumnFamilyAccessResult evaluateAccess(ObserverContext<?> ctx, String operation
session.resourceMatchingScope(RangerAccessRequest.ResourceMatchingScope.SELF);
session.ignoreDescendantDeny(true);
} else {
- LOG.debug("evaluateAccess: columns collection not empty. Skipping Family level check, will do finer level access check.");
+ boolean isColumnAuthShortCircuitingEnabled = hbasePlugin.getPropertyIsColumnAuthOptimizationEnabled();
Review Comment:
To be consistent, rename: `isColumnAuthShortCircuitingEnabled` => `isColumnAuthOptimizationEnabled`
##########
hbase-agent/src/main/java/org/apache/ranger/authorization/hbase/RangerAuthorizationCoprocessor.java:
##########
@@ -491,14 +515,52 @@ ColumnFamilyAccessResult evaluateAccess(ObserverContext<?> ctx, String operation
session.resourceMatchingScope(RangerAccessRequest.ResourceMatchingScope.SELF);
session.ignoreDescendantDeny(true);
} else {
- LOG.debug("evaluateAccess: columns collection not empty. Skipping Family level check, will do finer level access check.");
+ boolean isColumnAuthShortCircuitingEnabled = hbasePlugin.getPropertyIsColumnAuthOptimizationEnabled();
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("evaluateAccess: columns collection not empty." +
+ " Skipping Family level check, will do finer level access check for columns.");
+ }
+ if (isColumnAuthShortCircuitingEnabled) {
+ session.column(null)
+ .buildRequest()
+ .authorize();
+
+ boolean isColumnFamilyAuthorized = session.isAuthorized();
+
+ //check if column family fully authorized i.e. no deny for columns
+ session.column(null)
+ .resourceMatchingScope(RangerAccessRequest.ResourceMatchingScope.SELF_OR_DESCENDANTS)
+ .ignoreDescendantDeny(false)
+ .buildRequest()
+ .authorize();
+
+ boolean isColumnFamilyAndDescendantsAuthorized = session.isAuthorized() && isColumnFamilyAuthorized;
+ AuthzAuditEvent auditEvent = auditHandler.getAndDiscardMostRecentEvent();
+ // reset ResourceMatchingScope to SELF, ignoreDescendantDeny to true
+ session.resourceMatchingScope(RangerAccessRequest.ResourceMatchingScope.SELF)
+ .ignoreDescendantDeny(true);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("evaluateAccess: isColumnAuthShortCircuitingEnabled=true, isColumnFamilyAndDescendantsAuthorized={}",isColumnFamilyAndDescendantsAuthorized);
+ }
+ if (isColumnFamilyAndDescendantsAuthorized) {
+ familiesFullyAuthorized.add(family);
+ if (auditEvent != null) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("evaluateAccess: isColumnAuthShortCircuitingEnabled=true, adding to familiesFullyAuthorized set");
Review Comment:
Include `family` in the log message, to be more useful.
```
LOG.debug("evaluateAccess: isColumnAuthOptimizationEnabled ={}, adding family {} to familiesFullyAuthorized", isColumnAuthOptimizationEnabled, family);
```
##########
hbase-agent/src/main/java/org/apache/ranger/authorization/hbase/RangerAuthorizationCoprocessor.java:
##########
@@ -491,14 +515,52 @@ ColumnFamilyAccessResult evaluateAccess(ObserverContext<?> ctx, String operation
session.resourceMatchingScope(RangerAccessRequest.ResourceMatchingScope.SELF);
session.ignoreDescendantDeny(true);
} else {
- LOG.debug("evaluateAccess: columns collection not empty. Skipping Family level check, will do finer level access check.");
+ boolean isColumnAuthShortCircuitingEnabled = hbasePlugin.getPropertyIsColumnAuthOptimizationEnabled();
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("evaluateAccess: columns collection not empty." +
+ " Skipping Family level check, will do finer level access check for columns.");
+ }
+ if (isColumnAuthShortCircuitingEnabled) {
+ session.column(null)
+ .buildRequest()
+ .authorize();
+
+ boolean isColumnFamilyAuthorized = session.isAuthorized();
+
+ //check if column family fully authorized i.e. no deny for columns
+ session.column(null)
Review Comment:
Can the second authz, starting with line 531, be skipped when `isColumnFamilyAuthorized` is `false`?
```
boolean isColumnFamilyAndDescendantsAuthorized = false;
if (session.isAuthorized()) {
session.column(null)
.resourceMatchingScope(RangerAccessRequest.ResourceMatchingScope.SELF_OR_DESCENDANTS)
.ignoreDescendantDeny(false)
.buildRequest()
.authorize();
isColumnFamilyAndDescendantsAuthorized = session.isAuthorized();
}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@ranger.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RANGER-4670: (hbase plugin) Config to support disabling column authorization for fully authorized column families [ranger]
Posted by "fateh288 (via GitHub)" <gi...@apache.org>.
fateh288 commented on code in PR #417:
URL: https://github.com/apache/ranger/pull/417#discussion_r1870157832
##########
hbase-agent/src/main/java/org/apache/ranger/authorization/hbase/RangerAuthorizationCoprocessor.java:
##########
@@ -90,19 +91,28 @@ public class RangerAuthorizationCoprocessor implements AccessControlService.Inte
private static final String GROUP_PREFIX = "@";
private UserProvider userProvider;
- private RegionCoprocessorEnvironment regionEnv;
+ private RegionCoprocessorEnvironment regionEnv;
private Map<InternalScanner, String> scannerOwners = new MapMaker().weakKeys().makeMap();
/** if we should check EXEC permissions */
private boolean shouldCheckExecPermission;
-
+
/*
* These are package level only for testability and aren't meant to be exposed outside via getters/setters or made available to derived classes.
*/
final HbaseFactory _factory = HbaseFactory.getInstance();
final HbaseUserUtils _userUtils = _factory.getUserUtils();
final HbaseAuthUtils _authUtils = _factory.getAuthUtils();
private static volatile RangerHBasePlugin hbasePlugin = null;
-
+
+ public void setColumnAuthOptimizationEnabled(boolean enable) throws Exception {
+ if (hbasePlugin!=null) {
Review Comment:
Why is this assigning hbasePlugin to a local variable required ?
hbasePlugin is already initialized in the start()
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@ranger.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RANGER-4670: (hbase plugin) Config to support disabling column authorization for fully authorized column families [ranger]
Posted by "mneethiraj (via GitHub)" <gi...@apache.org>.
mneethiraj commented on code in PR #417:
URL: https://github.com/apache/ranger/pull/417#discussion_r1870412116
##########
hbase-agent/src/main/java/org/apache/ranger/authorization/hbase/RangerAuthorizationCoprocessor.java:
##########
@@ -90,19 +91,28 @@ public class RangerAuthorizationCoprocessor implements AccessControlService.Inte
private static final String GROUP_PREFIX = "@";
private UserProvider userProvider;
- private RegionCoprocessorEnvironment regionEnv;
+ private RegionCoprocessorEnvironment regionEnv;
private Map<InternalScanner, String> scannerOwners = new MapMaker().weakKeys().makeMap();
/** if we should check EXEC permissions */
private boolean shouldCheckExecPermission;
-
+
/*
* These are package level only for testability and aren't meant to be exposed outside via getters/setters or made available to derived classes.
*/
final HbaseFactory _factory = HbaseFactory.getInstance();
final HbaseUserUtils _userUtils = _factory.getUserUtils();
final HbaseAuthUtils _authUtils = _factory.getAuthUtils();
private static volatile RangerHBasePlugin hbasePlugin = null;
-
+
+ public void setColumnAuthOptimizationEnabled(boolean enable) throws Exception {
+ if (hbasePlugin!=null) {
Review Comment:
hbasePlugin is a static volatile member, whose value could change between if at line 108 and referencing at line 109. Hence copying to a local variable is a safe practice.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@ranger.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RANGER-4670: (hbase plugin) Config to support disabling column authorization for fully authorized column families [ranger]
Posted by "fateh288 (via GitHub)" <gi...@apache.org>.
fateh288 commented on code in PR #417:
URL: https://github.com/apache/ranger/pull/417#discussion_r1870426631
##########
hbase-agent/src/main/java/org/apache/ranger/authorization/hbase/RangerAuthorizationCoprocessor.java:
##########
@@ -90,19 +91,28 @@ public class RangerAuthorizationCoprocessor implements AccessControlService.Inte
private static final String GROUP_PREFIX = "@";
private UserProvider userProvider;
- private RegionCoprocessorEnvironment regionEnv;
+ private RegionCoprocessorEnvironment regionEnv;
private Map<InternalScanner, String> scannerOwners = new MapMaker().weakKeys().makeMap();
/** if we should check EXEC permissions */
private boolean shouldCheckExecPermission;
-
+
/*
* These are package level only for testability and aren't meant to be exposed outside via getters/setters or made available to derived classes.
*/
final HbaseFactory _factory = HbaseFactory.getInstance();
final HbaseUserUtils _userUtils = _factory.getUserUtils();
final HbaseAuthUtils _authUtils = _factory.getAuthUtils();
private static volatile RangerHBasePlugin hbasePlugin = null;
-
+
+ public void setColumnAuthOptimizationEnabled(boolean enable) throws Exception {
+ if (hbasePlugin!=null) {
Review Comment:
Addressed in the latest commit
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@ranger.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org