Skip to content

Commit

Permalink
Merge pull request #3246 from atlanhq/DG-1530_1
Browse files Browse the repository at this point in the history
Dg 1530 1
  • Loading branch information
hr2904 authored Jun 13, 2024
2 parents f1ffa21 + 0cdb224 commit 7f2eaef
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
@Component
public class ESAliasStore implements IndexAliasStore {
private static final Logger LOG = LoggerFactory.getLogger(ESAliasStore.class);
public static final String NEW_WILDCARD_DOMAIN_SUPER = "default/domain/*/super";

private final AtlasGraph graph;
private final EntityGraphRetriever entityRetriever;
Expand Down Expand Up @@ -213,7 +214,7 @@ private void personaPolicyToESDslClauses(List<AtlasEntity> policies,

for (String asset : assets) {
asset = validateAndConvertAsset(asset);
if(!asset.equals("default/domain/*/super")) {
if(!asset.equals(NEW_WILDCARD_DOMAIN_SUPER)) {
terms.add(asset);
}
allowClauseList.add(mapOf("wildcard", mapOf(QUALIFIED_NAME, asset + "*")));
Expand Down Expand Up @@ -249,7 +250,7 @@ private void personaPolicyToESDslClauses(List<AtlasEntity> policies,

private String validateAndConvertAsset(String asset) {
if(asset.equals("*/super") || asset.equals("*"))
asset = "default/domain/*/super";
asset = NEW_WILDCARD_DOMAIN_SUPER;
return asset;
}
private Map<String, Object> esClausesToFilter(List<Map<String, Object>> allowClauseList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@

public class AuthPolicyPreProcessor implements PreProcessor {
private static final Logger LOG = LoggerFactory.getLogger(AuthPolicyPreProcessor.class);
public static final String ENTITY_DEFAULT_DOMAIN_SUPER = "entity:default/domain/*/super";

private final AtlasGraph graph;
private final AtlasTypeRegistry typeRegistry;
Expand Down Expand Up @@ -206,7 +207,7 @@ private void validateAndReduce(AtlasEntity policy) {
i--;
}
}
resources.add("entity:default/domain/*/super");
resources.add(ENTITY_DEFAULT_DOMAIN_SUPER);
}

policy.setAttribute(ATTR_POLICY_RESOURCES, resources);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@
import static org.apache.atlas.repository.Constants.STAKEHOLDER_ENTITY_TYPE;
import static org.apache.atlas.repository.Constants.STAKEHOLDER_TITLE_ENTITY_TYPE;
import static org.apache.atlas.repository.store.graph.v2.preprocessor.PreProcessorUtils.indexSearchPaginated;
import static org.apache.atlas.repository.store.graph.v2.preprocessor.datamesh.StakeholderTitlePreProcessor.ATTR_DOMAIN_QUALIFIED_NAMES;
import static org.apache.atlas.repository.store.graph.v2.preprocessor.datamesh.StakeholderTitlePreProcessor.STAR;
import static org.apache.atlas.repository.store.graph.v2.preprocessor.datamesh.StakeholderTitlePreProcessor.*;
import static org.apache.atlas.repository.util.AccessControlUtils.ATTR_ACCESS_CONTROL_ENABLED;
import static org.apache.atlas.repository.util.AccessControlUtils.ATTR_PERSONA_ROLE_ID;
import static org.apache.atlas.repository.util.AccessControlUtils.REL_ATTR_POLICIES;
Expand Down Expand Up @@ -290,7 +289,7 @@ protected void ensureTitleAvailableForDomain(String domainQualifiedName, String

List<String> domainQualifiedNames = (List<String>) stakeholderTitleHeader.getAttribute(ATTR_DOMAIN_QUALIFIED_NAMES);

if (!domainQualifiedNames.contains(STAR)) {
if (!domainQualifiedNames.contains(STAR) && !domainQualifiedNames.contains(NEW_STAR)) {
Optional parentDomain = domainQualifiedNames.stream().filter(x -> domainQualifiedName.startsWith(x)).findFirst();

if (!parentDomain.isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class StakeholderTitlePreProcessor implements PreProcessor {


public static final String STAR = "*/super";
public static final String NEW_STAR = "default/domain/*/super";
public static final String ATTR_DOMAIN_QUALIFIED_NAMES = "stakeholderTitleDomainQualifiedNames";

public static final String REL_ATTR_STAKEHOLDERS = "stakeholders";
Expand Down Expand Up @@ -114,12 +115,12 @@ private void processCreateStakeholderTitle(AtlasEntity entity) throws AtlasBaseE
if (CollectionUtils.isEmpty(domainQualifiedNames)) {
throw new AtlasBaseException(BAD_REQUEST, "Please provide attribute " + ATTR_DOMAIN_QUALIFIED_NAMES);
}

if (domainQualifiedNames.contains(STAR)) {
domainQualifiedNames.replaceAll(s -> s.equals(STAR) ? NEW_STAR : s);
if (domainQualifiedNames.contains(NEW_STAR)) {
if (domainQualifiedNames.size() > 1) {

domainQualifiedNames.clear();
domainQualifiedNames.add(STAR);
domainQualifiedNames.add(NEW_STAR);
entity.setAttribute(ATTR_DOMAIN_QUALIFIED_NAMES, domainQualifiedNames);
}

Expand Down Expand Up @@ -211,8 +212,8 @@ private void authorizeDomainAccess(List<String> domainQualifiedNames) throws Atl
for (String domainQualifiedName: domainQualifiedNames) {
String domainQualifiedNameToAuth;

if (domainQualifiedNames.contains(STAR)) {
domainQualifiedNameToAuth = "*/super";
if (domainQualifiedNames.contains(STAR) || domainQualifiedNames.contains(NEW_STAR)) {
domainQualifiedNameToAuth = NEW_STAR;
} else {
domainQualifiedNameToAuth = domainQualifiedName;
}
Expand Down

0 comments on commit 7f2eaef

Please sign in to comment.