springboot+shiro+ Ehcache 调用subject.hasRole 不执行AuthorizationInfo方法,请问是什么问题?缓存导致的吗?
@GetMapping("/main")
public String main(ModelMap map) {
SysUser sysUser = ShiroUtils.getSysUser();
Subject subject = ShiroUtils.getSubject();
String deptno=sysUser.getDeptId();
map.addAttribute("deptno",deptno);
if(sysUser.isAdmin()) {
map.put("isShowTip", true);
map.put("isShowQxt", true);
}else {
String[] split = roleid.split(",");
String[] split2 = roleid2.split(",");
for(String r : split) {
System.out.println("--------弹窗开始验证授权:"+r);
boolean hasRole = subject.hasRole(r);
System.out.println("--------弹窗验证授权结束 :"+hasRole);
if(hasRole) {
map.put("isShowTip", true);
}
break;
}
for(String r : split2) {
System.out.println("--------曲线图开始验证授权:"+r);
boolean hasRole = subject.hasRole(r);// hasRole角色验证 isPermitted权限验证
System.out.println("--------曲线图证授权结束 :"+hasRole);
if(hasRole) {
map.put("isShowQxt", true);
}
break;
}
}
return viewPath+"/main";
}
根本没进入AuthorizationInfo方法,直接就判断false
弹窗开始验证授权:R00001
弹窗验证授权结束 :false
曲线图开始验证授权:R00001
曲线图证授权结束 :false
//anon :无需认证就可以访问
//authc:必须认证才能访问
//user:必须拥有记住我 功能才能使用
//perms: 拥有对某个资源的权限才能访问
//role: 拥有某个角色权限才能访问
Map<String,String> filterChainDefinitionMap = new LinkedHashMap<>();
filterChainDefinitionMap.put("/*","authc");
shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
在配置文件里有没有加setFilterChainDefinitionMap
你的AuthorizationInfo是怎么样配置的?