update 优化 Sa-Token 拦截器注册 SaTokenConfig#addInterceptors 排除拦截路径配置, 优化说明 ;
This commit is contained in:
parent
91c99d305c
commit
9e7141f97c
@ -34,13 +34,13 @@ public class SaTokenConfig implements WebMvcConfigurer {
|
|||||||
public void addInterceptors(InterceptorRegistry registry) {
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
// 注册路由拦截器,自定义验证规则
|
// 注册路由拦截器,自定义验证规则
|
||||||
registry.addInterceptor(new SaInterceptor(handler -> {
|
registry.addInterceptor(new SaInterceptor(handler -> {
|
||||||
|
// 自定义注解 @Anonymous 匿名访问配置,后续版本将删除
|
||||||
ExcludeUrlProperties excludeUrlProperties = SpringUtils.getBean(ExcludeUrlProperties.class);
|
ExcludeUrlProperties excludeUrlProperties = SpringUtils.getBean(ExcludeUrlProperties.class);
|
||||||
// 登录验证 -- 排除多个路径
|
// 登录验证 -- 排除多个路径
|
||||||
SaRouter
|
SaRouter
|
||||||
// 获取所有的
|
// 获取所有的
|
||||||
.match("/**")
|
.match("/**")
|
||||||
// 排除下不需要拦截的
|
// 排除下不需要拦截的(每次匹配)
|
||||||
.notMatch(securityProperties.getExcludes())
|
|
||||||
.notMatch(excludeUrlProperties.getExcludes())
|
.notMatch(excludeUrlProperties.getExcludes())
|
||||||
// 对未排除的路径进行检查
|
// 对未排除的路径进行检查
|
||||||
.check(() -> {
|
.check(() -> {
|
||||||
@ -54,7 +54,9 @@ public class SaTokenConfig implements WebMvcConfigurer {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
});
|
});
|
||||||
})).addPathPatterns("/**");
|
})).addPathPatterns("/**")
|
||||||
|
// 排除不需要拦截的路径
|
||||||
|
.excludePathPatterns(securityProperties.getExcludes());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
Loading…
x
Reference in New Issue
Block a user