|
@@ -1,8 +1,11 @@
|
|
package com.flyer.foster.config;
|
|
package com.flyer.foster.config;
|
|
|
|
|
|
|
|
+import cn.dev33.satoken.context.SaHolder;
|
|
|
|
+import cn.dev33.satoken.context.model.SaRequest;
|
|
import cn.dev33.satoken.interceptor.SaInterceptor;
|
|
import cn.dev33.satoken.interceptor.SaInterceptor;
|
|
import cn.dev33.satoken.router.SaRouter;
|
|
import cn.dev33.satoken.router.SaRouter;
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
|
+import com.flyer.foster.pojo.CheckUtil;
|
|
import com.flyer.foster.pojo.StpAppUtil;
|
|
import com.flyer.foster.pojo.StpAppUtil;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
@@ -21,13 +24,26 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
|
public void addInterceptors(InterceptorRegistry registry) {
|
|
public void addInterceptors(InterceptorRegistry registry) {
|
|
// 注册 Sa-Token 拦截器,打开注解式鉴权功能
|
|
// 注册 Sa-Token 拦截器,打开注解式鉴权功能
|
|
registry.addInterceptor(new SaInterceptor(handler -> {
|
|
registry.addInterceptor(new SaInterceptor(handler -> {
|
|
|
|
+ SaRequest request = SaHolder.getRequest();
|
|
SaRouter.match("/admin/**")
|
|
SaRouter.match("/admin/**")
|
|
.notMatch("/admin/user/login", "/admin/user/generate-key")
|
|
.notMatch("/admin/user/login", "/admin/user/generate-key")
|
|
- .check(r -> StpUtil.checkLogin());
|
|
|
|
|
|
+ .check(r -> {
|
|
|
|
+ String key = request.getParam("key");
|
|
|
|
+ if(CheckUtil.isKey(key)){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ StpUtil.checkLogin();
|
|
|
|
+ });
|
|
|
|
|
|
SaRouter.match("/app/**")
|
|
SaRouter.match("/app/**")
|
|
.notMatch("/app/user/login")
|
|
.notMatch("/app/user/login")
|
|
- .check(r -> StpAppUtil.checkLogin());
|
|
|
|
|
|
+ .check(r -> {
|
|
|
|
+ String key = request.getParam("key");
|
|
|
|
+ if(CheckUtil.isKey(key)){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ StpAppUtil.checkLogin();
|
|
|
|
+ });
|
|
|
|
|
|
|
|
|
|
})).addPathPatterns("/**");
|
|
})).addPathPatterns("/**");
|