Skip to content

Commit 8b224ac

Browse files
authored
Merge pull request #5497 from atlanhq/ns/fix/itau
PLTS-574 Avoid fetching vertex for abac evaluation
2 parents 82a8604 + ed53fa7 commit 8b224ac

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

repository/src/main/java/org/apache/atlas/authorizer/authorizers/EntityAuthorizer.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.apache.atlas.repository.graphdb.AtlasVertex;
1212
import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2;
1313
import org.apache.atlas.utils.AtlasPerfMetrics;
14+
import org.apache.commons.collections.CollectionUtils;
1415
import org.apache.commons.lang.StringUtils;
1516
import org.slf4j.Logger;
1617
import org.slf4j.LoggerFactory;
@@ -78,7 +79,9 @@ private static AtlasAccessResult isAccessAllowedInMemory(AtlasEntityHeader entit
7879
private static AtlasAccessResult evaluateABACPoliciesInMemory(List<RangerPolicy> abacPolicies, AtlasEntityHeader entity) {
7980
AtlasAccessResult result = new AtlasAccessResult(false);
8081

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());
8285

8386
for (RangerPolicy policy : abacPolicies) {
8487
boolean matched = false;
@@ -293,19 +296,21 @@ private static List<String> getAttributeValue(AtlasEntityHeader entity, String a
293296
for (String relatedAttribute : relatedAttributes) {
294297
Object attrValue = entity.getAttribute(relatedAttribute);
295298
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));
297300
if (attrValue instanceof Collection) {
298301
entityAttributeValues.addAll((Collection<? extends String>) attrValue);
299302
} else {
300303
entityAttributeValues.add(String.valueOf(attrValue));
301304
}
302305
} else if (vertex != null) {
303-
LOG.info("ABAC_AUTH: Attribute not found in entity, checking vertex attr={} entityId={}", relatedAttribute, entity.getAttribute(ATTR_QUALIFIED_NAME));
304306
// try fetching from vertex
305307
Collection<?> values = vertex.getPropertyValues(relatedAttribute, String.class);
306308
for (Object value : values) {
307309
entityAttributeValues.add(String.valueOf(value));
308310
}
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+
}
309314
}
310315
}
311316
return entityAttributeValues;

0 commit comments

Comments
 (0)