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
8 years ago
by
saqeeb.shaikh
Committed by
Madhan Neethiraj
8 years ago
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
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
20 deletions
+20
-20
AtlasAuthorizationUtils.java
...pache/atlas/authorize/simple/AtlasAuthorizationUtils.java
+15
-18
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;
...
@@ -27,6 +27,7 @@ import org.slf4j.LoggerFactory;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.Objects
;
import
java.util.Objects
;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.regex.Pattern
;
public
class
AtlasAuthorizationUtils
{
public
class
AtlasAuthorizationUtils
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
AtlasAuthorizationUtils
.
class
);
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
AtlasAuthorizationUtils
.
class
);
...
@@ -46,18 +47,13 @@ public class AtlasAuthorizationUtils {
...
@@ -46,18 +47,13 @@ public class AtlasAuthorizationUtils {
}
}
}
}
String
[]
split
=
contextPath
.
split
(
"/"
,
3
);
String
[]
split
=
contextPath
.
split
(
"/"
,
3
);
String
api
=
split
[
0
];
String
api
=
split
[
0
];
if
(
split
.
length
>
1
)
{
if
(
Pattern
.
matches
(
"v\\d"
,
api
))
{
if
(
Objects
.
equals
(
api
,
"v1"
))
{
api
=
split
[
1
];
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
;
}
}
LOG
.
info
(
"Now returning API : "
+
api
);
return
api
;
}
}
public
static
AtlasActionTypes
getAtlasAction
(
String
method
)
{
public
static
AtlasActionTypes
getAtlasAction
(
String
method
)
{
...
@@ -100,6 +96,9 @@ public class AtlasAuthorizationUtils {
...
@@ -100,6 +96,9 @@ public class AtlasAuthorizationUtils {
* entities,lineage and discovery apis are mapped with AtlasResourceTypes.ENTITY eg :- /api/atlas/lineage/hive/table/*
* entities,lineage and discovery apis are mapped with AtlasResourceTypes.ENTITY eg :- /api/atlas/lineage/hive/table/*
* /api/atlas/entities/{guid}* /api/atlas/discovery/*
* /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.
* unprotected types are mapped with AtlasResourceTypes.UNKNOWN, access to these are allowed.
*/
*/
public
static
Set
<
AtlasResourceTypes
>
getAtlasResourceType
(
String
contextPath
)
{
public
static
Set
<
AtlasResourceTypes
>
getAtlasResourceType
(
String
contextPath
)
{
...
@@ -108,33 +107,31 @@ public class AtlasAuthorizationUtils {
...
@@ -108,33 +107,31 @@ public class AtlasAuthorizationUtils {
LOG
.
debug
(
"==> getAtlasResourceType for "
+
contextPath
);
LOG
.
debug
(
"==> getAtlasResourceType for "
+
contextPath
);
}
}
String
api
=
getApi
(
contextPath
);
String
api
=
getApi
(
contextPath
);
if
(
api
.
startsWith
(
"types"
)
||
api
.
startsWith
(
"v2/types"
)
)
{
if
(
api
.
startsWith
(
"types"
))
{
resourceTypes
.
add
(
AtlasResourceTypes
.
TYPE
);
resourceTypes
.
add
(
AtlasResourceTypes
.
TYPE
);
}
else
if
(
api
.
startsWith
(
"admin"
)
&&
(
contextPath
.
contains
(
"/session"
)
||
contextPath
.
contains
(
"/version"
)))
{
}
else
if
(
api
.
startsWith
(
"admin"
)
&&
(
contextPath
.
contains
(
"/session"
)
||
contextPath
.
contains
(
"/version"
)))
{
resourceTypes
.
add
(
AtlasResourceTypes
.
UNKNOWN
);
resourceTypes
.
add
(
AtlasResourceTypes
.
UNKNOWN
);
}
else
if
((
api
.
startsWith
(
"discovery"
)
&&
contextPath
.
contains
(
"/gremlin"
))
||
api
.
startsWith
(
"admin"
)
}
else
if
((
api
.
startsWith
(
"discovery"
)
&&
contextPath
.
contains
(
"/gremlin"
))
||
api
.
startsWith
(
"admin"
)
||
api
.
startsWith
(
"graph"
))
{
||
api
.
startsWith
(
"graph"
))
{
resourceTypes
.
add
(
AtlasResourceTypes
.
OPERATION
);
resourceTypes
.
add
(
AtlasResourceTypes
.
OPERATION
);
}
else
if
(
api
.
startsWith
(
"entities"
)
||
api
.
startsWith
(
"lineage"
)
||
}
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
);
resourceTypes
.
add
(
AtlasResourceTypes
.
ENTITY
);
}
else
if
(
api
.
startsWith
(
"
v1/
taxonomies"
))
{
}
else
if
(
api
.
startsWith
(
"taxonomies"
))
{
resourceTypes
.
add
(
AtlasResourceTypes
.
TAXONOMY
);
resourceTypes
.
add
(
AtlasResourceTypes
.
TAXONOMY
);
// taxonomies are modeled as entities
// taxonomies are modeled as entities
resourceTypes
.
add
(
AtlasResourceTypes
.
ENTITY
);
resourceTypes
.
add
(
AtlasResourceTypes
.
ENTITY
);
if
(
contextPath
.
contains
(
"/terms"
))
{
if
(
contextPath
.
contains
(
"/terms"
))
{
resourceTypes
.
add
(
AtlasResourceTypes
.
TERM
);
resourceTypes
.
add
(
AtlasResourceTypes
.
TERM
);
}
}
}
else
if
(
api
.
startsWith
(
"v1/entities"
)
||
api
.
startsWith
(
"v2/entities"
))
{
resourceTypes
.
add
(
AtlasResourceTypes
.
ENTITY
);
}
else
{
}
else
{
LOG
.
error
(
"Unable to find Atlas Resource corresponding to : "
+
api
+
"\nSetting "
LOG
.
error
(
"Unable to find Atlas Resource corresponding to : "
+
api
+
"\nSetting "
+
AtlasResourceTypes
.
UNKNOWN
.
name
());
+
AtlasResourceTypes
.
UNKNOWN
.
name
());
resourceTypes
.
add
(
AtlasResourceTypes
.
UNKNOWN
);
resourceTypes
.
add
(
AtlasResourceTypes
.
UNKNOWN
);
}
}
if
(
isDebugEnabled
)
{
if
(
isDebugEnabled
)
{
LOG
.
debug
(
"<== Returning AtlasResources "
+
resourceTypes
+
" for api "
+
api
);
LOG
.
debug
(
"<== Returning AtlasResource
/
s "
+
resourceTypes
+
" for api "
+
api
);
}
}
return
resourceTypes
;
return
resourceTypes
;
}
}
...
...
This diff is collapsed.
Click to expand it.
authorization/src/test/java/org/apache/atlas/authorize/simple/AtlasAuthorizationUtilsTest.java
View file @
3725dcf1
...
@@ -39,10 +39,10 @@ public class AtlasAuthorizationUtilsTest {
...
@@ -39,10 +39,10 @@ public class AtlasAuthorizationUtilsTest {
assertEquals
(
AtlasAuthorizationUtils
.
getApi
(
contextPath
),
"entities"
);
assertEquals
(
AtlasAuthorizationUtils
.
getApi
(
contextPath
),
"entities"
);
contextPath
=
"/api/atlas/v1/entities"
;
contextPath
=
"/api/atlas/v1/entities"
;
assertEquals
(
AtlasAuthorizationUtils
.
getApi
(
contextPath
),
"
v1/
entities"
);
assertEquals
(
AtlasAuthorizationUtils
.
getApi
(
contextPath
),
"entities"
);
contextPath
=
"/api/atlas/v1/entities/111/tags"
;
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
// not sure of this use case but the code appears to support url's that don't
// begin with base url.
// begin with base url.
...
...
This diff is collapsed.
Click to expand it.
release-log.txt
View file @
3725dcf1
...
@@ -9,6 +9,9 @@ ATLAS-1060 Add composite indexes for exact match performance improvements for al
...
@@ -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)
ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai)
ALL CHANGES:
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-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-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)
ATLAS-1395 Lineage improvement for tooltip (kevalbhatt via mneethiraj)
...
...
This diff is collapsed.
Click to expand it.
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