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
adfdef02
Commit
adfdef02
authored
Oct 04, 2016
by
Suma Shivaprasad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1206 Atlas UI not working with IE or Chrome on Windows OS in Kerberos mode…
ATLAS-1206 Atlas UI not working with IE or Chrome on Windows OS in Kerberos mode (nixonrodrigues via sumasai)
parent
630a562b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
22 deletions
+65
-22
release-log.txt
release-log.txt
+1
-0
AtlasAuthenticationFilter.java
...g/apache/atlas/web/filters/AtlasAuthenticationFilter.java
+64
-22
No files found.
release-log.txt
View file @
adfdef02
...
@@ -9,6 +9,7 @@ ATLAS-1060 Add composite indexes for exact match performance improvements for al
...
@@ -9,6 +9,7 @@ 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-1206 Atlas UI not working with IE or Chrome on Windows OS in Kerberos mode (nixonrodrigues via sumasai)
ATLAS-1205 Improve atlas build time (shwethags)
ATLAS-1205 Improve atlas build time (shwethags)
ATLAS-1203 'Invalid type definition' due to no new types to be created at startup (mneethiraj via shwethags)
ATLAS-1203 'Invalid type definition' due to no new types to be created at startup (mneethiraj via shwethags)
ATLAS-1171 Structured, high-level public APIs (mneethiraj via shwethags)
ATLAS-1171 Structured, high-level public APIs (mneethiraj via shwethags)
...
...
webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthenticationFilter.java
View file @
adfdef02
...
@@ -69,6 +69,8 @@ import java.net.UnknownHostException;
...
@@ -69,6 +69,8 @@ import java.net.UnknownHostException;
import
java.security.Principal
;
import
java.security.Principal
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.*
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
javax.servlet.http.Cookie
;
import
javax.servlet.http.Cookie
;
/**
/**
...
@@ -84,6 +86,7 @@ public class AtlasAuthenticationFilter extends AuthenticationFilter {
...
@@ -84,6 +86,7 @@ public class AtlasAuthenticationFilter extends AuthenticationFilter {
private
SignerSecretProvider
secretProvider
;
private
SignerSecretProvider
secretProvider
;
public
final
boolean
isKerberos
=
AuthenticationUtil
.
isKerberosAuthenticationEnabled
();
public
final
boolean
isKerberos
=
AuthenticationUtil
.
isKerberosAuthenticationEnabled
();
private
boolean
isInitializedByTomcat
;
private
boolean
isInitializedByTomcat
;
private
Set
<
Pattern
>
browserUserAgents
;
public
AtlasAuthenticationFilter
()
{
public
AtlasAuthenticationFilter
()
{
try
{
try
{
...
@@ -148,7 +151,7 @@ public class AtlasAuthenticationFilter extends AuthenticationFilter {
...
@@ -148,7 +151,7 @@ public class AtlasAuthenticationFilter extends AuthenticationFilter {
@Override
@Override
public
void
initializeSecretProvider
(
FilterConfig
filterConfig
)
public
void
initializeSecretProvider
(
FilterConfig
filterConfig
)
throws
ServletException
{
throws
ServletException
{
LOG
.
debug
(
"AtlasAuthenticationFilter :: initializeSecretProvider "
+
filterConfig
);
LOG
.
debug
(
"AtlasAuthenticationFilter :: initializeSecretProvider "
+
filterConfig
);
secretProvider
=
(
SignerSecretProvider
)
filterConfig
.
getServletContext
().
secretProvider
=
(
SignerSecretProvider
)
filterConfig
.
getServletContext
().
getAttribute
(
AuthenticationFilter
.
SIGNER_SECRET_PROVIDER_ATTRIBUTE
);
getAttribute
(
AuthenticationFilter
.
SIGNER_SECRET_PROVIDER_ATTRIBUTE
);
if
(
secretProvider
==
null
)
{
if
(
secretProvider
==
null
)
{
...
@@ -230,6 +233,14 @@ public class AtlasAuthenticationFilter extends AuthenticationFilter {
...
@@ -230,6 +233,14 @@ public class AtlasAuthenticationFilter extends AuthenticationFilter {
LOG
.
debug
(
" AuthenticationFilterConfig: {}"
,
config
);
LOG
.
debug
(
" AuthenticationFilterConfig: {}"
,
config
);
String
agents
=
configuration
.
getString
(
AtlasCSRFPreventionFilter
.
BROWSER_USER_AGENT_PARAM
,
AtlasCSRFPreventionFilter
.
BROWSER_USER_AGENTS_DEFAULT
);
if
(
agents
==
null
)
{
agents
=
AtlasCSRFPreventionFilter
.
BROWSER_USER_AGENTS_DEFAULT
;
}
parseBrowserUserAgents
(
agents
);
return
config
;
return
config
;
}
}
...
@@ -296,11 +307,16 @@ public class AtlasAuthenticationFilter extends AuthenticationFilter {
...
@@ -296,11 +307,16 @@ public class AtlasAuthenticationFilter extends AuthenticationFilter {
try
{
try
{
String
authHeader
=
httpRequest
.
getHeader
(
"Authorization"
);
Authentication
existingAuth
=
SecurityContextHolder
.
getContext
().
getAuthentication
();
if
(
authHeader
!=
null
&&
authHeader
.
startsWith
(
"Basic"
))
{
if
(
existingAuth
==
null
)
{
filterChain
.
doFilter
(
request
,
response
);
String
authHeader
=
httpRequest
.
getHeader
(
"Authorization"
);
}
else
if
(
isKerberos
)
{
if
(
authHeader
!=
null
&&
authHeader
.
startsWith
(
"Basic"
))
{
doKerberosAuth
(
request
,
response
,
filterChainWrapper
);
filterChain
.
doFilter
(
request
,
response
);
}
else
if
(
isKerberos
)
{
doKerberosAuth
(
request
,
response
,
filterChainWrapper
,
filterChain
);
}
else
{
filterChain
.
doFilter
(
request
,
response
);
}
}
else
{
}
else
{
filterChain
.
doFilter
(
request
,
response
);
filterChain
.
doFilter
(
request
,
response
);
}
}
...
@@ -327,7 +343,7 @@ public class AtlasAuthenticationFilter extends AuthenticationFilter {
...
@@ -327,7 +343,7 @@ public class AtlasAuthenticationFilter extends AuthenticationFilter {
* @throws IOException thrown if an IO error occurred.
* @throws IOException thrown if an IO error occurred.
* @throws ServletException thrown if a processing error occurred.
* @throws ServletException thrown if a processing error occurred.
*/
*/
public
void
doKerberosAuth
(
ServletRequest
request
,
ServletResponse
response
,
FilterChain
filterChain
)
public
void
doKerberosAuth
(
ServletRequest
request
,
ServletResponse
response
,
FilterChain
filterChain
Wrapper
,
FilterChain
filterChain
)
throws
IOException
,
ServletException
{
throws
IOException
,
ServletException
{
boolean
unauthorizedResponse
=
true
;
boolean
unauthorizedResponse
=
true
;
int
errCode
=
HttpServletResponse
.
SC_UNAUTHORIZED
;
int
errCode
=
HttpServletResponse
.
SC_UNAUTHORIZED
;
...
@@ -389,7 +405,7 @@ public class AtlasAuthenticationFilter extends AuthenticationFilter {
...
@@ -389,7 +405,7 @@ public class AtlasAuthenticationFilter extends AuthenticationFilter {
getCookiePath
(),
token
.
getExpires
(),
isHttps
);
getCookiePath
(),
token
.
getExpires
(),
isHttps
);
}
}
filterChain
.
doFilter
(
httpRequest
,
httpResponse
);
filterChainWrapper
.
doFilter
(
httpRequest
,
httpResponse
);
}
}
}
else
{
}
else
{
unauthorizedResponse
=
false
;
unauthorizedResponse
=
false
;
...
@@ -412,22 +428,25 @@ public class AtlasAuthenticationFilter extends AuthenticationFilter {
...
@@ -412,22 +428,25 @@ public class AtlasAuthenticationFilter extends AuthenticationFilter {
errCode
=
HttpServletResponse
.
SC_FORBIDDEN
;
errCode
=
HttpServletResponse
.
SC_FORBIDDEN
;
}
}
if
(
authenticationEx
==
null
)
{
// added this code for atlas error handling and fallback
if
(
authenticationEx
==
null
)
{
// added this code for atlas error handling and fallback
boolean
chk
=
true
;
if
(
isBrowser
(
httpRequest
.
getHeader
(
"User-Agent"
)))
{
Collection
<
String
>
headerNames
=
httpResponse
.
getHeaderNames
();
for
(
String
headerName
:
headerNames
)
{
String
value
=
httpResponse
.
getHeader
(
headerName
);
if
(
headerName
.
equalsIgnoreCase
(
"Set-Cookie"
)
&&
value
.
startsWith
(
"JSESSIONID"
))
{
chk
=
false
;
break
;
}
}
String
authHeader
=
httpRequest
.
getHeader
(
"Authorization"
);
if
(
authHeader
==
null
&&
chk
)
{
filterChain
.
doFilter
(
request
,
response
);
}
else
if
(
authHeader
!=
null
&&
authHeader
.
startsWith
(
"Basic"
))
{
filterChain
.
doFilter
(
request
,
response
);
filterChain
.
doFilter
(
request
,
response
);
}
else
{
boolean
chk
=
true
;
Collection
<
String
>
headerNames
=
httpResponse
.
getHeaderNames
();
for
(
String
headerName
:
headerNames
)
{
String
value
=
httpResponse
.
getHeader
(
headerName
);
if
(
headerName
.
equalsIgnoreCase
(
"Set-Cookie"
)
&&
value
.
startsWith
(
"JSESSIONID"
))
{
chk
=
false
;
break
;
}
}
String
authHeader
=
httpRequest
.
getHeader
(
"Authorization"
);
if
(
authHeader
==
null
&&
chk
)
{
filterChain
.
doFilter
(
request
,
response
);
}
else
if
(
authHeader
!=
null
&&
authHeader
.
startsWith
(
"Basic"
))
{
filterChain
.
doFilter
(
request
,
response
);
}
}
}
}
else
{
}
else
{
httpResponse
.
sendError
(
errCode
,
authenticationEx
.
getMessage
());
httpResponse
.
sendError
(
errCode
,
authenticationEx
.
getMessage
());
}
}
...
@@ -550,4 +569,27 @@ public class AtlasAuthenticationFilter extends AuthenticationFilter {
...
@@ -550,4 +569,27 @@ public class AtlasAuthenticationFilter extends AuthenticationFilter {
return
token
;
return
token
;
}
}
void
parseBrowserUserAgents
(
String
userAgents
)
{
String
[]
agentsArray
=
userAgents
.
split
(
","
);
browserUserAgents
=
new
HashSet
<
Pattern
>();
for
(
String
patternString
:
agentsArray
)
{
browserUserAgents
.
add
(
Pattern
.
compile
(
patternString
));
}
}
boolean
isBrowser
(
String
userAgent
)
{
if
(
userAgent
==
null
)
{
return
false
;
}
if
(
browserUserAgents
!=
null
)
{
for
(
Pattern
pattern
:
browserUserAgents
)
{
Matcher
matcher
=
pattern
.
matcher
(
userAgent
);
if
(
matcher
.
matches
())
{
return
true
;
}
}
}
return
false
;
}
}
}
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