mirror of
https://gitee.com/dromara/sa-token.git
synced 2026-05-14 12:52:08 +08:00
sa-token-solon-plugin: 优化集成处理逻辑
This commit is contained in:
@@ -1,11 +1,5 @@
|
|||||||
package cn.dev33.satoken.solon;
|
package cn.dev33.satoken.solon;
|
||||||
|
|
||||||
import cn.dev33.satoken.solon.oauth2.SaOAuth2AutoConfigure;
|
|
||||||
import cn.dev33.satoken.solon.sso.SaSsoAutoConfigure;
|
|
||||||
import org.noear.solon.Solon;
|
|
||||||
import org.noear.solon.core.AopContext;
|
|
||||||
import org.noear.solon.core.Plugin;
|
|
||||||
|
|
||||||
import cn.dev33.satoken.SaManager;
|
import cn.dev33.satoken.SaManager;
|
||||||
import cn.dev33.satoken.basic.SaBasicTemplate;
|
import cn.dev33.satoken.basic.SaBasicTemplate;
|
||||||
import cn.dev33.satoken.basic.SaBasicUtil;
|
import cn.dev33.satoken.basic.SaBasicUtil;
|
||||||
@@ -19,10 +13,15 @@ import cn.dev33.satoken.log.SaLog;
|
|||||||
import cn.dev33.satoken.same.SaSameTemplate;
|
import cn.dev33.satoken.same.SaSameTemplate;
|
||||||
import cn.dev33.satoken.sign.SaSignTemplate;
|
import cn.dev33.satoken.sign.SaSignTemplate;
|
||||||
import cn.dev33.satoken.solon.model.SaContextForSolon;
|
import cn.dev33.satoken.solon.model.SaContextForSolon;
|
||||||
|
import cn.dev33.satoken.solon.oauth2.SaOAuth2AutoConfigure;
|
||||||
|
import cn.dev33.satoken.solon.sso.SaSsoAutoConfigure;
|
||||||
import cn.dev33.satoken.stp.StpInterface;
|
import cn.dev33.satoken.stp.StpInterface;
|
||||||
import cn.dev33.satoken.stp.StpLogic;
|
import cn.dev33.satoken.stp.StpLogic;
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
import cn.dev33.satoken.temp.SaTempInterface;
|
import cn.dev33.satoken.temp.SaTempInterface;
|
||||||
|
import org.noear.solon.Solon;
|
||||||
|
import org.noear.solon.core.AopContext;
|
||||||
|
import org.noear.solon.core.Plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author noear
|
* @author noear
|
||||||
|
|||||||
@@ -180,9 +180,10 @@ public class SaTokenFilter implements Filter { //之所以改名,为了跟 SaT
|
|||||||
beforeAuth.run(mainHandler);
|
beforeAuth.run(mainHandler);
|
||||||
}
|
}
|
||||||
//2.执行注解处理
|
//2.执行注解处理
|
||||||
authAnno(action);
|
if(authAnno(action)) {
|
||||||
//3.执行规则处理
|
//3.执行规则处理(如果没有被 @SaIgnore 忽略)
|
||||||
auth.run(mainHandler);
|
auth.run(mainHandler);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} catch (StopMatchException e) {
|
} catch (StopMatchException e) {
|
||||||
|
|
||||||
@@ -206,7 +207,7 @@ public class SaTokenFilter implements Filter { //之所以改名,为了跟 SaT
|
|||||||
chain.doFilter(ctx);
|
chain.doFilter(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void authAnno(Action action) {
|
private boolean authAnno(Action action) {
|
||||||
//2.验证注解处理
|
//2.验证注解处理
|
||||||
if (isAnnotation && action != null) {
|
if (isAnnotation && action != null) {
|
||||||
// 获取此请求对应的 Method 处理函数
|
// 获取此请求对应的 Method 处理函数
|
||||||
@@ -214,11 +215,13 @@ public class SaTokenFilter implements Filter { //之所以改名,为了跟 SaT
|
|||||||
|
|
||||||
// 如果此 Method 或其所属 Class 标注了 @SaIgnore,则忽略掉鉴权
|
// 如果此 Method 或其所属 Class 标注了 @SaIgnore,则忽略掉鉴权
|
||||||
if (SaStrategy.me.isAnnotationPresent.apply(method, SaIgnore.class)) {
|
if (SaStrategy.me.isAnnotationPresent.apply(method, SaIgnore.class)) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 注解校验
|
// 注解校验
|
||||||
SaStrategy.me.checkMethodAnnotation.accept(method);
|
SaStrategy.me.checkMethodAnnotation.accept(method);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -179,9 +179,10 @@ public class SaTokenInterceptor implements RouterInterceptor {
|
|||||||
beforeAuth.run(mainHandler);
|
beforeAuth.run(mainHandler);
|
||||||
}
|
}
|
||||||
//2.执行注解处理
|
//2.执行注解处理
|
||||||
authAnno(action);
|
if(authAnno(action)) {
|
||||||
//3.执行规则处理
|
//3.执行规则处理(如果没有被 @SaIgnore 忽略)
|
||||||
auth.run(mainHandler);
|
auth.run(mainHandler);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
} catch (StopMatchException e) {
|
} catch (StopMatchException e) {
|
||||||
@@ -206,7 +207,7 @@ public class SaTokenInterceptor implements RouterInterceptor {
|
|||||||
chain.doIntercept(ctx, mainHandler);
|
chain.doIntercept(ctx, mainHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void authAnno(Action action) {
|
private boolean authAnno(Action action) {
|
||||||
//2.验证注解处理
|
//2.验证注解处理
|
||||||
if (isAnnotation && action != null) {
|
if (isAnnotation && action != null) {
|
||||||
// 获取此请求对应的 Method 处理函数
|
// 获取此请求对应的 Method 处理函数
|
||||||
@@ -214,11 +215,13 @@ public class SaTokenInterceptor implements RouterInterceptor {
|
|||||||
|
|
||||||
// 如果此 Method 或其所属 Class 标注了 @SaIgnore,则忽略掉鉴权
|
// 如果此 Method 或其所属 Class 标注了 @SaIgnore,则忽略掉鉴权
|
||||||
if (SaStrategy.me.isAnnotationPresent.apply(method, SaIgnore.class)) {
|
if (SaStrategy.me.isAnnotationPresent.apply(method, SaIgnore.class)) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 注解校验
|
// 注解校验
|
||||||
SaStrategy.me.checkMethodAnnotation.accept(method);
|
SaStrategy.me.checkMethodAnnotation.accept(method);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user