-
Notifications
You must be signed in to change notification settings - Fork 722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shiro模块源码几个疑问 #81
Comments
|
刚看了refreshLoginInfo的实现,首先会调用deleteLoginInfo删除redis中的记录,那getLoginSysUserRedisVo应该取不到对应的value了吧。 |
LoginUtil的getUserId()、getUsername()方法有问题:1、loginSysUserRedisVo为空依然调用getId()、getUsername()方法,容易出现NullPointer异常 |
Redis缓存时间是获取的JwtToken的失效时间,所以是一致的。 @nita22 // Redis过期时间与JwtToken过期时间一致
Duration expireDuration = Duration.ofSeconds(jwtToken.getExpireSecond()); |
当抛出AuthenticationException等校验异常时,会进入失败方法处理 /**
* 访问失败处理
*
* @param request
* @param response
* @return
* @throws Exception
*/
@Override
protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception {
HttpServletRequest httpServletRequest = WebUtils.toHttp(request);
HttpServletResponse httpServletResponse = WebUtils.toHttp(response);
// 返回401
httpServletResponse.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
// 设置响应码为401或者直接输出消息
String url = httpServletRequest.getRequestURI();
log.error("onAccessDenied url:{}", url);
ApiResult apiResult = ApiResult.fail(ApiCode.UNAUTHORIZED);
HttpServletResponseUtil.printJSON(httpServletResponse, apiResult);
return false;
} 前端响应结果 {
"code": 401,
"msg": "非法访问",
"time": "2019-10-22 10:06:16"
} |
refreshToken方法和LoginUtil工具类方法问题已修复 |
看了Shiro模块的相关源码,有几个疑问,求解答,十分感谢!
1、ShiroConfig类中的addDefaultFilterDefinition()方法:为何默认都要经过path拦截器,就是为了记录日志?
2、LoginRedisServiceImpl类的cacheLoginInfo()方法:generate参数并没有用到?
3、LoginUtil类并没有被用到?
4、LoginServiceImpl类的refreshToken方法存在问题:
4.1:签发新token后,jwtToken还是用回旧token的过期时间?
4.2:仅仅是在redis中新增已刷新的token,未删除redis上的过期key?
The text was updated successfully, but these errors were encountered: