作者 若依
提交者 Gitee

!669 用户多角色,数据权限切面处理时可能出现权限抬升的情况。

Merge pull request !669 from 0慕容雪0/master
@@ -108,6 +108,7 @@ public class DataScopeAspect @@ -108,6 +108,7 @@ public class DataScopeAspect
108 if (DATA_SCOPE_ALL.equals(dataScope)) 108 if (DATA_SCOPE_ALL.equals(dataScope))
109 { 109 {
110 sqlString = new StringBuilder(); 110 sqlString = new StringBuilder();
  111 + conditions.add(dataScope);
111 break; 112 break;
112 } 113 }
113 else if (DATA_SCOPE_CUSTOM.equals(dataScope)) 114 else if (DATA_SCOPE_CUSTOM.equals(dataScope))
@@ -141,6 +142,12 @@ public class DataScopeAspect @@ -141,6 +142,12 @@ public class DataScopeAspect
141 conditions.add(dataScope); 142 conditions.add(dataScope);
142 } 143 }
143 144
  145 + // 多角色情况下,所有角色都不包含传递过来的权限字符,这个时候sqlString也会为空,所以要限制一下,不查询任何数据
  146 + if (StringUtils.isEmpty(conditions))
  147 + {
  148 + sqlString.append(StringUtils.format(" OR {}.dept_id = 0 ", deptAlias));
  149 + }
  150 +
144 if (StringUtils.isNotBlank(sqlString.toString())) 151 if (StringUtils.isNotBlank(sqlString.toString()))
145 { 152 {
146 Object params = joinPoint.getArgs()[0]; 153 Object params = joinPoint.getArgs()[0];