检查登录
This commit is contained in:
@@ -43,7 +43,7 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
||||
userConfig.setIsShare(true);
|
||||
// config2.setTimeout(2000);
|
||||
userConfig.setTokenStyle("simple-uuid");
|
||||
MyStpLogic.CLIENT_LOGIC.setConfig(userConfig);
|
||||
MyStpLogic.USER_LOGIC.setConfig(userConfig);
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
@@ -62,21 +62,25 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
||||
// 重置根路径,防止satoken切割根路径导致匹配不到路径
|
||||
ApplicationInfo.routePrefix = "";
|
||||
|
||||
SaRouter.match("/user/**").notMatch("/user/login", "/user/test", "/user/geo/**", "/user/home/**", "/user/home/**", "/user/dict/**", "/user/openId")
|
||||
.notMatch("/pay/**")
|
||||
.notMatch("/notify/**")
|
||||
.check(r -> MyStpLogic.CLIENT_LOGIC.checkLogin())
|
||||
.setHit(true)
|
||||
// .match("/**")
|
||||
.notMatch("/user/**")
|
||||
.notMatch("/pay/**")
|
||||
.notMatch("/notify/**")
|
||||
.notMatch("/admin/auth/**")
|
||||
.notMatch("/admin/shopMsgPush/subscribe/**")
|
||||
.notMatch("/admin/coupon/grant")
|
||||
SaRouter
|
||||
// 完全开放的路径(不需要任何认证)
|
||||
.match("/user/login", "/user/geo/**", "/user/home/**",
|
||||
"/user/dict/**", "/user/openId","/admin/auth/**",
|
||||
"/admin/shopMsgPush/subscribe/**",
|
||||
"/admin/coupon/grant",
|
||||
"/pay/**",
|
||||
"/notify/**")
|
||||
.stop() // 直接放行,不检查登录
|
||||
|
||||
// 用户认证路径
|
||||
.match("/user/**")
|
||||
.check(r -> MyStpLogic.USER_LOGIC.checkLogin())
|
||||
|
||||
// 管理端认证(内网IP免认证)
|
||||
.match("/**")
|
||||
.check(r -> {
|
||||
ServletRequestAttributes attributes =
|
||||
(ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes)
|
||||
RequestContextHolder.getRequestAttributes();
|
||||
if (attributes == null || (!ServletUtil.getClientIP(attributes.getRequest()).contains("192.168") && !ServletUtil.getClientIP(attributes.getRequest()).contains("127.0.0.1"))) {
|
||||
MyStpLogic.ADMIN_LOGIC.checkLogin();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.util.function.Consumer;
|
||||
@Slf4j
|
||||
@Getter
|
||||
public class MyStpLogic {
|
||||
public static final StpLogic CLIENT_LOGIC = new StpLogic("client");
|
||||
public static final StpLogic USER_LOGIC = new StpLogic("user");
|
||||
public static final StpLogic ADMIN_LOGIC = new StpLogic("admin");
|
||||
|
||||
public Object isPC() {
|
||||
@@ -42,7 +42,7 @@ public class MyStpLogic {
|
||||
private StpLogic getLogic() {
|
||||
boolean hit = SaRouter.match("/user/**").isHit();
|
||||
if (hit) {
|
||||
return CLIENT_LOGIC;
|
||||
return USER_LOGIC;
|
||||
}
|
||||
return ADMIN_LOGIC;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user