diff --git a/sa-token-dependencies/pom.xml b/sa-token-dependencies/pom.xml
index bf8b6ab2..5f6b3f09 100644
--- a/sa-token-dependencies/pom.xml
+++ b/sa-token-dependencies/pom.xml
@@ -24,7 +24,7 @@
6.0.0
3.0.9.RELEASE
1.12.2
- 1.4.4
+ 1.4.5
4.9.17
3.14.4
2.5.0
diff --git a/sa-token-plugin/sa-token-dao-redisx/README.md b/sa-token-plugin/sa-token-dao-redisx/README.md
index 3a73e3f2..95ccce2d 100644
--- a/sa-token-plugin/sa-token-dao-redisx/README.md
+++ b/sa-token-plugin/sa-token-dao-redisx/README.md
@@ -1,4 +1,6 @@
+sa-token-dao-redisx 是中立的扩展。可任何应用开发框架下使用(springboot, solon, jfinal 等..)
+
### 使用示例
#### 1.配置
@@ -9,6 +11,7 @@ sa-token-dao: #名字可以随意取
server: "localhost:6379"
password: 123456
db: 1
+# serializer: "org.noear.redisx.utils.SerializerJson" #指定自定义序列化实现(默认为 SerializerDefault)
```
#### 2.代码
diff --git a/sa-token-starter/sa-token-solon-plugin/src/main/java/cn/dev33/satoken/solon/integration/SaTokenFilter.java b/sa-token-starter/sa-token-solon-plugin/src/main/java/cn/dev33/satoken/solon/integration/SaTokenFilter.java
index 5d7d0f25..5ca220d1 100644
--- a/sa-token-starter/sa-token-solon-plugin/src/main/java/cn/dev33/satoken/solon/integration/SaTokenFilter.java
+++ b/sa-token-starter/sa-token-solon-plugin/src/main/java/cn/dev33/satoken/solon/integration/SaTokenFilter.java
@@ -171,29 +171,26 @@ public class SaTokenFilter implements Filter { //之所以改名,为了跟 SaT
try {
//查找当前主处理
Handler mainHandler = Solon.app().router().matchMain(ctx);
+ Action action = (mainHandler instanceof Action ? (Action) mainHandler : null);
- //如果是静态文件,则不处理(静态文件,不在路由中)
- if (mainHandler != null) {
- Action action = (mainHandler instanceof Action ? (Action) mainHandler : null);
+ //1.路径规则处理(包括了静态文件)
+ SaRouter.match(includeList).notMatch(excludeList).check(r -> {
+ beforeAuth.run(mainHandler);
+ auth.run(mainHandler);
+ });
- if (isAnnotation && action != null) {
- // 获取此请求对应的 Method 处理函数
- Method method = action.method().getMethod();
+ //2.验证注解处理
+ if (isAnnotation && action != null) {
+ // 获取此请求对应的 Method 处理函数
+ Method method = action.method().getMethod();
- // 如果此 Method 或其所属 Class 标注了 @SaIgnore,则忽略掉鉴权
- if (SaStrategy.me.isAnnotationPresent.apply(method, SaIgnore.class)) {
- return;
- }
-
- // 注解校验
- SaStrategy.me.checkMethodAnnotation.accept(method);
+ // 如果此 Method 或其所属 Class 标注了 @SaIgnore,则忽略掉鉴权
+ if (SaStrategy.me.isAnnotationPresent.apply(method, SaIgnore.class)) {
+ return;
}
- //路径规则处理
- SaRouter.match(includeList).notMatch(excludeList).check(r -> {
- beforeAuth.run(mainHandler);
- auth.run(mainHandler);
- });
+ // 注解校验
+ SaStrategy.me.checkMethodAnnotation.accept(method);
}
} catch (StopMatchException e) {
diff --git a/sa-token-starter/sa-token-solon-plugin/src/main/java/cn/dev33/satoken/solon/integration/SaTokenInterceptor.java b/sa-token-starter/sa-token-solon-plugin/src/main/java/cn/dev33/satoken/solon/integration/SaTokenInterceptor.java
index f16bd2a1..959586ad 100644
--- a/sa-token-starter/sa-token-solon-plugin/src/main/java/cn/dev33/satoken/solon/integration/SaTokenInterceptor.java
+++ b/sa-token-starter/sa-token-solon-plugin/src/main/java/cn/dev33/satoken/solon/integration/SaTokenInterceptor.java
@@ -170,29 +170,28 @@ public class SaTokenInterceptor implements RouterInterceptor {
@Override
public void doIntercept(Context ctx, Handler mainHandler, RouterInterceptorChain chain) throws Throwable {
try {
- //如果是静态文件,则不处理(静态文件,不在路由中)
- if (mainHandler != null) {
- Action action = (mainHandler instanceof Action ? (Action) mainHandler : null);
+ Action action = (mainHandler instanceof Action ? (Action) mainHandler : null);
- if (isAnnotation && action != null) {
- // 获取此请求对应的 Method 处理函数
- Method method = action.method().getMethod();
+ //1.路径规则处理
+ SaRouter.match(includeList).notMatch(excludeList).check(r -> {
+ beforeAuth.run(mainHandler);
+ auth.run(mainHandler);
+ });
- // 如果此 Method 或其所属 Class 标注了 @SaIgnore,则忽略掉鉴权
- if (SaStrategy.me.isAnnotationPresent.apply(method, SaIgnore.class)) {
- return;
- }
+ //2.验证注解处理
+ if (isAnnotation && action != null) {
+ // 获取此请求对应的 Method 处理函数
+ Method method = action.method().getMethod();
- // 注解校验
- SaStrategy.me.checkMethodAnnotation.accept(method);
+ // 如果此 Method 或其所属 Class 标注了 @SaIgnore,则忽略掉鉴权
+ if (SaStrategy.me.isAnnotationPresent.apply(method, SaIgnore.class)) {
+ return;
}
- //路径规则处理
- SaRouter.match(includeList).notMatch(excludeList).check(r -> {
- beforeAuth.run(mainHandler);
- auth.run(mainHandler);
- });
+ // 注解校验
+ SaStrategy.me.checkMethodAnnotation.accept(method);
}
+
} catch (StopMatchException e) {
} catch (SaTokenException e) {
diff --git a/sa-token-starter/sa-token-solon-plugin/src/main/java/cn/dev33/satoken/solon/integration/SaTokenPathFilter.java b/sa-token-starter/sa-token-solon-plugin/src/main/java/cn/dev33/satoken/solon/integration/SaTokenPathFilter.java
index b48bd23a..6d2285bb 100644
--- a/sa-token-starter/sa-token-solon-plugin/src/main/java/cn/dev33/satoken/solon/integration/SaTokenPathFilter.java
+++ b/sa-token-starter/sa-token-solon-plugin/src/main/java/cn/dev33/satoken/solon/integration/SaTokenPathFilter.java
@@ -1,222 +1,16 @@
package cn.dev33.satoken.solon.integration;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import org.noear.solon.Solon;
-import org.noear.solon.core.handle.Action;
-import org.noear.solon.core.handle.Context;
-import org.noear.solon.core.handle.Filter;
-import org.noear.solon.core.handle.FilterChain;
-import org.noear.solon.core.handle.Handler;
-
-import cn.dev33.satoken.annotation.SaIgnore;
-import cn.dev33.satoken.exception.BackResultException;
-import cn.dev33.satoken.exception.SaTokenException;
-import cn.dev33.satoken.exception.StopMatchException;
-import cn.dev33.satoken.filter.SaFilterAuthStrategy;
-import cn.dev33.satoken.filter.SaFilterErrorStrategy;
-import cn.dev33.satoken.router.SaRouter;
-import cn.dev33.satoken.solon.error.SaSolonErrorCode;
-import cn.dev33.satoken.strategy.SaStrategy;
+import org.noear.solon.annotation.Note;
/**
- * sa-token 基于路由的过滤式鉴权(增加了注解的处理);使用优先级要低些
+ * sa-token 基于路由的过滤式鉴权(增加了注解的处理);使用优先级要低些 //对静态文件有处理效果
*
* @author noear
* @since 1.10
*/
+@Note("推荐:由 SaTokenFilter 替代")
@Deprecated
-public class SaTokenPathFilter implements Filter {
- /**
- * 是否打开注解鉴权
- */
- public boolean isAnnotation = true;
+public class SaTokenPathFilter extends SaTokenFilter {
- // ------------------------ 设置此过滤器 拦截 & 放行 的路由
-
- /**
- * 拦截路由
- */
- protected List includeList = new ArrayList<>();
-
- /**
- * 放行路由
- */
- protected List excludeList = new ArrayList<>();
-
- /**
- * 添加 [拦截路由]
- *
- * @param paths 路由
- * @return 对象自身
- */
- public SaTokenPathFilter addInclude(String... paths) {
- includeList.addAll(Arrays.asList(paths));
- return this;
- }
-
- /**
- * 添加 [放行路由]
- *
- * @param paths 路由
- * @return 对象自身
- */
- public SaTokenPathFilter addExclude(String... paths) {
- excludeList.addAll(Arrays.asList(paths));
- return this;
- }
-
- /**
- * 写入 [拦截路由] 集合
- *
- * @param pathList 路由集合
- * @return 对象自身
- */
- public SaTokenPathFilter setIncludeList(List pathList) {
- includeList = pathList;
- return this;
- }
-
- /**
- * 写入 [放行路由] 集合
- *
- * @param pathList 路由集合
- * @return 对象自身
- */
- public SaTokenPathFilter setExcludeList(List pathList) {
- excludeList = pathList;
- return this;
- }
-
- /**
- * 获取 [拦截路由] 集合
- *
- * @return see note
- */
- public List getIncludeList() {
- return includeList;
- }
-
- /**
- * 获取 [放行路由] 集合
- *
- * @return see note
- */
- public List getExcludeList() {
- return excludeList;
- }
-
-
- // ------------------------ 钩子函数
-
- /**
- * 认证函数:每次请求执行
- */
- protected SaFilterAuthStrategy auth = r -> {
- };
-
- /**
- * 异常处理函数:每次[认证函数]发生异常时执行此函数
- */
- protected SaFilterErrorStrategy error = e -> {
- if (e instanceof SaTokenException) {
- throw (SaTokenException) e;
- } else {
- throw new SaTokenException(e).setCode(SaSolonErrorCode.CODE_20302);
- }
- };
-
- /**
- * 前置函数:在每次[认证函数]之前执行
- */
- protected SaFilterAuthStrategy beforeAuth = r -> {
- };
-
- /**
- * 写入[认证函数]: 每次请求执行
- *
- * @param auth see note
- * @return 对象自身
- */
- public SaTokenPathFilter setAuth(SaFilterAuthStrategy auth) {
- this.auth = auth;
- return this;
- }
-
- /**
- * 写入[异常处理函数]:每次[认证函数]发生异常时执行此函数
- *
- * @param error see note
- * @return 对象自身
- */
- public SaTokenPathFilter setError(SaFilterErrorStrategy error) {
- this.error = error;
- return this;
- }
-
- /**
- * 写入[前置函数]:在每次[认证函数]之前执行
- *
- * @param beforeAuth see note
- * @return 对象自身
- */
- public SaTokenPathFilter setBeforeAuth(SaFilterAuthStrategy beforeAuth) {
- this.beforeAuth = beforeAuth;
- return this;
- }
-
-
- @Override
- public void doFilter(Context ctx, FilterChain chain) throws Throwable {
- try {
- //查找当前主处理
- Handler mainHandler = Solon.app().router().matchMain(ctx);
-
- //如果是静态文件,则不处理(静态文件,不在路由中)
- if (mainHandler != null) {
- Action action = (mainHandler instanceof Action ? (Action) mainHandler : null);
-
- if (isAnnotation && action != null) {
- // 获取此请求对应的 Method 处理函数
- Method method = action.method().getMethod();
-
- // 如果此 Method 或其所属 Class 标注了 @SaIgnore,则忽略掉鉴权
- if (SaStrategy.me.isAnnotationPresent.apply(method, SaIgnore.class)) {
- return;
- }
-
- // 注解校验
- SaStrategy.me.checkMethodAnnotation.accept(method);
- }
-
- //路径规则处理
- SaRouter.match(includeList).notMatch(excludeList).check(r -> {
- beforeAuth.run(mainHandler);
- auth.run(mainHandler);
- });
- }
- } catch (StopMatchException e) {
-
- } catch (SaTokenException e) {
- // 1. 获取异常处理策略结果
- Object result;
- if (e instanceof BackResultException) {
- result = e.getMessage();
- } else {
- result = error.run(e);
- }
-
- // 2. 写入输出流
- if (result != null) {
- ctx.render(result);
- }
- ctx.setHandled(true);
- return;
- }
-
- chain.doFilter(ctx);
- }
}
diff --git a/sa-token-starter/sa-token-solon-plugin/src/main/java/cn/dev33/satoken/solon/integration/SaTokenPathInterceptor.java b/sa-token-starter/sa-token-solon-plugin/src/main/java/cn/dev33/satoken/solon/integration/SaTokenPathInterceptor.java
index 2e5fb944..32ab24a1 100644
--- a/sa-token-starter/sa-token-solon-plugin/src/main/java/cn/dev33/satoken/solon/integration/SaTokenPathInterceptor.java
+++ b/sa-token-starter/sa-token-solon-plugin/src/main/java/cn/dev33/satoken/solon/integration/SaTokenPathInterceptor.java
@@ -7,8 +7,8 @@ import cn.dev33.satoken.exception.StopMatchException;
import cn.dev33.satoken.filter.SaFilterAuthStrategy;
import cn.dev33.satoken.filter.SaFilterErrorStrategy;
import cn.dev33.satoken.router.SaRouter;
-import cn.dev33.satoken.solon.error.SaSolonErrorCode;
import cn.dev33.satoken.strategy.SaStrategy;
+import org.noear.solon.annotation.Note;
import org.noear.solon.core.handle.Action;
import org.noear.solon.core.handle.Context;
import org.noear.solon.core.handle.Handler;
@@ -24,6 +24,7 @@ import java.util.List;
* @author noear
* @since 1.10
*/
+@Note("推荐:由 SaTokenInterceptor 替代")
@Deprecated
public class SaTokenPathInterceptor implements Handler {
/**
@@ -121,7 +122,7 @@ public class SaTokenPathInterceptor implements Handler {
if (e instanceof SaTokenException) {
throw (SaTokenException) e;
} else {
- throw new SaTokenException(e).setCode(SaSolonErrorCode.CODE_20301);
+ throw new SaTokenException(e);
}
};
@@ -168,9 +169,15 @@ public class SaTokenPathInterceptor implements Handler {
@Override
public void handle(Context ctx) throws Throwable {
try {
- //注处处理
Action action = ctx.action();
+ //1.路径规则处理
+ SaRouter.match(includeList).notMatch(excludeList).check(r -> {
+ beforeAuth.run(action);
+ auth.run(action);
+ });
+
+ //2.验证注解处理
if(isAnnotation && action != null){
// 获取此请求对应的 Method 处理函数
Method method = action.method().getMethod();
@@ -183,13 +190,6 @@ public class SaTokenPathInterceptor implements Handler {
// 注解校验
SaStrategy.me.checkMethodAnnotation.accept(method);
}
-
- //路径规则处理
- SaRouter.match(includeList).notMatch(excludeList).check(r -> {
- beforeAuth.run(action);
- auth.run(action);
- });
-
} catch (StopMatchException e) {
} catch (SaTokenException e) {