1. 增加验证码开关(fixed:接口模式校验问题)

This commit is contained in:
wangiegie@gmail.com 2017-12-23 12:35:47 +08:00
parent fddf866b41
commit 2f58b29cfb
1 changed files with 7 additions and 2 deletions

View File

@ -25,17 +25,22 @@ import java.io.PrintWriter;
/**
* @author lengleng
* @date 2017-12-18
* 验证码校验
* 验证码校验true开启false关闭校验
* 更细化可以 clientId 进行区分
*
*/
@Component("validateCodeFilter")
public class ValidateCodeFilter extends OncePerRequestFilter {
private static final Logger logger = LoggerFactory.getLogger(ValidateCodeFilter.class);
@Value("${security.validate.code:true}")
private boolean isValidate;
@Autowired
private RedisTemplate redisTemplate;
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
if (StringUtils.contains(request.getRequestURI(), SecurityConstants.OAUTH_TOKEN_URL) || StringUtils.contains(request.getRequestURI(), SecurityConstants.REFRESH_TOKEN)) {
if (isValidate && (StringUtils.contains(request.getRequestURI(), SecurityConstants.OAUTH_TOKEN_URL)
|| StringUtils.contains(request.getRequestURI(), SecurityConstants.REFRESH_TOKEN))) {
PrintWriter printWriter = null;
try {
checkCode(request, response, filterChain);