Commit e3a650f8 authored by zengtianlai3's avatar zengtianlai3

解决不安全的http方法

parent cf7965c5
...@@ -31,7 +31,7 @@ import java.util.Map; ...@@ -31,7 +31,7 @@ import java.util.Map;
*/ */
@Slf4j @Slf4j
@RestController @RestController
@RequestMapping("/") @RequestMapping("/iot_license")
@Api(value = "登录模块", tags = {"登录模块"}) @Api(value = "登录模块", tags = {"登录模块"})
public class LoginController { public class LoginController {
......
...@@ -19,7 +19,7 @@ import java.io.IOException; ...@@ -19,7 +19,7 @@ import java.io.IOException;
@RestController @RestController
@RequestMapping("/resource") @RequestMapping("/iot_license/resource")
@Api(value = "资源模块", tags = {"资源模块"}) @Api(value = "资源模块", tags = {"资源模块"})
public class ResourceContrller { public class ResourceContrller {
......
...@@ -11,6 +11,7 @@ import javax.servlet.annotation.WebFilter; ...@@ -11,6 +11,7 @@ import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Date; import java.util.Date;
import java.util.Map; import java.util.Map;
...@@ -35,9 +36,11 @@ public class JwtFilter implements Filter { ...@@ -35,9 +36,11 @@ public class JwtFilter implements Filter {
final HttpServletResponse response = (HttpServletResponse) servletResponse; final HttpServletResponse response = (HttpServletResponse) servletResponse;
response.setHeader("Set-Cookie","cookiename=cookievalue; path=/; Domain=domainvaule; Max-age=seconds; HttpOnly"); response.setHeader("Set-Cookie","cookiename=cookievalue; path=/; Domain=domainvaule; Max-age=seconds; HttpOnly");
response.setContentType("text/html; charset=utf-8"); response.setContentType("text/html; charset=utf-8");
if ("OPTIONS".equals(request.getMethod())) { if ("OPTIONS".equals(request.getMethod()) || "HEAD".equals(request.getMethod())) {
response.setStatus(HttpServletResponse.SC_OK); response.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
filterChain.doFilter(request, response); ServletOutputStream outputStream = response.getOutputStream();
outputStream.write(new String("不安全的请求".getBytes(), StandardCharsets.UTF_8).getBytes());
outputStream.flush();
return; return;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment