Skip to content

Commit

Permalink
init commit - Added flag for one time check in authRemoveRelation if …
Browse files Browse the repository at this point in the history
…request is from WF.
  • Loading branch information
hr2904 committed Jan 14, 2025
1 parent 74531a7 commit 4605278
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,9 @@ public List<AtlasVertex> addTagPropagation(AtlasVertex classificationVertex, Lis

public void authorizeRemoveRelation(AtlasEdge edge) throws AtlasBaseException {
AtlasPerfMetrics.MetricRecorder metric = RequestContext.get().startMetricRecord("authoriseRemoveRelation");
if(isRequestFromWF()){
RequestContext.get().setAuthorisedRemoveRelation(true);
}
AtlasEntityHeader end1Entity, end2Entity;
String relationShipType = getTypeName(edge);
AtlasRelationshipDef relationshipDef = typeRegistry.getRelationshipDefByName(relationShipType);
Expand All @@ -527,6 +530,15 @@ public void authorizeRemoveRelation(AtlasEdge edge) throws AtlasBaseException {
RequestContext.get().endMetricRecord(metric);
}

private boolean isRequestFromWF() {
String workflowID = RequestContext.get().getRequestContextHeaders().getOrDefault("x-atlan-agent-workflow-id", "");
boolean ret = workflowID.isEmpty();
if(ret){
LOG.info("Authorised one time request for workflow with id : {} ", workflowID);
}
return ret;
}

public Map<AtlasVertex, List<AtlasVertex>> removeTagPropagation(AtlasEdge edge) throws AtlasBaseException {
AtlasPerfMetrics.MetricRecorder metric = RequestContext.get().startMetricRecord("removeTagPropagationEdge");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package org.apache.atlas.repository.store.graph.v1;

import org.apache.atlas.RequestContext;
import org.apache.atlas.annotation.ConditionalOnAtlasProperty;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.repository.graph.GraphHelper;
Expand Down Expand Up @@ -56,7 +57,9 @@ protected void deleteEdge(AtlasEdge edge, boolean force) throws AtlasBaseExcepti
}
boolean isRelationshipEdge = isRelationshipEdge(edge);

authorizeRemoveRelation(edge);
if(!RequestContext.get().isAuthorisedRemoveRelation()) {
authorizeRemoveRelation(edge);
}

if (DEFERRED_ACTION_ENABLED) {
createAndQueueClassificationRefreshPropagationTask(edge);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ protected void deleteEdge(AtlasEdge edge, boolean force) throws AtlasBaseExcepti
LOG.debug("==> SoftDeleteHandlerV1.deleteEdge({}, {})", GraphHelper.string(edge), force);
}
boolean isRelationshipEdge = isRelationshipEdge(edge);

authorizeRemoveRelation(edge);
if(!RequestContext.get().isAuthorisedRemoveRelation()) {
authorizeRemoveRelation(edge);
}

if (DEFERRED_ACTION_ENABLED && RequestContext.get().getCurrentTask() == null) {
if (CollectionUtils.isNotEmpty(getPropagatableClassifications(edge))) {
Expand Down
10 changes: 10 additions & 0 deletions server-api/src/main/java/org/apache/atlas/RequestContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ public class RequestContext {
private Long assetsCountPropagated = 0L;
private boolean isImportInProgress = false;
private boolean isInNotificationProcessing = false;


private boolean authorisedRemoveRelation = false;
private boolean isInTypePatching = false;
private boolean createShellEntityForNonExistingReference = false;
private boolean skipFailedEntities = false;
Expand Down Expand Up @@ -206,6 +209,13 @@ public void clearEntityCache() {
this.entityCache.clear();
}

public boolean isAuthorisedRemoveRelation() {
return authorisedRemoveRelation;
}

public void setAuthorisedRemoveRelation(boolean authorisedRemoveRelation) {
this.authorisedRemoveRelation = authorisedRemoveRelation;
}
public Set<String> getRelationAttrsForSearch() {
return relationAttrsForSearch;
}
Expand Down

0 comments on commit 4605278

Please sign in to comment.