Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
apollo
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
openSource
apollo
Commits
57c7264c
Commit
57c7264c
authored
Dec 27, 2016
by
lepdou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bugfix: UserAccessFilter filter openapi request
parent
26b44e2f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
UserAccessFilter.java
...ork/apollo/portal/spi/ctrip/filters/UserAccessFilter.java
+17
-3
No files found.
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/spi/ctrip/filters/UserAccessFilter.java
View file @
57c7264c
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
spi
.
ctrip
.
filters
;
import
com.ctrip.framework.apollo.portal.constant.CatEventType
;
import
com.ctrip.framework.apollo.portal.entity.bo.UserInfo
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.google.common.base.Strings
;
import
javax.servlet.*
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.IOException
;
public
class
UserAccessFilter
implements
Filter
{
...
...
@@ -26,12 +29,19 @@ public class UserAccessFilter implements Filter {
@Override
public
void
doFilter
(
ServletRequest
request
,
ServletResponse
response
,
FilterChain
chain
)
throws
IOException
,
ServletException
{
throws
IOException
,
ServletException
{
String
requestUri
=
((
HttpServletRequest
)
request
).
getRequestURI
();
if
(!
isStaticResource
(
requestUri
))
{
Tracer
.
logEvent
(
CatEventType
.
USER_ACCESS
,
userInfoHolder
.
getUser
().
getUserId
());
try
{
if
(!
isOpenAPIRequest
(
requestUri
)
&&
!
isStaticResource
(
requestUri
))
{
UserInfo
userInfo
=
userInfoHolder
.
getUser
();
if
(
userInfo
!=
null
)
{
Tracer
.
logEvent
(
CatEventType
.
USER_ACCESS
,
userInfo
.
getUserId
());
}
}
}
catch
(
Throwable
e
)
{
Tracer
.
logError
(
"Record user access info error."
,
e
);
}
chain
.
doFilter
(
request
,
response
);
...
...
@@ -42,6 +52,10 @@ public class UserAccessFilter implements Filter {
}
private
boolean
isOpenAPIRequest
(
String
uri
)
{
return
!
Strings
.
isNullOrEmpty
(
uri
)
&&
uri
.
startsWith
(
"/openapi"
);
}
private
boolean
isStaticResource
(
String
uri
)
{
return
!
Strings
.
isNullOrEmpty
(
uri
)
&&
uri
.
matches
(
STATIC_RESOURCE_REGEX
);
}
...
...
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