You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ni...@apache.org on 2021/05/10 04:20:23 UTC

[atlas] branch branch-2.0 updated: ATLAS-4271 : When unauthorised user is tries to create a relationship, message thrown is incorrect.

This is an automated email from the ASF dual-hosted git repository.

nixon pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/atlas.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 13b8d38  ATLAS-4271 : When unauthorised user is tries to create a relationship, message thrown is incorrect.
13b8d38 is described below

commit 13b8d38997c5d0e9d0963cba34f91556d30df56c
Author: Jayendra Parab <ja...@freestoneinfotech.com>
AuthorDate: Fri Apr 30 22:48:29 2021 +0530

    ATLAS-4271 : When unauthorised user is tries to create a relationship, message thrown is incorrect.
    
    Signed-off-by: nixonrodrigues <ni...@apache.org>
    (cherry picked from commit 0384f4c0f428200bdd8cb46a7ae418b7acd6afdc)
---
 .../store/graph/v2/AtlasRelationshipDefStoreV2.java        | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipDefStoreV2.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipDefStoreV2.java
index b1f8efd..7bc4b28 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipDefStoreV2.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipDefStoreV2.java
@@ -71,6 +71,8 @@ public class AtlasRelationshipDefStoreV2 extends AtlasAbstractDefStoreV2<AtlasRe
             throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, relationshipDef.getName(), TypeCategory.RELATIONSHIP.name());
         }
 
+        verifyTypeReadAccess(relationshipDef);
+
         AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_CREATE, relationshipDef), "create relationship-def ", relationshipDef.getName());
 
         AtlasVertex relationshipDefVertex = typeDefStore.findTypeVertexByName(relationshipDef.getName());
@@ -135,10 +137,6 @@ public class AtlasRelationshipDefStoreV2 extends AtlasAbstractDefStoreV2<AtlasRe
             LOG.debug("==> AtlasRelationshipDefStoreV1.create({}, {})", relationshipDef, preCreateResult);
         }
 
-        verifyTypeReadAccess(relationshipDef.getEndDef1().getType());
-        verifyTypeReadAccess(relationshipDef.getEndDef2().getType());
-
-
         AtlasVertex vertex = (preCreateResult == null) ? preCreate(relationshipDef) : preCreateResult;
 
         AtlasRelationshipDef ret = toRelationshipDef(vertex);
@@ -220,8 +218,7 @@ public class AtlasRelationshipDefStoreV2 extends AtlasAbstractDefStoreV2<AtlasRe
             LOG.debug("==> AtlasRelationshipDefStoreV1.update({})", relationshipDef);
         }
 
-        verifyTypeReadAccess(relationshipDef.getEndDef1().getType());
-        verifyTypeReadAccess(relationshipDef.getEndDef2().getType());
+        verifyTypeReadAccess(relationshipDef);
 
         validateType(relationshipDef);
 
@@ -542,4 +539,9 @@ public class AtlasRelationshipDefStoreV2 extends AtlasAbstractDefStoreV2<AtlasRe
                 Objects.equals(currentDef.getCardinality(), updatedDef.getCardinality());
     }
 
+    private void verifyTypeReadAccess(AtlasRelationshipDef relationshipDef) throws AtlasBaseException {
+        verifyTypeReadAccess(relationshipDef.getEndDef1().getType());
+        verifyTypeReadAccess(relationshipDef.getEndDef2().getType());
+    }
+
 }