权限为空时问题处理
This commit is contained in:
parent
2e5f383db4
commit
2e99c26654
@ -90,8 +90,8 @@ public class ManagerAuthenticationFilter extends BasicAuthenticationFilter {
|
|||||||
//获取数据(GET 请求)权限
|
//获取数据(GET 请求)权限
|
||||||
if (request.getMethod().equals(RequestMethod.GET.name())) {
|
if (request.getMethod().equals(RequestMethod.GET.name())) {
|
||||||
//如果用户的超级权限和查阅权限都不包含当前请求的api
|
//如果用户的超级权限和查阅权限都不包含当前请求的api
|
||||||
if (PatternMatchUtils.simpleMatch(permission.get(PermissionEnum.SUPER.name()).toArray(new String[0]), requestUrl)
|
if (match(permission.get(PermissionEnum.SUPER.name()), requestUrl) ||
|
||||||
|| PatternMatchUtils.simpleMatch(permission.get(PermissionEnum.QUERY.name()).toArray(new String[0]), requestUrl)) {
|
match(permission.get(PermissionEnum.QUERY.name()), requestUrl)) {
|
||||||
} else {
|
} else {
|
||||||
ResponseUtil.output(response, ResponseUtil.resultMap(false, 400, "权限不足"));
|
ResponseUtil.output(response, ResponseUtil.resultMap(false, 400, "权限不足"));
|
||||||
throw new NoPermissionException("权限不足");
|
throw new NoPermissionException("权限不足");
|
||||||
@ -109,6 +109,20 @@ public class ManagerAuthenticationFilter extends BasicAuthenticationFilter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验权限
|
||||||
|
*
|
||||||
|
* @param permissions 权限集合
|
||||||
|
* @param url 请求地址
|
||||||
|
* @return 是否拥有权限
|
||||||
|
*/
|
||||||
|
boolean match(List<String> permissions, String url) {
|
||||||
|
if (permissions.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return PatternMatchUtils.simpleMatch(permissions.toArray(new String[0]), url);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取token信息
|
* 获取token信息
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user