mirror of
https://gitee.com/dromara/sa-token.git
synced 2025-09-18 17:48:03 +08:00
新增 SaCheckOr 注解,批量注解鉴权:只要满足其中一个注解即可通过验证
This commit is contained in:
@@ -398,7 +398,7 @@ public class SaOAuth2Template {
|
||||
|
||||
// 3、是否在[允许地址列表]之中
|
||||
List<String> allowList = SaFoxUtil.convertStringToList(checkClientModel(clientId).allowUrl);
|
||||
if( ! SaStrategy.me.hasElement.apply(allowList, url)) {
|
||||
if( ! SaStrategy.instance.hasElement.apply(allowList, url)) {
|
||||
throw new SaOAuth2Exception("非法redirect_url:" + url).setCode(SaOAuth2ErrorCode.CODE_30114);
|
||||
}
|
||||
}
|
||||
|
@@ -64,7 +64,7 @@ public class SaTokenDaoRedisFastjson implements SaTokenDao {
|
||||
}
|
||||
|
||||
// 重写 SaSession 生成策略
|
||||
SaStrategy.me.createSession = (sessionId) -> new SaSessionForFastjsonCustomized(sessionId);
|
||||
SaStrategy.instance.createSession = (sessionId) -> new SaSessionForFastjsonCustomized(sessionId);
|
||||
|
||||
// 指定相应的序列化方案
|
||||
StringRedisSerializer keySerializer = new StringRedisSerializer();
|
||||
|
@@ -64,7 +64,7 @@ public class SaTokenDaoRedisFastjson2 implements SaTokenDao {
|
||||
}
|
||||
|
||||
// 重写 SaSession 生成策略
|
||||
SaStrategy.me.createSession = (sessionId) -> new SaSessionForFastjson2Customized(sessionId);
|
||||
SaStrategy.instance.createSession = (sessionId) -> new SaSessionForFastjson2Customized(sessionId);
|
||||
|
||||
// 指定相应的序列化方案
|
||||
StringRedisSerializer keySerializer = new StringRedisSerializer();
|
||||
|
@@ -127,7 +127,7 @@ public class SaTokenDaoRedisJackson implements SaTokenDao {
|
||||
this.objectMapper.registerModule(timeModule);
|
||||
|
||||
// 重写 SaSession 生成策略
|
||||
SaStrategy.me.createSession = (sessionId) -> new SaSessionForJacksonCustomized(sessionId);
|
||||
SaStrategy.instance.createSession = (sessionId) -> new SaSessionForJacksonCustomized(sessionId);
|
||||
} catch (Exception e) {
|
||||
System.err.println(e.getMessage());
|
||||
}
|
||||
|
@@ -120,7 +120,7 @@ public class SaTokenDaoRedissonJackson implements SaTokenDao {
|
||||
timeModule.addDeserializer(LocalTime.class, new LocalTimeDeserializer(TIME_FORMATTER));
|
||||
this.objectMapper.registerModule(timeModule);
|
||||
// 重写 SaSession 生成策略
|
||||
SaStrategy.me.createSession = (sessionId) -> new SaSessionForJacksonCustomized(sessionId);
|
||||
SaStrategy.instance.createSession = (sessionId) -> new SaSessionForJacksonCustomized(sessionId);
|
||||
} catch (Exception e) {
|
||||
System.err.println(e.getMessage());
|
||||
}
|
||||
|
@@ -44,7 +44,7 @@ public class SaTokenDaoOfRedisJson implements SaTokenDao {
|
||||
redisBucket = redisClient.getBucket();
|
||||
|
||||
// 重写 SaSession 生成策略
|
||||
SaStrategy.me.createSession = (sessionId) -> new SaSessionForJson(sessionId);
|
||||
SaStrategy.instance.createSession = (sessionId) -> new SaSessionForJson(sessionId);
|
||||
|
||||
}
|
||||
|
||||
|
@@ -83,11 +83,11 @@ public class SaCheckAspect {
|
||||
Method method = signature.getMethod();
|
||||
|
||||
// 如果此 Method 或其所属 Class 标注了 @SaIgnore,则忽略掉鉴权
|
||||
if(SaStrategy.me.isAnnotationPresent.apply(method, SaIgnore.class)) {
|
||||
if(SaStrategy.instance.isAnnotationPresent.apply(method, SaIgnore.class)) {
|
||||
// ...
|
||||
} else {
|
||||
// 注解鉴权
|
||||
SaStrategy.me.checkMethodAnnotation.accept(method);
|
||||
SaStrategy.instance.checkMethodAnnotation.accept(method);
|
||||
}
|
||||
|
||||
// 执行原有逻辑
|
||||
|
@@ -283,7 +283,7 @@ public class SaSsoTemplate {
|
||||
|
||||
// 3、是否在[允许地址列表]之中
|
||||
List<String> authUrlList = Arrays.asList(getAllowUrl().replaceAll(" ", "").split(","));
|
||||
if( ! SaStrategy.me.hasElement.apply(authUrlList, url) ) {
|
||||
if( ! SaStrategy.instance.hasElement.apply(authUrlList, url) ) {
|
||||
throw new SaSsoException("非法redirect:" + url).setCode(SaSsoErrorCode.CODE_30002);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user