diff --git a/hsweb-web-core/src/main/java/org/hsweb/web/core/authorize/AopAuthorizeValidator.java b/hsweb-web-core/src/main/java/org/hsweb/web/core/authorize/AopAuthorizeValidator.java index b48de5cd6..f6d1c877b 100644 --- a/hsweb-web-core/src/main/java/org/hsweb/web/core/authorize/AopAuthorizeValidator.java +++ b/hsweb-web-core/src/main/java/org/hsweb/web/core/authorize/AopAuthorizeValidator.java @@ -38,11 +38,14 @@ public class AopAuthorizeValidator extends SimpleAuthorizeValidator { return null; } Set authorizes = new LinkedHashSet<>(); - if (classAuth != null) + if (classAuth != null) { + if (classAuth.anonymous()) return null; authorizes.add(classAuth); - if (methodAuth != null) + } + if (methodAuth != null) { + if (methodAuth.anonymous()) return null; authorizes.add(methodAuth); - + } config.addAnnotation(authorizes); configCache.put(cacheKey, config); } @@ -65,11 +68,11 @@ public class AopAuthorizeValidator extends SimpleAuthorizeValidator { Map param = new LinkedHashMap<>(); MethodSignature signature = (MethodSignature) pjp.getSignature(); String[] names = signature.getParameterNames(); - Object[] args=pjp.getArgs(); + Object[] args = pjp.getArgs(); for (int i = 0; i < names.length; i++) { param.put(names[i], args[i]); } - param.put("paramsMap",param); + param.put("paramsMap", param); return validate(user, param, config); } diff --git a/hsweb-web-core/src/main/java/org/hsweb/web/core/authorize/annotation/Authorize.java b/hsweb-web-core/src/main/java/org/hsweb/web/core/authorize/annotation/Authorize.java index a965e0193..4dfa64402 100644 --- a/hsweb-web-core/src/main/java/org/hsweb/web/core/authorize/annotation/Authorize.java +++ b/hsweb-web-core/src/main/java/org/hsweb/web/core/authorize/annotation/Authorize.java @@ -54,6 +54,11 @@ public @interface Authorize { */ boolean api() default false; + /** + * 可匿名访问 + * @return 是否可匿名访问,匿名访问将不用登录 + */ + boolean anonymous() default false; /** * 验证模式,在使用多个验证条件时有效 *