mirror of
https://github.com/hs-web/hsweb-framework.git
synced 2026-06-21 20:52:46 +08:00
新增匿名访问
This commit is contained in:
@@ -38,11 +38,14 @@ public class AopAuthorizeValidator extends SimpleAuthorizeValidator {
|
||||
return null;
|
||||
}
|
||||
Set<Authorize> 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<String, Object> 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,11 @@ public @interface Authorize {
|
||||
*/
|
||||
boolean api() default false;
|
||||
|
||||
/**
|
||||
* 可匿名访问
|
||||
* @return 是否可匿名访问,匿名访问将不用登录
|
||||
*/
|
||||
boolean anonymous() default false;
|
||||
/**
|
||||
* 验证模式,在使用多个验证条件时有效
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user