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
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
2 deletions
+16
-2
UserAccessFilter.java
...ork/apollo/portal/spi/ctrip/filters/UserAccessFilter.java
+16
-2
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
{
...
...
@@ -30,8 +33,15 @@ public class UserAccessFilter implements Filter {
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