Commit 5ca63ea6 authored by suntao's avatar suntao

qian xian

parent c8ce9cab
...@@ -32,19 +32,25 @@ public class ApplicationSecurityHandler implements SecurityHandler { ...@@ -32,19 +32,25 @@ public class ApplicationSecurityHandler implements SecurityHandler {
Assert.isNull(principal, ApplicationStatus.AUTHENTICATION_FAILURE); Assert.isNull(principal, ApplicationStatus.AUTHENTICATION_FAILURE);
// 如果是超级管理员跳过权限验证 // 如果是超级管理员跳过权限验证
boolean superAdministrator = principal.isSuperAdministrator();
boolean anyMatch = principal.getRoles().stream().anyMatch(role -> { return principal.isSuperAdministrator() || principal.getRoles().stream().anyMatch(role -> {
List<Role> roleList = getRoleAndParent(role); List<Role> roleList = getRoleAndParent(role);
if (CollectionUtils.isEmpty(roleList)) {
return false;
}
return roleList.stream().anyMatch(_role -> this.checkAuthority(authorityId, _role)); return roleList.stream().anyMatch(_role -> this.checkAuthority(authorityId, _role));
}); });
return superAdministrator || anyMatch;
} }
/**
* 遍历出用户的父级 role
* @param role
* @return
*/
private List<Role> getRoleAndParent(Role role) { private List<Role> getRoleAndParent(Role role) {
if (role == null) { if (role == null) {
return new ArrayList<>(); return null;
} }
List<Role> list = new ArrayList<>(); List<Role> list = new ArrayList<>();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment