mirror of
https://gitee.com/dromara/sa-token.git
synced 2025-09-19 01:58:05 +08:00
新增 SaIgnore 忽略鉴权注解
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package cn.dev33.satoken.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 忽略认证:表示被修饰的方法或类无需进行注解认证和路由拦截认证
|
||||
*
|
||||
* <h2> 请注意:此注解的忽略效果只针对 SaInterceptor拦截器 和 APO注解鉴权 生效,对自定义拦截器与过滤器不生效 </h2>
|
||||
*
|
||||
* @author kong
|
||||
* @since: 2022-8-21
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ ElementType.METHOD, ElementType.TYPE })
|
||||
public @interface SaIgnore {
|
||||
|
||||
}
|
@@ -15,6 +15,7 @@ import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.annotation.SaCheckRole;
|
||||
import cn.dev33.satoken.annotation.SaCheckSafe;
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import cn.dev33.satoken.basic.SaBasicUtil;
|
||||
import cn.dev33.satoken.session.SaSession;
|
||||
import cn.dev33.satoken.util.SaFoxUtil;
|
||||
@@ -179,6 +180,16 @@ public final class SaStrategy {
|
||||
return element.getAnnotation(annotationClass);
|
||||
};
|
||||
|
||||
/**
|
||||
* 判断一个 Method 或其所属 Class 是否包含指定注解
|
||||
*
|
||||
* <p> 参数 [Method, 注解]
|
||||
*/
|
||||
public BiFunction<Method, AnnotatedElement, Boolean> isAnnotationPresent = (method, annotationClass) -> {
|
||||
return me.getAnnotation.apply(method, SaIgnore.class) != null ||
|
||||
me.getAnnotation.apply(method.getDeclaringClass(), SaIgnore.class) != null;
|
||||
};
|
||||
|
||||
/**
|
||||
* 拼接两个url
|
||||
* <p> 例如:url1=http://domain.cn,url2=/sso/auth,则返回:http://domain.cn/sso/auth
|
||||
|
Reference in New Issue
Block a user