|
@@ -50,101 +50,180 @@ public class ShiroConfig {
|
|
|
@Autowired
|
|
|
private Environment env;
|
|
|
|
|
|
+ @Value("${spring.redis.port}")
|
|
|
+ private String port;
|
|
|
+
|
|
|
+ @Value("${spring.redis.host}")
|
|
|
+ private String host;
|
|
|
+
|
|
|
+ @Value("${spring.redis.password}")
|
|
|
+ private String redisPassword;
|
|
|
|
|
|
/**
|
|
|
* Filter Chain定义说明
|
|
|
- *
|
|
|
+ * <p>
|
|
|
* 1、一个URL可以配置多个Filter,使用逗号分隔
|
|
|
* 2、当设置多个过滤器时,全部验证通过,才视为通过
|
|
|
* 3、部分过滤器可指定参数,如perms,roles
|
|
|
*/
|
|
|
@Bean("shiroFilter")
|
|
|
public ShiroFilterFactoryBean shiroFilter(SecurityManager securityManager) {
|
|
|
- CustomShiroFilterFactoryBean shiroFilterFactoryBean = new CustomShiroFilterFactoryBean();
|
|
|
+ ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
|
|
|
shiroFilterFactoryBean.setSecurityManager(securityManager);
|
|
|
// 拦截器
|
|
|
- Map<String, String> filterChainDefinitionMap = new LinkedHashMap<String, String>();
|
|
|
- if(oConvertUtils.isNotEmpty(excludeUrls)){
|
|
|
- String[] permissionUrl = excludeUrls.split(",");
|
|
|
- for(String url : permissionUrl){
|
|
|
- filterChainDefinitionMap.put(url,"anon");
|
|
|
- }
|
|
|
- }
|
|
|
+ Map<String, String> filterChainDefinitionMap = new LinkedHashMap<>();
|
|
|
// 配置不会被拦截的链接 顺序判断
|
|
|
- filterChainDefinitionMap.put("/sys/cas/client/validateLogin", "anon"); //cas验证登录
|
|
|
- filterChainDefinitionMap.put("/sys/randomImage/**", "anon"); //登录验证码接口排除
|
|
|
- filterChainDefinitionMap.put("/sys/checkCaptcha", "anon"); //登录验证码接口排除
|
|
|
- filterChainDefinitionMap.put("/sys/login", "anon"); //登录接口排除
|
|
|
- filterChainDefinitionMap.put("/sys/mLogin", "anon"); //登录接口排除
|
|
|
- filterChainDefinitionMap.put("/sys/logout", "anon"); //登出接口排除
|
|
|
- filterChainDefinitionMap.put("/sys/thirdLogin/**", "anon"); //第三方登录
|
|
|
- filterChainDefinitionMap.put("/sys/getEncryptedString", "anon"); //获取加密串
|
|
|
- filterChainDefinitionMap.put("/sys/sms", "anon");//短信验证码
|
|
|
- filterChainDefinitionMap.put("/sys/phoneLogin", "anon");//手机登录
|
|
|
- filterChainDefinitionMap.put("/sys/user/checkOnlyUser", "anon");//校验用户是否存在
|
|
|
- filterChainDefinitionMap.put("/sys/user/register", "anon");//用户注册
|
|
|
- filterChainDefinitionMap.put("/sys/user/querySysUser", "anon");//根据手机号获取用户信息
|
|
|
- filterChainDefinitionMap.put("/sys/user/phoneVerification", "anon");//用户忘记密码验证手机号
|
|
|
- filterChainDefinitionMap.put("/sys/user/passwordChange", "anon");//用户更改密码
|
|
|
- filterChainDefinitionMap.put("/auth/2step-code", "anon");//登录验证码
|
|
|
- filterChainDefinitionMap.put("/sys/common/static/**", "anon");//图片预览 &下载文件不限制token
|
|
|
- filterChainDefinitionMap.put("/sys/common/pdf/**", "anon");//pdf预览
|
|
|
- filterChainDefinitionMap.put("/generic/**", "anon");//pdf预览需要文件
|
|
|
+ //登录接口排除
|
|
|
+ filterChainDefinitionMap.put("/sys/mLogin", "anon");
|
|
|
+ filterChainDefinitionMap.put("/sys/login", "anon");
|
|
|
+ filterChainDefinitionMap.put("/sys/wxlogin", "anon");
|
|
|
+ filterChainDefinitionMap.put("/ctop/rule/**", "anon");
|
|
|
+ //第三方登录
|
|
|
+ filterChainDefinitionMap.put("/thirdLogin/**", "anon");
|
|
|
+ //获取加密串
|
|
|
+ filterChainDefinitionMap.put("/sys/getEncryptedString", "anon");
|
|
|
+ //短信验证码
|
|
|
+ filterChainDefinitionMap.put("/sys/sms", "anon");
|
|
|
+ //手机登录
|
|
|
+ filterChainDefinitionMap.put("/sys/phoneLogin", "anon");
|
|
|
+ //校验用户是否存在
|
|
|
+ filterChainDefinitionMap.put("/sys/user/checkOnlyUser", "anon");
|
|
|
+ //用户注册
|
|
|
+ filterChainDefinitionMap.put("/sys/user/register", "anon");
|
|
|
+ //根据手机号获取用户信息
|
|
|
+ filterChainDefinitionMap.put("/sys/user/querySysUser", "anon");
|
|
|
+ //用户忘记密码验证手机号
|
|
|
+ filterChainDefinitionMap.put("/sys/user/phoneVerification", "anon");
|
|
|
+ //用户更改密码
|
|
|
+ filterChainDefinitionMap.put("/sys/user/passwordChange", "anon");
|
|
|
+ //登录验证码
|
|
|
+ filterChainDefinitionMap.put("/auth/2step-code", "anon");
|
|
|
+ //图片预览不限制token
|
|
|
+ filterChainDefinitionMap.put("/sys/common/view/**", "anon");
|
|
|
+ //文件下载不限制token
|
|
|
+ filterChainDefinitionMap.put("/sys/common/download/**", "anon");
|
|
|
+ //pdf预览
|
|
|
+ filterChainDefinitionMap.put("/sys/common/pdf/**", "anon");
|
|
|
+ filterChainDefinitionMap.put("/ctop/bytedanceAreaInfo/**", "anon");
|
|
|
+ filterChainDefinitionMap.put("/ctop/bytedanceInterestCategory/**", "anon");
|
|
|
+ filterChainDefinitionMap.put("/template/creative/words/get", "anon");
|
|
|
+ filterChainDefinitionMap.put("template/bytedance/industry/list", "anon");
|
|
|
+ //积木报表排除
|
|
|
+ filterChainDefinitionMap.put("/jmreport/**", "anon");
|
|
|
+ filterChainDefinitionMap.put("/**/*.js.map", "anon");
|
|
|
+ filterChainDefinitionMap.put("/**/*.css.map", "anon");
|
|
|
+ filterChainDefinitionMap.put("/bytedance/batch/creative/words/get", "anon");
|
|
|
+ filterChainDefinitionMap.put("/bytedance/batch/action/text", "anon");
|
|
|
+ filterChainDefinitionMap.put("/bytedance/batch/industry/list", "anon");
|
|
|
+ filterChainDefinitionMap.put("/appium/crawler/*", "anon");
|
|
|
+
|
|
|
+ filterChainDefinitionMap.put("/ctop/kuaishouChannelRegInfo/*", "anon");
|
|
|
+ filterChainDefinitionMap.put("/ctop/byteDance/homePage/report/*", "anon");
|
|
|
+ filterChainDefinitionMap.put("/ctop/material/top/cost", "anon");
|
|
|
+ filterChainDefinitionMap.put("/dimension/report/*", "anon");
|
|
|
+ filterChainDefinitionMap.put("/userAllocation/updateAuthName", "anon");
|
|
|
+
|
|
|
+ filterChainDefinitionMap.put("/v1/**", "anon");
|
|
|
+
|
|
|
+ filterChainDefinitionMap.put("/generic/**", "anon");
|
|
|
filterChainDefinitionMap.put("/", "anon");
|
|
|
filterChainDefinitionMap.put("/doc.html", "anon");
|
|
|
filterChainDefinitionMap.put("/**/*.js", "anon");
|
|
|
filterChainDefinitionMap.put("/**/*.css", "anon");
|
|
|
filterChainDefinitionMap.put("/**/*.html", "anon");
|
|
|
filterChainDefinitionMap.put("/**/*.svg", "anon");
|
|
|
- filterChainDefinitionMap.put("/**/*.pdf", "anon");
|
|
|
filterChainDefinitionMap.put("/**/*.jpg", "anon");
|
|
|
filterChainDefinitionMap.put("/**/*.png", "anon");
|
|
|
filterChainDefinitionMap.put("/**/*.ico", "anon");
|
|
|
-
|
|
|
- filterChainDefinitionMap.put("/**/*.ttf", "anon");
|
|
|
- filterChainDefinitionMap.put("/**/*.woff", "anon");
|
|
|
- filterChainDefinitionMap.put("/**/*.woff2", "anon");
|
|
|
-
|
|
|
filterChainDefinitionMap.put("/druid/**", "anon");
|
|
|
filterChainDefinitionMap.put("/swagger-ui.html", "anon");
|
|
|
filterChainDefinitionMap.put("/swagger**/**", "anon");
|
|
|
filterChainDefinitionMap.put("/webjars/**", "anon");
|
|
|
filterChainDefinitionMap.put("/v2/**", "anon");
|
|
|
-
|
|
|
-
|
|
|
- // update-begin--Author:sunjianlei Date:20210510 for:排除消息通告查看详情页面(用于第三方APP)
|
|
|
- filterChainDefinitionMap.put("/sys/annountCement/show/**", "anon");
|
|
|
- // update-end--Author:sunjianlei Date:20210510 for:排除消息通告查看详情页面(用于第三方APP)
|
|
|
-
|
|
|
- //积木报表排除
|
|
|
- filterChainDefinitionMap.put("/jmreport/**", "anon");
|
|
|
- filterChainDefinitionMap.put("/**/*.js.map", "anon");
|
|
|
- filterChainDefinitionMap.put("/**/*.css.map", "anon");
|
|
|
+ filterChainDefinitionMap.put("/kuaishou", "anon");
|
|
|
+ filterChainDefinitionMap.put("/kuaishou/report", "anon");
|
|
|
+ filterChainDefinitionMap.put("/ctop/bindAccount/**", "anon");
|
|
|
+ filterChainDefinitionMap.put("/**/*.mp4", "anon");
|
|
|
+ //activiti
|
|
|
+ filterChainDefinitionMap.put("/activiti/**", "anon");
|
|
|
+ filterChainDefinitionMap.put("/diagram-viewer/**", "anon");
|
|
|
+ filterChainDefinitionMap.put("/editor-app/**", "anon");
|
|
|
//大屏设计器排除
|
|
|
- filterChainDefinitionMap.put("/bigscreen/**", "anon");
|
|
|
+ filterChainDefinitionMap.put("/big/screen/**", "anon");
|
|
|
|
|
|
- //测试示例
|
|
|
- filterChainDefinitionMap.put("/test/order/**", "anon");
|
|
|
- filterChainDefinitionMap.put("/test/bigScreen/**", "anon"); //大屏模板例子
|
|
|
- //filterChainDefinitionMap.put("/test/jeecgDemo/rabbitMqClientTest/**", "anon"); //MQ测试
|
|
|
- //filterChainDefinitionMap.put("/test/jeecgDemo/html", "anon"); //模板页面
|
|
|
- //filterChainDefinitionMap.put("/test/jeecgDemo/redis/**", "anon"); //redis测试
|
|
|
+ //性能监控
|
|
|
+ filterChainDefinitionMap.put("/actuator/metrics/**", "anon");
|
|
|
+ filterChainDefinitionMap.put("/actuator/httptrace/**", "anon");
|
|
|
+ filterChainDefinitionMap.put("/actuator/redis/**", "anon");
|
|
|
+ //消息队列
|
|
|
+ filterChainDefinitionMap.put("/mq/**", "anon");
|
|
|
+ //模板测试
|
|
|
+ filterChainDefinitionMap.put("/test/**", "anon");
|
|
|
+ //oauth接口
|
|
|
+ filterChainDefinitionMap.put("/auth/**", "anon");
|
|
|
+ filterChainDefinitionMap.put("/ctop/syncdata/**", "anon");
|
|
|
+ filterChainDefinitionMap.put("/sys/dictItem/list", "anon");
|
|
|
+ //头条接口
|
|
|
+ filterChainDefinitionMap.put("/bytedance", "anon");
|
|
|
+ filterChainDefinitionMap.put("/toutiao/loadAllData", "anon");
|
|
|
+ filterChainDefinitionMap.put("/toutiao/loadSingleData", "anon");
|
|
|
+ filterChainDefinitionMap.put("/kuaishou/getReport/historyData", "anon");
|
|
|
+ filterChainDefinitionMap.put("/toutiao/advertiser/**", "anon");
|
|
|
+ filterChainDefinitionMap.put("/template/convert/**", "anon");
|
|
|
+ filterChainDefinitionMap.put("/upload/**", "anon");
|
|
|
+ filterChainDefinitionMap.put("/appium/appiumTask/run", "anon");
|
|
|
|
|
|
- //websocket排除
|
|
|
- filterChainDefinitionMap.put("/websocket/**", "anon");//系统通知和公告
|
|
|
- filterChainDefinitionMap.put("/newsWebsocket/**", "anon");//CMS模块
|
|
|
- filterChainDefinitionMap.put("/vxeSocket/**", "anon");//JVxeTable无痕刷新示例
|
|
|
- //
|
|
|
- filterChainDefinitionMap.put("/advertiser/aiBytedanceAdvertiserStrategy/**", "anon");
|
|
|
+ filterChainDefinitionMap.put("/system/userCompany/**", "anon");
|
|
|
+ filterChainDefinitionMap.put("/qywexin", "anon");
|
|
|
+ filterChainDefinitionMap.put("/sys/feishu/**", "anon");
|
|
|
+ filterChainDefinitionMap.put("/test/getGroupData/**", "anon");
|
|
|
+ filterChainDefinitionMap.put("/test/getVideoAndImage/**", "anon");
|
|
|
+ filterChainDefinitionMap.put("/test/gerCreative/**", "anon");
|
|
|
+ filterChainDefinitionMap.put("/test/testdouyinmusic", "anon");
|
|
|
+ filterChainDefinitionMap.put("/test/syncDouyinMusic", "anon");
|
|
|
+ filterChainDefinitionMap.put("/test/parseDouyinMusic", "anon");
|
|
|
+ filterChainDefinitionMap.put("/report/kuaishouReportDailyAgent/get", "anon");
|
|
|
|
|
|
- //性能监控 TODO 存在安全漏洞泄露TOEKN(durid连接池也有)
|
|
|
- filterChainDefinitionMap.put("/actuator/**", "anon");
|
|
|
+ filterChainDefinitionMap.put("/appium/appiumTask/run/login", "anon");
|
|
|
+ filterChainDefinitionMap.put("/zip/download", "anon");
|
|
|
+ //WebSocket
|
|
|
+ filterChainDefinitionMap.put("/websocket/*", "anon");
|
|
|
+ //爬虫接口
|
|
|
+ filterChainDefinitionMap.put("/graphql/video", "anon");
|
|
|
+ filterChainDefinitionMap.put("/ks/web/test", "anon");
|
|
|
+ filterChainDefinitionMap.put("/ureport/**", "anon");
|
|
|
+ filterChainDefinitionMap.put("/job/test/*", "anon");
|
|
|
+ filterChainDefinitionMap.put("/third/*", "anon");
|
|
|
+ filterChainDefinitionMap.put("/ctop/kuaishou/dailyPage/**", "anon");
|
|
|
+ filterChainDefinitionMap.put("/rest/script/*", "anon");
|
|
|
+ filterChainDefinitionMap.put("/ctop/checkTaskList/*", "anon");
|
|
|
+ filterChainDefinitionMap.put("/ctop/report/bytedance/*", "anon");
|
|
|
+ filterChainDefinitionMap.put("/shiwan/shiwanFileUpload/*", "anon");
|
|
|
+ filterChainDefinitionMap.put("/oa/wechatNoList/*", "anon");
|
|
|
+ filterChainDefinitionMap.put("/ruleGroup/*", "anon");
|
|
|
+ filterChainDefinitionMap.put("/kuaishou/material/*", "anon");
|
|
|
+ filterChainDefinitionMap.put("/kuaishou/create/*", "anon");
|
|
|
+ filterChainDefinitionMap.put("/template/kuaiShouBatchCreativeTemplate/*", "anon");
|
|
|
+ filterChainDefinitionMap.put("/template/kuaiShouBatchGroupTemplate/*", "anon");
|
|
|
+ filterChainDefinitionMap.put("/template/kuaiShouBatchCampaignTemplate/*", "anon");
|
|
|
+ filterChainDefinitionMap.put("/template/**", "anon");
|
|
|
+ filterChainDefinitionMap.put("/batch/kuaiShouGroupTemplate/*", "anon");
|
|
|
+ filterChainDefinitionMap.put("/kuaishouBatch/**", "anon");
|
|
|
+ filterChainDefinitionMap.put("/kuaishou/creative/*", "anon");
|
|
|
+ filterChainDefinitionMap.put("/ai/aiKuaiShouAppInfo/*", "anon");
|
|
|
+ filterChainDefinitionMap.put("/explore/*", "anon");
|
|
|
+ filterChainDefinitionMap.put("/ai/batchUpdate/*", "anon");
|
|
|
+ filterChainDefinitionMap.put("/ctop/kuaishou/videoReport/*", "anon");
|
|
|
+ filterChainDefinitionMap.put("/ai/create/*", "anon");
|
|
|
+ //filterChainDefinitionMap.put("/overView/*", "anon");
|
|
|
+ filterChainDefinitionMap.put("/kuaishouCrowdPack/**", "anon");
|
|
|
+ filterChainDefinitionMap.put("/kuaishou/batch/*", "anon");
|
|
|
+ filterChainDefinitionMap.put("/dimension/kuaiShouDimensionAccount/*", "anon");
|
|
|
+ filterChainDefinitionMap.put("/ai/projectCreate/*", "anon");
|
|
|
|
|
|
// 添加自己的过滤器并且取名为jwt
|
|
|
- Map<String, Filter> filterMap = new HashMap<String, Filter>(1);
|
|
|
- //如果cloudServer为空 则说明是单体 需要加载跨域配置
|
|
|
- Object cloudServer = env.getProperty(CommonConstant.CLOUD_SERVER_KEY);
|
|
|
- filterMap.put("jwt", new JwtFilter(cloudServer==null));
|
|
|
+ Map<String, Filter> filterMap = new HashMap<>(1);
|
|
|
+ filterMap.put("jwt", new JwtFilter());
|
|
|
shiroFilterFactoryBean.setFilters(filterMap);
|
|
|
// <!-- 过滤链定义,从上向下顺序执行,一般将/**放在最为下边
|
|
|
filterChainDefinitionMap.put("/**", "jwt");
|
|
@@ -171,13 +250,13 @@ public class ShiroConfig {
|
|
|
defaultSessionStorageEvaluator.setSessionStorageEnabled(false);
|
|
|
subjectDAO.setSessionStorageEvaluator(defaultSessionStorageEvaluator);
|
|
|
securityManager.setSubjectDAO(subjectDAO);
|
|
|
- //自定义缓存实现,使用redis
|
|
|
- securityManager.setCacheManager(redisCacheManager());
|
|
|
+
|
|
|
return securityManager;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 下面的代码是添加注解支持
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
@Bean
|
|
@@ -213,7 +292,6 @@ public class ShiroConfig {
|
|
|
* @return
|
|
|
*/
|
|
|
public RedisCacheManager redisCacheManager() {
|
|
|
- log.info("===============(1)创建缓存管理器RedisCacheManager");
|
|
|
RedisCacheManager redisCacheManager = new RedisCacheManager();
|
|
|
redisCacheManager.setRedisManager(redisManager());
|
|
|
//redis中针对不同用户缓存(此处的id需要对应user实体中的id字段,用于唯一标识)
|
|
@@ -230,39 +308,14 @@ public class ShiroConfig {
|
|
|
* @return
|
|
|
*/
|
|
|
@Bean
|
|
|
- public IRedisManager redisManager() {
|
|
|
- log.info("===============(2)创建RedisManager,连接Redis..");
|
|
|
- IRedisManager manager;
|
|
|
- // redis 单机支持,在集群为空,或者集群无机器时候使用 add by jzyadmin@163.com
|
|
|
- if (lettuceConnectionFactory.getClusterConfiguration() == null || lettuceConnectionFactory.getClusterConfiguration().getClusterNodes().isEmpty()) {
|
|
|
- RedisManager redisManager = new RedisManager();
|
|
|
- redisManager.setHost(lettuceConnectionFactory.getHostName());
|
|
|
- redisManager.setPort(lettuceConnectionFactory.getPort());
|
|
|
- redisManager.setDatabase(lettuceConnectionFactory.getDatabase());
|
|
|
- redisManager.setTimeout(0);
|
|
|
- if (!StringUtils.isEmpty(lettuceConnectionFactory.getPassword())) {
|
|
|
- redisManager.setPassword(lettuceConnectionFactory.getPassword());
|
|
|
- }
|
|
|
- manager = redisManager;
|
|
|
- }else{
|
|
|
- // redis集群支持,优先使用集群配置
|
|
|
- RedisClusterManager redisManager = new RedisClusterManager();
|
|
|
- Set<HostAndPort> portSet = new HashSet<>();
|
|
|
- lettuceConnectionFactory.getClusterConfiguration().getClusterNodes().forEach(node -> portSet.add(new HostAndPort(node.getHost() , node.getPort())));
|
|
|
- //update-begin--Author:scott Date:20210531 for:修改集群模式下未设置redis密码的bug issues/I3QNIC
|
|
|
- if (oConvertUtils.isNotEmpty(lettuceConnectionFactory.getPassword())) {
|
|
|
- JedisCluster jedisCluster = new JedisCluster(portSet, 2000, 2000, 5,
|
|
|
- lettuceConnectionFactory.getPassword(), new GenericObjectPoolConfig());
|
|
|
- redisManager.setPassword(lettuceConnectionFactory.getPassword());
|
|
|
- redisManager.setJedisCluster(jedisCluster);
|
|
|
- } else {
|
|
|
- JedisCluster jedisCluster = new JedisCluster(portSet);
|
|
|
- redisManager.setJedisCluster(jedisCluster);
|
|
|
- }
|
|
|
- //update-end--Author:scott Date:20210531 for:修改集群模式下未设置redis密码的bug issues/I3QNIC
|
|
|
- manager = redisManager;
|
|
|
+ public RedisManager redisManager() {
|
|
|
+ RedisManager redisManager = new RedisManager();
|
|
|
+ redisManager.setHost(host);
|
|
|
+ redisManager.setPort(oConvertUtils.getInt(port));
|
|
|
+ redisManager.setTimeout(0);
|
|
|
+ if (!StringUtils.isEmpty(redisPassword)) {
|
|
|
+ redisManager.setPassword(redisPassword);
|
|
|
}
|
|
|
- return manager;
|
|
|
+ return redisManager;
|
|
|
}
|
|
|
-
|
|
|
}
|