21
21
import org .apache .atlas .AtlasErrorCode ;
22
22
import org .apache .atlas .RequestContext ;
23
23
import org .apache .atlas .authorize .AtlasAuthorizationUtils ;
24
+ import org .apache .atlas .authorize .AtlasEntityAccessRequest ;
25
+ import org .apache .atlas .authorize .AtlasPrivilege ;
24
26
import org .apache .atlas .exception .AtlasBaseException ;
25
27
import org .apache .atlas .featureflag .FeatureFlagStore ;
26
28
import org .apache .atlas .model .instance .AtlasEntity ;
27
29
import org .apache .atlas .model .instance .AtlasEntity .AtlasEntityWithExtInfo ;
30
+ import org .apache .atlas .model .instance .AtlasEntityHeader ;
28
31
import org .apache .atlas .model .instance .AtlasObjectId ;
29
32
import org .apache .atlas .model .instance .AtlasStruct ;
30
33
import org .apache .atlas .model .instance .EntityMutations .EntityOperation ;
52
55
import static org .apache .atlas .AtlasErrorCode .RESOURCE_NOT_FOUND ;
53
56
import static org .apache .atlas .AtlasErrorCode .UNAUTHORIZED_CONNECTION_ADMIN ;
54
57
import static org .apache .atlas .authorize .AtlasAuthorizationUtils .getCurrentUserName ;
58
+ import static org .apache .atlas .authorize .AtlasAuthorizationUtils .verifyAccess ;
55
59
import static org .apache .atlas .model .instance .EntityMutations .EntityOperation .CREATE ;
56
60
import static org .apache .atlas .model .instance .EntityMutations .EntityOperation .UPDATE ;
57
61
import static org .apache .atlas .repository .Constants .ATTR_ADMIN_ROLES ;
@@ -223,6 +227,8 @@ public void processDelete(AtlasVertex vertex) throws AtlasBaseException {
223
227
try {
224
228
AtlasEntity policy = entityRetriever .toAtlasEntity (vertex );
225
229
230
+ authorizeDeleteAuthPolicy (policy );
231
+
226
232
if (!policy .getStatus ().equals (AtlasEntity .Status .ACTIVE )) {
227
233
LOG .info ("Policy with guid {} is already deleted/purged" , policy .getGuid ());
228
234
return ;
@@ -238,6 +244,16 @@ public void processDelete(AtlasVertex vertex) throws AtlasBaseException {
238
244
}
239
245
}
240
246
247
+ private void authorizeDeleteAuthPolicy (AtlasEntity policy ) throws AtlasBaseException {
248
+ if (getPolicyCategory (policy ).equals (POLICY_CATEGORY_BOOTSTRAP ) && getPolicySubCategory (policy ).equals (POLICY_SUB_CATEGORY_COLLECTION )) {
249
+ //skip auth check for collection bootstrap policies
250
+ //refer - https://linear.app/atlanproduct/issue/GOV-1245/collection-delete-is-failing-for-member-as-they-dont-have-authpolicy
251
+ } else {
252
+ AtlasEntityAccessRequest request = new AtlasEntityAccessRequest (typeRegistry , AtlasPrivilege .ENTITY_DELETE , new AtlasEntityHeader (policy ));
253
+ verifyAccess (request , "delete entity: guid=" + policy .getGuid ());
254
+ }
255
+ }
256
+
241
257
private void validateConnectionAdmin (AtlasEntity policy ) throws AtlasBaseException {
242
258
String subCategory = getPolicySubCategory (policy );
243
259
if (POLICY_SUB_CATEGORY_METADATA .equals (subCategory ) || POLICY_SUB_CATEGORY_DATA .equals (subCategory )) {
0 commit comments