update 优化同步数据时的验证逻辑

This commit is contained in:
lijiarao
2021-09-16 16:04:14 +08:00
parent 7232e9920f
commit d1d3368189
2 changed files with 21 additions and 11 deletions
@@ -1,5 +1,9 @@
package com.jero.config.shiro.filters;
import cn.hutool.core.util.StrUtil;
import com.jero.common.system.util.JwtUtil;
import com.jero.common.util.AuthenticationUtils;
import com.jero.common.util.SpringContextUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.web.filter.authc.BasicHttpAuthenticationFilter;
@@ -9,6 +13,7 @@ import com.jero.config.shiro.JwtToken;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.annotation.Resource;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
@@ -28,6 +33,8 @@ public class JwtFilter extends BasicHttpAuthenticationFilter {
public JwtFilter(boolean allowOrigin){
this.allowOrigin = allowOrigin;
}
@Resource
private AuthenticationUtils authenticationUtils;
/**
* 执行登录认证
@@ -58,12 +65,21 @@ public class JwtFilter extends BasicHttpAuthenticationFilter {
if(token == null){
token = httpServletRequest.getParameter("token");
}
// update-end--Author:lvdandan Date:20210105 forJT-355 OA聊天添加token验证,获取token参数
String pushToken = httpServletRequest.getParameter("pushToken");
if (StrUtil.isNotBlank(pushToken)){
String publicKey = httpServletRequest.getParameter("publicKey");
if (authenticationUtils ==null ){
authenticationUtils = (AuthenticationUtils) SpringContextUtil.getBean("authenticationUtils");
}
authenticationUtils.check(pushToken,publicKey);
}else {
// update-end--Author:lvdandan Date:20210105 forJT-355 OA聊天添加token验证,获取token参数
JwtToken jwtToken = new JwtToken(token);
// 提交给realm进行登入,如果错误他会抛出异常并被捕获
getSubject(request, response).login(jwtToken);
// 如果没有抛出异常则代表登入成功,返回true
JwtToken jwtToken = new JwtToken(token);
// 提交给realm进行登入,如果错误他会抛出异常并被捕获
getSubject(request, response).login(jwtToken);
// 如果没有抛出异常则代表登入成功,返回true
}
return true;
}
@@ -103,9 +103,6 @@ public class SysUserController {
@Resource
private BaseCommonService baseCommonService;
@Resource
private AuthenticationUtils authenticationUtils;
/**
* 根据角色id和部门id获取用户列表数据
*/
@@ -252,9 +249,6 @@ public class SysUserController {
@ApiOperation(value = "查询列表", notes = "查询列表")
@RequestMapping(value = "/payUserList", method = RequestMethod.GET)
public Result<?> queryList2(SysUser user, HttpServletRequest req) {
String publicKey = req.getParameter("publicKey");
String token = req.getParameter("token");
authenticationUtils.check(token,publicKey);
Result<List<SysUser>> result = new Result<>();
QueryWrapper<SysUser> queryWrapper = QueryGenerator.initQueryWrapper(user, req.getParameterMap());
//TODO 外部模拟登陆临时账号,列表不显示