Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
head_group
xyqb-user2
Commits
ed99287e
Commit
ed99287e
authored
Dec 31, 2021
by
李健华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
拦截删除的接口
parent
3fdbe024
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
0 deletions
+48
-0
RequestFilter.java
src/main/java/cn/quantgroup/xyqb/filter/RequestFilter.java
+48
-0
No files found.
src/main/java/cn/quantgroup/xyqb/filter/RequestFilter.java
View file @
ed99287e
...
@@ -28,10 +28,39 @@ public class RequestFilter implements Filter {
...
@@ -28,10 +28,39 @@ public class RequestFilter implements Filter {
* 带状态
* 带状态
*/
*/
private
static
final
String
[]
ALLOWED_PATTERNS
=
{
"/auth/info/login"
,
"/platform/api/page/next"
};
private
static
final
String
[]
ALLOWED_PATTERNS
=
{
"/auth/info/login"
,
"/platform/api/page/next"
};
private
static
final
String
[]
ALLOWED_PATTERNS_UNDEFIND
=
{
"/innerapi/address/search/user_id"
,
"/innerapi/user-association/search/uid"
,
"/innerapi/user-association/search/userid"
,
"/innerapi/user_detail/search/phone"
,
"/innerapi/user_detail/search/userid"
,
"/innerapi/userinfo/search/phone"
,
"/middle_office/contacts"
,
"/middle_office/user_detail/userid"
,
"/user/center/personaldata"
,
"/user/center/searchcontacts/phoneno"
,
"/app/auth/v1/login"
,
"/innerapi/address/save"
,
"/innerapi/contact/save/contacts"
,
"/innerapi/contact/search/user_id"
,
"/innerapi/user-association/search/phone"
,
"/innerapi/user_detail/save"
,
"/innerapi/user_detail/search/phone"
,
"/innerapi/user_detail/search/userid"
,
"/innerapi/user_detail/search_list"
,
"/innerapi/user_ext_info/search/user_id"
,
"/innerapi/user_ext_info/update"
,
"/innerapi/user_full_info/search/uuid"
,
"/innerapi/userinfo/search/uuid"
,
"/user/center/contacts/save"
,
"/user/center/save/userextinfo"
,
};
/**
/**
* 带状态请求鉴权失败时的响应信息
* 带状态请求鉴权失败时的响应信息
*/
*/
private
static
final
String
UNAUTH_RESULT
=
JSONObject
.
toJSONString
(
JsonResult
.
buildErrorStateResult
(
"登录失败"
,
null
));
private
static
final
String
UNAUTH_RESULT
=
JSONObject
.
toJSONString
(
JsonResult
.
buildErrorStateResult
(
"登录失败"
,
null
));
private
static
final
String
UNAUTH_RESULT_UNDEFIND
=
JSONObject
.
toJSONString
(
JsonResult
.
buildErrorStateResult
(
"未找到接口"
,
null
));
@Autowired
@Autowired
private
ISessionService
sessionService
;
private
ISessionService
sessionService
;
private
AntPathMatcher
matcher
=
new
AntPathMatcher
();
private
AntPathMatcher
matcher
=
new
AntPathMatcher
();
...
@@ -65,6 +94,15 @@ public class RequestFilter implements Filter {
...
@@ -65,6 +94,15 @@ public class RequestFilter implements Filter {
}
}
}
}
}
}
if
(
isMatchUndefind
(
request
))
{
response
.
setStatus
(
HttpStatus
.
SC_NOT_FOUND
);
response
.
setHeader
(
"Content-Type"
,
"application/json;charset=utf-8"
);
PrintWriter
writer
=
response
.
getWriter
();
writer
.
print
(
UNAUTH_RESULT_UNDEFIND
);
writer
.
close
();
return
;
}
filterChain
.
doFilter
(
request
,
response
);
filterChain
.
doFilter
(
request
,
response
);
}
}
...
@@ -84,6 +122,16 @@ public class RequestFilter implements Filter {
...
@@ -84,6 +122,16 @@ public class RequestFilter implements Filter {
return
false
;
return
false
;
}
}
private
boolean
isMatchUndefind
(
HttpServletRequest
request
)
{
String
path
=
getRequestPath
(
request
);
for
(
String
pattern
:
ALLOWED_PATTERNS_UNDEFIND
)
{
if
(
matcher
.
match
(
pattern
,
path
))
{
return
true
;
}
}
return
false
;
}
private
String
getRequestPath
(
HttpServletRequest
request
)
{
private
String
getRequestPath
(
HttpServletRequest
request
)
{
String
url
=
request
.
getServletPath
();
String
url
=
request
.
getServletPath
();
if
(
Objects
.
nonNull
(
request
.
getPathInfo
()))
{
if
(
Objects
.
nonNull
(
request
.
getPathInfo
()))
{
...
...
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