atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject incubator-atlas git commit: ATLAS-1350: update authorization to handle v2 REST endpoints
Date Wed, 21 Dec 2016 20:04:05 GMT
Repository: incubator-atlas
Updated Branches:
  refs/heads/master ec1b160ac -> 3725dcf11


ATLAS-1350: update authorization to handle v2 REST endpoints

Signed-off-by: Madhan Neethiraj <madhan@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/3725dcf1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/3725dcf1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/3725dcf1

Branch: refs/heads/master
Commit: 3725dcf113056c47184e4a5ba95aeb7d57e61de0
Parents: ec1b160
Author: saqeeb.shaikh <saqeeb.shaikh@freestoneinfotech.com>
Authored: Wed Dec 21 16:45:28 2016 +0530
Committer: Madhan Neethiraj <madhan@apache.org>
Committed: Wed Dec 21 12:03:56 2016 -0800

----------------------------------------------------------------------
 .../simple/AtlasAuthorizationUtils.java         | 33 +++++++++-----------
 .../simple/AtlasAuthorizationUtilsTest.java     |  4 +--
 release-log.txt                                 |  3 ++
 3 files changed, 20 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3725dcf1/authorization/src/main/java/org/apache/atlas/authorize/simple/AtlasAuthorizationUtils.java
----------------------------------------------------------------------
diff --git a/authorization/src/main/java/org/apache/atlas/authorize/simple/AtlasAuthorizationUtils.java
b/authorization/src/main/java/org/apache/atlas/authorize/simple/AtlasAuthorizationUtils.java
index 2ef4ea2..ebfb964 100644
--- a/authorization/src/main/java/org/apache/atlas/authorize/simple/AtlasAuthorizationUtils.java
+++ b/authorization/src/main/java/org/apache/atlas/authorize/simple/AtlasAuthorizationUtils.java
@@ -27,6 +27,7 @@ import org.slf4j.LoggerFactory;
 import java.util.HashSet;
 import java.util.Objects;
 import java.util.Set;
+import java.util.regex.Pattern;
 
 public class AtlasAuthorizationUtils {
     private static final Logger LOG = LoggerFactory.getLogger(AtlasAuthorizationUtils.class);
@@ -46,18 +47,13 @@ public class AtlasAuthorizationUtils {
             }
         }
         String[] split = contextPath.split("/", 3);
+
         String api = split[0];
-        if (split.length > 1) {
-            if (Objects.equals(api, "v1")) {
-                return String.format("v1/%s", split[1]);
-            } else if (Objects.equals(api, "v2")) {
-                return String.format("v2/%s", split[1]);
-            } else {
-                return api;
-            }
-        } else {
-            return api;
+        if(Pattern.matches("v\\d", api)) {
+            api = split[1];
         }
+        LOG.info("Now returning API : "+api);
+        return api;
     }
 
     public static AtlasActionTypes getAtlasAction(String method) {
@@ -100,6 +96,9 @@ public class AtlasAuthorizationUtils {
      *         entities,lineage and discovery apis are mapped with AtlasResourceTypes.ENTITY
eg :- /api/atlas/lineage/hive/table/*
      *         /api/atlas/entities/{guid}* /api/atlas/discovery/*
      * 
+     *         taxonomy API are also mapped to AtlasResourceTypes.TAXONOMY & AtlasResourceTypes.ENTITY
and its terms APIs have 
+     *         added AtlasResourceTypes.TERM associations.
+     *         
      *         unprotected types are mapped with AtlasResourceTypes.UNKNOWN, access to these
are allowed.
      */
     public static Set<AtlasResourceTypes> getAtlasResourceType(String contextPath)
{
@@ -108,33 +107,31 @@ public class AtlasAuthorizationUtils {
             LOG.debug("==> getAtlasResourceType  for " + contextPath);
         }
         String api = getApi(contextPath);
-        if (api.startsWith("types") || api.startsWith("v2/types")) {
+        if (api.startsWith("types")) {
             resourceTypes.add(AtlasResourceTypes.TYPE);
         } else if (api.startsWith("admin") && (contextPath.contains("/session") ||
contextPath.contains("/version"))) {
             resourceTypes.add(AtlasResourceTypes.UNKNOWN);
         } else if ((api.startsWith("discovery") && contextPath.contains("/gremlin"))
|| api.startsWith("admin")
-            || api.startsWith("graph")) {
+                || api.startsWith("graph")) {
             resourceTypes.add(AtlasResourceTypes.OPERATION);
         } else if (api.startsWith("entities") || api.startsWith("lineage") ||
-                api.startsWith("discovery") || api.startsWith("v2/entity")) {
+                api.startsWith("discovery") || api.startsWith("entity")) {
             resourceTypes.add(AtlasResourceTypes.ENTITY);
-        } else if (api.startsWith("v1/taxonomies")) {
+        } else if (api.startsWith("taxonomies")) {
             resourceTypes.add(AtlasResourceTypes.TAXONOMY);
             // taxonomies are modeled as entities
             resourceTypes.add(AtlasResourceTypes.ENTITY);
             if (contextPath.contains("/terms")) {
                 resourceTypes.add(AtlasResourceTypes.TERM);
             }
-        } else if (api.startsWith("v1/entities") || api.startsWith("v2/entities")) {
-            resourceTypes.add(AtlasResourceTypes.ENTITY);
         } else {
             LOG.error("Unable to find Atlas Resource corresponding to : " + api + "\nSetting
"
-                + AtlasResourceTypes.UNKNOWN.name());
+                    + AtlasResourceTypes.UNKNOWN.name());
             resourceTypes.add(AtlasResourceTypes.UNKNOWN);
         }
 
         if (isDebugEnabled) {
-            LOG.debug("<== Returning AtlasResources " + resourceTypes + " for api " +
api);
+            LOG.debug("<== Returning AtlasResource/s " + resourceTypes + " for api " +
api);
         }
         return resourceTypes;
     }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3725dcf1/authorization/src/test/java/org/apache/atlas/authorize/simple/AtlasAuthorizationUtilsTest.java
----------------------------------------------------------------------
diff --git a/authorization/src/test/java/org/apache/atlas/authorize/simple/AtlasAuthorizationUtilsTest.java
b/authorization/src/test/java/org/apache/atlas/authorize/simple/AtlasAuthorizationUtilsTest.java
index 326cb3c..b76a297 100644
--- a/authorization/src/test/java/org/apache/atlas/authorize/simple/AtlasAuthorizationUtilsTest.java
+++ b/authorization/src/test/java/org/apache/atlas/authorize/simple/AtlasAuthorizationUtilsTest.java
@@ -39,10 +39,10 @@ public class AtlasAuthorizationUtilsTest {
         assertEquals(AtlasAuthorizationUtils.getApi(contextPath), "entities");
 
         contextPath = "/api/atlas/v1/entities";
-        assertEquals(AtlasAuthorizationUtils.getApi(contextPath), "v1/entities");
+        assertEquals(AtlasAuthorizationUtils.getApi(contextPath), "entities");
 
         contextPath = "/api/atlas/v1/entities/111/tags";
-        assertEquals(AtlasAuthorizationUtils.getApi(contextPath), "v1/entities");
+        assertEquals(AtlasAuthorizationUtils.getApi(contextPath), "entities");
 
         // not sure of this use case but the code appears to support url's that don't
         // begin with base url.

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3725dcf1/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index 3de0ce6..6e52963 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -9,6 +9,9 @@ ATLAS-1060 Add composite indexes for exact match performance improvements
for al
 ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai)
 
 ALL CHANGES:
+ATLAS-1350 update authorization to handle v2 REST endpoints (saqeeb.s via mneethiraj)
+ATLAS-1311 Integration tests for V2 Entity APIs (apoorvnaik via mneethiraj)
+ATLAS-1377 fix for Escaping comma in for LDAP properties (nixonrodrigues via mneethiraj)
 ATLAS-1367 fix to use correct version of curator-client library (mneethiraj)
 ATLAS-1371 create/edit tag dialog to allow choosing of data-type for attributes (Kalyanikashikar
via mneethiraj)
 ATLAS-1395 Lineage improvement for tooltip (kevalbhatt via mneethiraj)


Mime
View raw message