mirror of
				https://github.com/dromara/RuoYi-Vue-Plus.git
				synced 2025-11-04 16:23:42 +08:00 
			
		
		
		
	!238 【轻量级 PR】优化 Sa-Token 拦截器排除配置
Merge pull request !238 from MichelleChung/dev
This commit is contained in:
		@@ -34,13 +34,13 @@ public class SaTokenConfig implements WebMvcConfigurer {
 | 
			
		||||
    public void addInterceptors(InterceptorRegistry registry) {
 | 
			
		||||
        // 注册路由拦截器,自定义验证规则
 | 
			
		||||
        registry.addInterceptor(new SaInterceptor(handler -> {
 | 
			
		||||
            // 自定义注解 @Anonymous 匿名访问配置,后续版本将删除
 | 
			
		||||
            ExcludeUrlProperties excludeUrlProperties = SpringUtils.getBean(ExcludeUrlProperties.class);
 | 
			
		||||
            // 登录验证 -- 排除多个路径
 | 
			
		||||
            SaRouter
 | 
			
		||||
                // 获取所有的
 | 
			
		||||
                .match("/**")
 | 
			
		||||
                // 排除下不需要拦截的
 | 
			
		||||
                .notMatch(securityProperties.getExcludes())
 | 
			
		||||
                // 排除下不需要拦截的(每次匹配)
 | 
			
		||||
                .notMatch(excludeUrlProperties.getExcludes())
 | 
			
		||||
                // 对未排除的路径进行检查
 | 
			
		||||
                .check(() -> {
 | 
			
		||||
@@ -54,7 +54,9 @@ public class SaTokenConfig implements WebMvcConfigurer {
 | 
			
		||||
                    // }
 | 
			
		||||
 | 
			
		||||
                });
 | 
			
		||||
        })).addPathPatterns("/**");
 | 
			
		||||
        })).addPathPatterns("/**")
 | 
			
		||||
            // 排除不需要拦截的路径
 | 
			
		||||
            .excludePathPatterns(securityProperties.getExcludes());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Bean
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user