RANGER-5610:getResourceACLs for a principal should consider validitySchedule of principal for ACL creation#988
RANGER-5610:getResourceACLs for a principal should consider validitySchedule of principal for ACL creation#988rameeshm wants to merge 2 commits into
Conversation
…chedule of principal for ACL creation Signed-off-by: Ramesh Mani <rmani@apache.org>
…chedule of principal for ACL creation -include implied grants in policy item selection
|
@mneethiraj Please review this patch. Thanks. |
| Map<String, Collection<String>> impliedGrants = null; | ||
| Map<String, Collection<String>> gdsImpliedGrants = null; | ||
|
|
||
| if (hivePlugin != null) { |
There was a problem hiding this comment.
hivePlugin will not null here given the caller already references it at line 2847. I suggest removing the if at 2884.
|
|
||
| if (hivePlugin != null) { | ||
| RangerServiceDef serviceDef = hivePlugin.getServiceDef(); | ||
| if (serviceDef != null) { |
There was a problem hiding this comment.
Consider replacing this if block by initializing impliedGrants in line 2881 with:
final Map<String, Collection<String>> impliedGrants = hivePlugin.getServiceDefHelper() != null ? hivePlugin.getServiceDefHelper().getImpliedAccessGrants() : Collections.emptyMap();
|
|
||
| GdsPolicyEngine gdsPolicyEngine = hivePlugin.getGdsPolicyEngine(); | ||
| if (gdsPolicyEngine != null && gdsPolicyEngine.getGdsInfo() != null) { | ||
| RangerServiceDef gdsServiceDef = gdsPolicyEngine.getGdsInfo().getGdsServiceDef(); |
There was a problem hiding this comment.
Consider updating GdsPolicyEngine to expose RangerServiceDefHelper and use it to initialize gdsImpliedGrants in line 2882.
final Map<String, Collection<String>> gdsImpliedGrants = gdsPolicyEngine != null && gdsPolicyEngine.getServiceDefHelper() != null ? gdsPolicyEngine.getServiceDefHelper().getImpliedAccessGrants() : Collections.emptyMap();
| } | ||
|
|
||
| Map<RangerPolicy.RangerPolicyItem, Boolean> policyItemActiveCache = new HashMap<>(); | ||
| List<String> keysToRemove = new ArrayList<>(); |
There was a problem hiding this comment.
keysToRemove ==> permissionsToRemove
| } | ||
| } | ||
| if (!hasActiveItem) { | ||
| keysToRemove.add(entry.getKey()); |
There was a problem hiding this comment.
@rameeshm - if multiple policies grant this permission to the principal, removing the permission based on just one policy (line 2904) will result in incorrect ACLs.
What changes were proposed in this pull request?
getResourceACLs for a principal should consider validitySchedule of principal for ACL creation. Currently getResourceACLs returns a set of ACLs for the principal but if the principal is has a validity period which is expired, it is giving the ACLs which are there which is not correct.
This scenario occurs in GDS where a principal validity period is expired and ACL still show the access given, even though there is no access.
Show Privileges in RangerHiveAuthorizer uses the getResourceACLs which also result in wrong permission sets shown when the principal validity period expired. Fix will filter the getResourceACLs for the Prinicipal in RangerHiveAuthorizer if the validitySchedule is not allowing the access for the resource.
How was this patch tested?
Tested in Local VM and Unit Tests.