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
31eb3664
Commit
31eb3664
authored
Mar 19, 2018
by
nixonrodrigues
Committed by
Madhan Neethiraj
Mar 25, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2505: add client IP address in authorization requests
Signed-off-by:
Madhan Neethiraj
<
madhan@apache.org
>
parent
729d9238
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
5 deletions
+20
-5
pom.xml
authorization/pom.xml
+5
-0
AtlasAuthorizationUtils.java
...a/org/apache/atlas/authorize/AtlasAuthorizationUtils.java
+4
-4
RequestContextV1.java
...-api/src/main/java/org/apache/atlas/RequestContextV1.java
+10
-0
AuditFilter.java
...c/main/java/org/apache/atlas/web/filters/AuditFilter.java
+1
-1
No files found.
authorization/pom.xml
View file @
31eb3664
...
@@ -41,6 +41,11 @@
...
@@ -41,6 +41,11 @@
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
org.apache.atlas
</groupId>
<artifactId>
atlas-server-api
</artifactId>
</dependency>
<dependency>
<groupId>
javax.servlet
</groupId>
<groupId>
javax.servlet
</groupId>
<artifactId>
javax.servlet-api
</artifactId>
<artifactId>
javax.servlet-api
</artifactId>
<version>
${javax.servlet.version}
</version>
<version>
${javax.servlet.version}
</version>
...
...
authorization/src/main/java/org/apache/atlas/authorize/AtlasAuthorizationUtils.java
View file @
31eb3664
...
@@ -33,7 +33,7 @@ import java.net.InetAddress;
...
@@ -33,7 +33,7 @@ import java.net.InetAddress;
import
java.net.UnknownHostException
;
import
java.net.UnknownHostException
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.Set
;
import
java.util.Set
;
import
org.apache.atlas.RequestContextV1
;
public
class
AtlasAuthorizationUtils
{
public
class
AtlasAuthorizationUtils
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
AtlasAuthorizationUtils
.
class
);
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
AtlasAuthorizationUtils
.
class
);
...
@@ -71,7 +71,7 @@ public class AtlasAuthorizationUtils {
...
@@ -71,7 +71,7 @@ public class AtlasAuthorizationUtils {
AtlasAuthorizer
authorizer
=
AtlasAuthorizerFactory
.
getAtlasAuthorizer
();
AtlasAuthorizer
authorizer
=
AtlasAuthorizerFactory
.
getAtlasAuthorizer
();
request
.
setUser
(
userName
,
getCurrentUserGroups
());
request
.
setUser
(
userName
,
getCurrentUserGroups
());
request
.
setClientIPAddress
(
RequestContextV1
.
get
().
getClientIPAddress
());
ret
=
authorizer
.
isAccessAllowed
(
request
);
ret
=
authorizer
.
isAccessAllowed
(
request
);
}
catch
(
AtlasAuthorizationException
e
)
{
}
catch
(
AtlasAuthorizationException
e
)
{
LOG
.
error
(
"Unable to obtain AtlasAuthorizer"
,
e
);
LOG
.
error
(
"Unable to obtain AtlasAuthorizer"
,
e
);
...
@@ -92,7 +92,7 @@ public class AtlasAuthorizationUtils {
...
@@ -92,7 +92,7 @@ public class AtlasAuthorizationUtils {
AtlasAuthorizer
authorizer
=
AtlasAuthorizerFactory
.
getAtlasAuthorizer
();
AtlasAuthorizer
authorizer
=
AtlasAuthorizerFactory
.
getAtlasAuthorizer
();
request
.
setUser
(
getCurrentUserName
(),
getCurrentUserGroups
());
request
.
setUser
(
getCurrentUserName
(),
getCurrentUserGroups
());
request
.
setClientIPAddress
(
RequestContextV1
.
get
().
getClientIPAddress
());
ret
=
authorizer
.
isAccessAllowed
(
request
);
ret
=
authorizer
.
isAccessAllowed
(
request
);
}
catch
(
AtlasAuthorizationException
e
)
{
}
catch
(
AtlasAuthorizationException
e
)
{
LOG
.
error
(
"Unable to obtain AtlasAuthorizer"
,
e
);
LOG
.
error
(
"Unable to obtain AtlasAuthorizer"
,
e
);
...
@@ -113,7 +113,7 @@ public class AtlasAuthorizationUtils {
...
@@ -113,7 +113,7 @@ public class AtlasAuthorizationUtils {
AtlasAuthorizer
authorizer
=
AtlasAuthorizerFactory
.
getAtlasAuthorizer
();
AtlasAuthorizer
authorizer
=
AtlasAuthorizerFactory
.
getAtlasAuthorizer
();
request
.
setUser
(
getCurrentUserName
(),
getCurrentUserGroups
());
request
.
setUser
(
getCurrentUserName
(),
getCurrentUserGroups
());
request
.
setClientIPAddress
(
RequestContextV1
.
get
().
getClientIPAddress
());
ret
=
authorizer
.
isAccessAllowed
(
request
);
ret
=
authorizer
.
isAccessAllowed
(
request
);
}
catch
(
AtlasAuthorizationException
e
)
{
}
catch
(
AtlasAuthorizationException
e
)
{
LOG
.
error
(
"Unable to obtain AtlasAuthorizer"
,
e
);
LOG
.
error
(
"Unable to obtain AtlasAuthorizer"
,
e
);
...
...
server-api/src/main/java/org/apache/atlas/RequestContextV1.java
View file @
31eb3664
...
@@ -37,6 +37,8 @@ public class RequestContextV1 {
...
@@ -37,6 +37,8 @@ public class RequestContextV1 {
private
String
user
;
private
String
user
;
private
Set
<
String
>
userGroups
;
private
Set
<
String
>
userGroups
;
private
String
clientIPAddress
;
private
RequestContextV1
()
{
private
RequestContextV1
()
{
}
}
...
@@ -79,6 +81,14 @@ public class RequestContextV1 {
...
@@ -79,6 +81,14 @@ public class RequestContextV1 {
this
.
userGroups
=
userGroups
;
this
.
userGroups
=
userGroups
;
}
}
public
String
getClientIPAddress
()
{
return
clientIPAddress
;
}
public
void
setClientIPAddress
(
String
clientIPAddress
)
{
this
.
clientIPAddress
=
clientIPAddress
;
}
public
void
recordEntityUpdate
(
AtlasObjectId
entity
)
{
public
void
recordEntityUpdate
(
AtlasObjectId
entity
)
{
if
(
entity
!=
null
&&
entity
.
getGuid
()
!=
null
)
{
if
(
entity
!=
null
&&
entity
.
getGuid
()
!=
null
)
{
updatedEntities
.
put
(
entity
.
getGuid
(),
entity
);
updatedEntities
.
put
(
entity
.
getGuid
(),
entity
);
...
...
webapp/src/main/java/org/apache/atlas/web/filters/AuditFilter.java
View file @
31eb3664
...
@@ -76,7 +76,7 @@ public class AuditFilter implements Filter {
...
@@ -76,7 +76,7 @@ public class AuditFilter implements Filter {
RequestContextV1
.
clear
();
RequestContextV1
.
clear
();
RequestContextV1
requestContext
=
RequestContextV1
.
get
();
RequestContextV1
requestContext
=
RequestContextV1
.
get
();
requestContext
.
setUser
(
user
,
userGroups
);
requestContext
.
setUser
(
user
,
userGroups
);
requestContext
.
setClientIPAddress
(
AtlasAuthorizationUtils
.
getRequestIpAddress
(
httpRequest
));
filterChain
.
doFilter
(
request
,
response
);
filterChain
.
doFilter
(
request
,
response
);
}
finally
{
}
finally
{
long
timeTaken
=
System
.
currentTimeMillis
()
-
startTime
;
long
timeTaken
=
System
.
currentTimeMillis
()
-
startTime
;
...
...
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