|
@@ -23,7 +23,8 @@ import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
import org.springframework.context.annotation.DependsOn;
|
|
|
|
|
|
-import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@Configuration
|
|
@@ -141,39 +142,23 @@ public class ShiroConfig {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 过滤器链
|
|
|
- */
|
|
|
- private Map<String, String> filterChainDefinition() {
|
|
|
- Map<String, String> map = MapUtil.newHashMap(20, true);
|
|
|
- map.put("/static/**", "anon");
|
|
|
- map.put("/v1/test/**", "anon");
|
|
|
- map.put("/v1/login", "anon");
|
|
|
- map.put("/v1/rsa-key", "anon");
|
|
|
- map.put("/v1/**", "anon");
|
|
|
- map.put("/**", "anon");
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
-// @Bean
|
|
|
-// public JwtContext jwtUtil() {
|
|
|
-// return new JwtContext(this.properties);
|
|
|
-// }
|
|
|
-
|
|
|
- private Map<String, Filter> filterMap() {
|
|
|
- HashMap<String, Filter> map = MapUtil.newHashMap();
|
|
|
- map.put("jwt", new JwtFilter(this.properties, this.jwtContext));
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* Shiro过滤器
|
|
|
*/
|
|
|
@Bean("shiroFilter")
|
|
|
public ShiroFilterFactoryBean shiroFilterFactoryBean() {
|
|
|
ShiroFilterFactoryBean shiroFilter = new ShiroFilterFactoryBean();
|
|
|
shiroFilter.setSecurityManager(this.defaultWebSecurityManager());
|
|
|
- shiroFilter.setFilters(this.filterMap());
|
|
|
- shiroFilter.setFilterChainDefinitionMap(this.filterChainDefinition());
|
|
|
+ // 新增过滤器
|
|
|
+ Map<String, Filter> filterMap = MapUtil.newHashMap(true);
|
|
|
+ filterMap.put("jwt", new JwtFilter(this.jwtContext));
|
|
|
+ shiroFilter.setFilters(filterMap);
|
|
|
+ // 过滤器链配置
|
|
|
+ Map<String, String> filterChainMap = MapUtil.newHashMap(16, true);
|
|
|
+ List<DaqProperties.FilterChain> shiroFilterChain = this.properties.getShiroFilterChain();
|
|
|
+ for (DaqProperties.FilterChain filterChain : shiroFilterChain) {
|
|
|
+ filterChainMap.put(filterChain.getPath(), String.join(",", filterChain.getFilters()));
|
|
|
+ }
|
|
|
+ shiroFilter.setFilterChainDefinitionMap(filterChainMap);
|
|
|
// 去掉,防止404路由自动跳转到登录请求
|
|
|
// shiroFilter.setLoginUrl("/v1/login");
|
|
|
// shiroFilter.setUnauthorizedUrl("/v1/login");
|