Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dataplatform
atlas
Commits
3725dcf1
Commit
3725dcf1
authored
Dec 21, 2016
by
saqeeb.shaikh
Committed by
Madhan Neethiraj
Dec 21, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1350: update authorization to handle v2 REST endpoints
Signed-off-by:
Madhan Neethiraj
<
madhan@apache.org
>
parent
ec1b160a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
17 deletions
+17
-17
AtlasAuthorizationUtils.java
...pache/atlas/authorize/simple/AtlasAuthorizationUtils.java
+12
-15
AtlasAuthorizationUtilsTest.java
...e/atlas/authorize/simple/AtlasAuthorizationUtilsTest.java
+2
-2
release-log.txt
release-log.txt
+3
-0
No files found.
authorization/src/main/java/org/apache/atlas/authorize/simple/AtlasAuthorizationUtils.java
View file @
3725dcf1
...
...
@@ -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,19 +47,14 @@ 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
;
if
(
Pattern
.
matches
(
"v\\d"
,
api
))
{
api
=
split
[
1
];
}
}
else
{
LOG
.
info
(
"Now returning API : "
+
api
);
return
api
;
}
}
public
static
AtlasActionTypes
getAtlasAction
(
String
method
)
{
AtlasActionTypes
action
=
null
;
...
...
@@ -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,7 +107,7 @@ 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
);
...
...
@@ -116,17 +115,15 @@ public class AtlasAuthorizationUtils {
||
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
());
...
...
@@ -134,7 +131,7 @@ public class AtlasAuthorizationUtils {
}
if
(
isDebugEnabled
)
{
LOG
.
debug
(
"<== Returning AtlasResources "
+
resourceTypes
+
" for api "
+
api
);
LOG
.
debug
(
"<== Returning AtlasResource
/
s "
+
resourceTypes
+
" for api "
+
api
);
}
return
resourceTypes
;
}
...
...
authorization/src/test/java/org/apache/atlas/authorize/simple/AtlasAuthorizationUtilsTest.java
View file @
3725dcf1
...
...
@@ -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.
...
...
release-log.txt
View file @
3725dcf1
...
...
@@ -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)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment