|
@@ -1,8 +1,11 @@
|
|
|
package com.singularity.config;
|
|
|
|
|
|
import cn.dev33.satoken.config.SaTokenConfig;
|
|
|
+import cn.dev33.satoken.interceptor.SaInterceptor;
|
|
|
import cn.dev33.satoken.jwt.StpLogicJwtForSimple;
|
|
|
+import cn.dev33.satoken.router.SaRouter;
|
|
|
import cn.dev33.satoken.stp.StpLogic;
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
@@ -19,7 +22,7 @@ public class WebConfig implements WebMvcConfigurer {
|
|
|
|
|
|
private static final String[] EXCLUDE_PATH_PATTERNS = {
|
|
|
// Swagger
|
|
|
- "**/swagger-ui.html",
|
|
|
+ "**/doc.html",
|
|
|
"/swagger-resources/**",
|
|
|
"/webjars/**",
|
|
|
"/v2/**",
|
|
@@ -73,22 +76,16 @@ public class WebConfig implements WebMvcConfigurer {
|
|
|
return config;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 注册拦截器
|
|
|
- * addInterceptor: 注册拦截器对象
|
|
|
- * addPathPatterns: 拦截的请求
|
|
|
- * excludePathPatgetPermissionListterns: 拦截白名单
|
|
|
- */
|
|
|
@Override
|
|
|
public void addInterceptors(InterceptorRegistry registry) {
|
|
|
// 注册 Sa-Token 拦截器,定义详细认证规则
|
|
|
-// registry.addInterceptor(new SaInterceptor(handler -> {
|
|
|
-// // 指定一条 match 规则
|
|
|
-// SaRouter.match("/**") // 拦截的 path 列表,可以写多个 */
|
|
|
-// .notMatch("/backstageLogin/password") // 排除掉的 path 列表,可以写多个
|
|
|
-// .notMatch(EXCLUDE_PATH_PATTERNS)
|
|
|
-// .check(r -> StpUtil.checkLogin()); // 要执行的校验动作,可以写完整的 lambda 表达式
|
|
|
-// })).addPathPatterns("/**");
|
|
|
+ registry.addInterceptor(new SaInterceptor(handler -> {
|
|
|
+ // 指定一条 match 规则
|
|
|
+ SaRouter.match("/**") // 拦截的 path 列表,可以写多个 */
|
|
|
+ .notMatch("/backstageLogin/password")// 排除掉的 path 列表,可以写多个
|
|
|
+ .notMatch(EXCLUDE_PATH_PATTERNS)
|
|
|
+ .check(r -> StpUtil.checkLogin()); // 要执行的校验动作,可以写完整的 lambda 表达式
|
|
|
+ })).addPathPatterns("/**");
|
|
|
}
|
|
|
|
|
|
/**
|