Open Sage520 opened 4 years ago
可否附上配置文件?
类似的问题,我是于jwt配合使用的,是哪个类的方法封装了redis权限校验的部分?一直没有跟到具体代码
类似的问题,我是于jwt配合使用的,是这些类的方法封装了redis权限校验的部分?一直没有跟到具体代码
我也是jwt的
可否附上配置文件?
@Bean
public SessionManager sessionManager(RedisSessionDAO redisSessionDAO) {
DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
// inject redisSessionDAO
sessionManager.setSessionDAO(redisSessionDAO);
// other stuff...
return sessionManager;
}
@Bean
public SessionsSecurityManager securityManager(AccountRealm accountRealm, SessionManager sessionManager,RedisCacheManager redisCacheManager) {
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(accountRealm);
// 注入realm
securityManager.setRealm(accountRealm);
// inject sessionManager
securityManager.setSessionManager(sessionManager);
// inject redisCacheManager
securityManager.setCacheManager(redisCacheManager);
// other stuff...
return securityManager;
}
@Bean
public ShiroFilterChainDefinition shiroFilterChainDefinition() {
DefaultShiroFilterChainDefinition chainDefinition = new DefaultShiroFilterChainDefinition();
Map<String, String> filterMap = new LinkedHashMap<>();
filterMap.put("/druid/**","anon");
filterMap.put("/**", "jwt"); // 主要通过注解方式校验权限
chainDefinition.addPathDefinitions(filterMap);
return chainDefinition;
}
@Bean("shiroFilterFactoryBean")
public ShiroFilterFactoryBean shiroFilterFactoryBean(SecurityManager securityManager,
ShiroFilterChainDefinition shiroFilterChainDefinition) {
ShiroFilterFactoryBean shiroFilter = new ShiroFilterFactoryBean();
shiroFilter.setSecurityManager(securityManager);
Map<String, Filter> filters = new HashMap<>();
filters.put("jwt", jwtFilter);
shiroFilter.setFilters(filters);
Map<String, String> filterMap = shiroFilterChainDefinition.getFilterChainMap();
shiroFilter.setFilterChainDefinitionMap(filterMap);
return shiroFilter;
}
我的那个是参考最新样例,只自定义了shiroFilterFactoryBean,注入jwtfilter
我的那个是参考最新样例,只自定义了shiroFilterFactoryBean,注入jwtfilter
我折腾了几天没弄好,最后只好选择把它的那个session关了,自己写了个redis缓存的功能
redis中有会话数据,但每次访问api,都会重新查数据库不走redis,并且查完又加了一条redis缓存,导致redis中同一个用户有很多相同会话,但查询的时候又不用
环境: jdk8 windows 10 springboot 2.2.6