Skip to content

Commit

Permalink
Added authz to repair index endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
nixon-atlan committed Jun 27, 2023
1 parent 7f85c21 commit 91f1a08
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 8 deletions.
25 changes: 25 additions & 0 deletions addons/policies/bootstrap_entity_policies.json
Original file line number Diff line number Diff line change
Expand Up @@ -2860,6 +2860,31 @@
"entity-update"
]
}
},
{
"typeName": "AuthPolicy",
"attributes": {
"name": "RUN_REPAIR_INDEX",
"qualifiedName": "RUN_REPAIR_INDEX",
"policyCategory": "bootstrap",
"policySubCategory": "default",
"policyServiceName": "atlas",
"policyType": "allow",
"policyPriority": 1,
"policyUsers": [
"service-account-atlan-argo",
"service-account-atlan-backend"
],
"policyGroups": [],
"policyRoles": [],
"policyResourceCategory": "ADMIN",
"policyResources": [
"atlas-service:*"
],
"policyActions": [
"admin-repair-index"
]
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
},
"label": "Atlas Service",
"description": "Atlas Service",
"accessTypeRestrictions": ["admin-import", "admin-export", "admin-purge", "admin-audits", "admin-entity-audits"]
"accessTypeRestrictions": ["admin-import", "admin-export", "admin-purge", "admin-audits", "admin-entity-audits", "admin-repair-index"]
},
{
"itemId": 7,
Expand Down Expand Up @@ -440,7 +440,13 @@
"itemId": 22,
"name": "admin-entity-audits",
"label": "Admin Entity Audits"
},
{
"itemId": 23,
"name": "admin-repair-index",
"label": "Admin Repair Index"
}

],
"configs": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public enum AtlasPrivilege {

ADMIN_AUDITS("admin-audits"),

ADMIN_ENTITY_AUDITS("admin-entity-audits");
ADMIN_ENTITY_AUDITS("admin-entity-audits"),
ADMIN_REPAIR_INDEX("admin-repair-index");

private final String type;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,11 @@ public void restoreSelective(String guid, Map<String, AtlasEntity> referredEntit
IndexSerializer indexSerializer = janusGraph.getIndexSerializer();

for (String indexName : getIndexes()) {
displayCrlf("Restoring: " + indexName);
LOG.info("Restoring: " + indexName);
long startTime = System.currentTimeMillis();
reindexVertex(indexName, indexSerializer, referencedGUIDs);

display(": Time taken: " + (System.currentTimeMillis() - startTime) + " ms");
displayCrlf(": Done!");
LOG.info(": Time taken: " + (System.currentTimeMillis() - startTime) + " ms");
}
}

Expand All @@ -281,12 +280,12 @@ public void restoreByIds(Set<String> guids) throws Exception {
IndexSerializer indexSerializer = janusGraph.getIndexSerializer();

for (String indexName : getIndexes()) {
// displayCrlf("Restoring: " + indexName);
LOG.info("Restoring: " + indexName);
long startTime = System.currentTimeMillis();
reindexVertex(indexName, indexSerializer, guids);

// display(": Time taken: " + (System.currentTimeMillis() - startTime) + " ms");
// displayCrlf(": Done!");
LOG.info(": Time taken: " + (System.currentTimeMillis() - startTime) + " ms");
LOG.info(": Done!");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1805,6 +1805,8 @@ private void validateEntityForAccessors(String guid, String qualifiedName, Strin
public void repairEntityIndex(@PathParam("guid") String guid) throws AtlasBaseException {
Servlets.validateQueryParamLength("guid", guid);

AtlasAuthorizationUtils.verifyAccess(new AtlasAdminAccessRequest(AtlasPrivilege.ADMIN_REPAIR_INDEX), "Admin Repair Index");

AtlasPerfTracer perf = null;

try {
Expand Down Expand Up @@ -1839,6 +1841,8 @@ public void repairIndexByTypeName(@PathParam("typename") String typename, @Query
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.repairAllEntitiesIndex");
}

AtlasAuthorizationUtils.verifyAccess(new AtlasAdminAccessRequest(AtlasPrivilege.ADMIN_REPAIR_INDEX), "Admin Repair Index");

RepairIndex repairIndex = new RepairIndex();
repairIndex.setupGraph();

Expand Down

0 comments on commit 91f1a08

Please sign in to comment.