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
75bed9b3
Commit
75bed9b3
authored
Dec 27, 2016
by
Jason Song
Committed by
GitHub
Dec 27, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #504 from lepdou/bugfix_openapi3
bugfix: UserAccessFilter filter openapi request
parents
26b44e2f
57c7264c
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 @
75bed9b3
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
spi
.
ctrip
.
filters
;
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
spi
.
ctrip
.
filters
;
import
com.ctrip.framework.apollo.portal.constant.CatEventType
;
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.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.google.common.base.Strings
;
import
com.google.common.base.Strings
;
import
javax.servlet.*
;
import
javax.servlet.*
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.IOException
;
import
java.io.IOException
;
public
class
UserAccessFilter
implements
Filter
{
public
class
UserAccessFilter
implements
Filter
{
...
@@ -30,8 +33,15 @@ public class UserAccessFilter implements Filter {
...
@@ -30,8 +33,15 @@ public class UserAccessFilter implements Filter {
String
requestUri
=
((
HttpServletRequest
)
request
).
getRequestURI
();
String
requestUri
=
((
HttpServletRequest
)
request
).
getRequestURI
();
if
(!
isStaticResource
(
requestUri
))
{
try
{
Tracer
.
logEvent
(
CatEventType
.
USER_ACCESS
,
userInfoHolder
.
getUser
().
getUserId
());
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
);
chain
.
doFilter
(
request
,
response
);
...
@@ -42,6 +52,10 @@ public class UserAccessFilter implements Filter {
...
@@ -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
)
{
private
boolean
isStaticResource
(
String
uri
)
{
return
!
Strings
.
isNullOrEmpty
(
uri
)
&&
uri
.
matches
(
STATIC_RESOURCE_REGEX
);
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