feat(sa-token): 在 SaCheckOr 注解中添加 apikey 支持

- 在 SaCheckOr 注解中添加 apikey 属性,用于设定 @SaCheckApiKey
- 更新 SaCheckOrHandler 类,支持处理新增的 apikey 属性- 此更新扩展了 SaCheckOr 注解的功能,使其能够支持 API 密钥的验证
This commit is contained in:
Kairos 2025-04-26 09:15:22 +08:00
parent abdfb2305d
commit a17befcebb
2 changed files with 10 additions and 1 deletions

View File

@ -81,4 +81,11 @@ public @interface SaCheckOr {
*/
SaCheckDisable[] disable() default {};
/**
* 设定 @SaCheckApiKey参考 {@link SaCheckApiKey}
*
* @return /
*/
SaCheckApiKey[] apikey() default {};
}

View File

@ -40,7 +40,7 @@ public class SaCheckOrHandler implements SaAnnotationHandlerInterface<SaCheckOr>
@Override
public void checkMethod(SaCheckOr at, Method method) {
_checkMethod(at.login(), at.role(), at.permission(), at.safe(), at.httpBasic(), at.httpDigest(), at.disable(), method);
_checkMethod(at.login(), at.role(), at.permission(), at.safe(), at.httpBasic(), at.httpDigest(), at.disable(), at.apikey(), method);
}
public static void _checkMethod(
@ -51,6 +51,7 @@ public class SaCheckOrHandler implements SaAnnotationHandlerInterface<SaCheckOr>
SaCheckHttpBasic[] httpBasic,
SaCheckHttpDigest[] httpDigest,
SaCheckDisable[] disable,
SaCheckApiKey[] apikey,
Method method
) {
// 先把所有注解塞到一个 list
@ -62,6 +63,7 @@ public class SaCheckOrHandler implements SaAnnotationHandlerInterface<SaCheckOr>
annotationList.addAll(Arrays.asList(disable));
annotationList.addAll(Arrays.asList(httpBasic));
annotationList.addAll(Arrays.asList(httpDigest));
annotationList.addAll(Arrays.asList(apikey));
// 如果 atList 为空说明 SaCheckOr 上不包含任何注解校验我们直接跳过即可
if(annotationList.isEmpty()) {