|
11 | 11 | import org.apache.atlas.repository.graphdb.AtlasVertex; |
12 | 12 | import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2; |
13 | 13 | import org.apache.atlas.utils.AtlasPerfMetrics; |
| 14 | +import org.apache.commons.collections.CollectionUtils; |
14 | 15 | import org.apache.commons.lang.StringUtils; |
15 | 16 | import org.slf4j.Logger; |
16 | 17 | import org.slf4j.LoggerFactory; |
@@ -78,7 +79,9 @@ private static AtlasAccessResult isAccessAllowedInMemory(AtlasEntityHeader entit |
78 | 79 | private static AtlasAccessResult evaluateABACPoliciesInMemory(List<RangerPolicy> abacPolicies, AtlasEntityHeader entity) { |
79 | 80 | AtlasAccessResult result = new AtlasAccessResult(false); |
80 | 81 |
|
81 | | - AtlasVertex vertex = AtlasGraphUtilsV2.findByGuid(entity.getGuid()); |
| 82 | + // might have to fetch vertex when support for more attributes is added, so not removing the argument but setting to null for now |
| 83 | + AtlasVertex vertex = null; // AtlasGraphUtilsV2.findByGuid(entity.getGuid()); |
| 84 | + LOG.info("ABAC_AUTH: Attributes present in entity={} attrs={}", entity.getAttribute(ATTR_QUALIFIED_NAME), entity.getAttributes() == null ? "null" : entity.getAttributes().keySet()); |
82 | 85 |
|
83 | 86 | for (RangerPolicy policy : abacPolicies) { |
84 | 87 | boolean matched = false; |
@@ -293,19 +296,21 @@ private static List<String> getAttributeValue(AtlasEntityHeader entity, String a |
293 | 296 | for (String relatedAttribute : relatedAttributes) { |
294 | 297 | Object attrValue = entity.getAttribute(relatedAttribute); |
295 | 298 | if (attrValue != null) { |
296 | | - LOG.info("ABAC_AUTH: Attribute found in entity attr={} entityId={}", relatedAttribute, entity.getAttribute(ATTR_QUALIFIED_NAME)); |
| 299 | + LOG.info("ABAC_AUTH: Attribute found in entity attr={} qn={}", relatedAttribute, entity.getAttribute(ATTR_QUALIFIED_NAME)); |
297 | 300 | if (attrValue instanceof Collection) { |
298 | 301 | entityAttributeValues.addAll((Collection<? extends String>) attrValue); |
299 | 302 | } else { |
300 | 303 | entityAttributeValues.add(String.valueOf(attrValue)); |
301 | 304 | } |
302 | 305 | } else if (vertex != null) { |
303 | | - LOG.info("ABAC_AUTH: Attribute not found in entity, checking vertex attr={} entityId={}", relatedAttribute, entity.getAttribute(ATTR_QUALIFIED_NAME)); |
304 | 306 | // try fetching from vertex |
305 | 307 | Collection<?> values = vertex.getPropertyValues(relatedAttribute, String.class); |
306 | 308 | for (Object value : values) { |
307 | 309 | entityAttributeValues.add(String.valueOf(value)); |
308 | 310 | } |
| 311 | + if (CollectionUtils.isNotEmpty(values)) { |
| 312 | + LOG.info("ABAC_AUTH: Attribute not found in entity, checking vertex attr={} qn={} value={}", relatedAttribute, entity.getAttribute(ATTR_QUALIFIED_NAME), values); |
| 313 | + } |
309 | 314 | } |
310 | 315 | } |
311 | 316 | return entityAttributeValues; |
|
0 commit comments