|
|
|
@ -3,16 +3,11 @@ package cn.dev33.satoken.context.dubbo.filter;
|
|
|
|
|
import cn.dev33.satoken.SaManager;
|
|
|
|
|
import cn.dev33.satoken.id.SaIdUtil;
|
|
|
|
|
import cn.dev33.satoken.spring.SaBeanInject;
|
|
|
|
|
import cn.hutool.core.annotation.AnnotationUtil;
|
|
|
|
|
import com.ruoyi.common.core.annotation.InnerExclude;
|
|
|
|
|
import com.ruoyi.common.core.utils.SpringUtils;
|
|
|
|
|
import lombok.SneakyThrows;
|
|
|
|
|
import org.apache.dubbo.common.constants.CommonConstants;
|
|
|
|
|
import org.apache.dubbo.common.extension.Activate;
|
|
|
|
|
import org.apache.dubbo.rpc.*;
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* Sa-Token 整合 Dubbo Provider端过滤器
|
|
|
|
@ -25,7 +20,6 @@ import java.lang.reflect.Method;
|
|
|
|
|
@Activate(group = {CommonConstants.PROVIDER}, order = Integer.MIN_VALUE)
|
|
|
|
|
public class SaTokenDubboProviderFilter implements Filter {
|
|
|
|
|
|
|
|
|
|
@SneakyThrows(NoSuchMethodException.class)
|
|
|
|
|
@Override
|
|
|
|
|
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
|
|
|
|
|
// 强制初始化 Sa-Token 相关配置 解决内网鉴权元数据加载报错问题
|
|
|
|
@ -33,15 +27,6 @@ public class SaTokenDubboProviderFilter implements Filter {
|
|
|
|
|
|
|
|
|
|
// RPC 调用鉴权
|
|
|
|
|
if(SaManager.getConfig().getCheckIdToken()) {
|
|
|
|
|
|
|
|
|
|
Class<?> clazz = invoker.getInterface();
|
|
|
|
|
Method method = clazz.getMethod(invocation.getMethodName(), invocation.getParameterTypes());
|
|
|
|
|
// 检查是否有内网鉴权排除注解
|
|
|
|
|
if (AnnotationUtil.hasAnnotation(clazz, InnerExclude.class)
|
|
|
|
|
|| AnnotationUtil.hasAnnotation(method, InnerExclude.class)) {
|
|
|
|
|
return invoker.invoke(invocation);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String idToken = invocation.getAttachment(SaIdUtil.ID_TOKEN);
|
|
|
|
|
SaIdUtil.checkToken(idToken);
|
|
|
|
|
}
|
|
|
|
|