mirror of
https://gitee.com/dromara/RuoYi-Cloud-Plus.git
synced 2025-09-06 04:18:07 +00:00
reset 回滚 InnerExclude 注解相关提交 错误的理解了功能
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
package com.ruoyi.common.core.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* dubbo 内网鉴权放行
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Inherited
|
||||
@Target({ElementType.METHOD, ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface InnerExclude {
|
||||
}
|
@@ -6,16 +6,11 @@ import cn.dev33.satoken.id.SaIdUtil;
|
||||
import cn.dev33.satoken.spring.SaBeanInject;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.dev33.satoken.util.SaTokenConsts;
|
||||
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 Consumer端过滤器
|
||||
@@ -28,7 +23,6 @@ import java.lang.reflect.Method;
|
||||
@Activate(group = {CommonConstants.CONSUMER}, order = Integer.MIN_VALUE)
|
||||
public class SaTokenDubboConsumerFilter implements Filter {
|
||||
|
||||
@SneakyThrows(NoSuchMethodException.class)
|
||||
@Override
|
||||
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
|
||||
// 强制初始化 Sa-Token 相关配置 解决内网鉴权元数据加载报错问题
|
||||
@@ -36,16 +30,7 @@ public class SaTokenDubboConsumerFilter implements Filter {
|
||||
|
||||
// 追加 Id-Token 参数
|
||||
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)) {
|
||||
// 不传递 Id-Token
|
||||
} else {
|
||||
RpcContext.getServiceContext().setAttachment(SaIdUtil.ID_TOKEN, SaIdUtil.getToken());
|
||||
}
|
||||
|
||||
RpcContext.getServiceContext().setAttachment(SaIdUtil.ID_TOKEN, SaIdUtil.getToken());
|
||||
}
|
||||
|
||||
// 1. 调用前,向下传递会话Token
|
||||
|
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user