Skip to content

Commit d330c45

Browse files
committed
fix bug
1 parent f37f9b2 commit d330c45

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

src/main/java/org/joychou/security/jsonpFilter.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,24 @@ public void init(FilterConfig filterConfig) throws ServletException {
3232
public void doFilter(ServletRequest req, ServletResponse res, FilterChain filterChain)
3333
throws IOException, ServletException {
3434

35-
36-
// If don't check referer, return.
37-
if (!jsonpSwitch) {
38-
return ;
39-
}
40-
4135
HttpServletRequest request = (HttpServletRequest) req;
4236
HttpServletResponse response = (HttpServletResponse) res;
4337

4438
String refer = request.getHeader("referer");
4539
String referWhitelist[] = {"joychou.org", "joychou.com"};
4640

47-
// Check referer for all GET requests with callback parameters.
48-
if (request.getMethod().equals("GET") && StringUtils.isNotBlank(request.getParameter("callback")) ){
49-
// If the check of referer fails, a 403 forbidden error page will be returned.
50-
if (!SecurityUtil.checkURLbyEndsWith(refer, referWhitelist)){
51-
response.sendRedirect("https://test.joychou.org/error3.html");
52-
return;
41+
if (jsonpSwitch) {
42+
// Check referer for all GET requests with callback parameters.
43+
if (request.getMethod().equals("GET") && StringUtils.isNotBlank(request.getParameter("callback")) ){
44+
// If the check of referer fails, a 403 forbidden error page will be returned.
45+
if (!SecurityUtil.checkURLbyEndsWith(refer, referWhitelist)){
46+
response.sendRedirect("https://test.joychou.org/error3.html");
47+
return;
48+
}
5349
}
5450
}
5551

52+
5653
filterChain.doFilter(req, res);
5754
}
5855

src/main/resources/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ management.security.enabled=false
44
# logging.config=classpath:logback-online.xml
55

66
# jsonp check referer switch
7-
org.joychou.security.jsonp = true
7+
org.joychou.security.jsonp = false
88
org.joychou.security.csrf = false

0 commit comments

Comments
 (0)