@@ -910,6 +910,26 @@ public class GroupAuthzService implements IGroupAuthzService {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 子组继承闸门:判定「来源组 authority 对 moduleId 的记录」是否对<b>本组</b> selfGroupId 生效。
|
||||
*
|
||||
* <p>规则(修复「父级未勾子组继承却仍被继承」的 bug):
|
||||
* ① 来源组 == 本组:本组自身勾选的模块直接生效——{@code inheritFlag} 只约束是否下放到<b>子组</b>,不影响本组自己;
|
||||
* ② 来源组为祖先(往上回溯得来):必须勾选了「子组继承」({@code inheritFlag=true}) 才会下放到本组,
|
||||
* 否则该模块不继承。即「只过滤勾选了子组继承的模块;若来源组对该应用所有模块都没勾子组继承,则本组对该应用返回空」。
|
||||
*/
|
||||
private boolean isPermEffectiveForSelf(Integer authority, Integer selfGroupId,
|
||||
Map<Integer, SysGroupModulePerm> permMap) {
|
||||
SysGroupModulePerm perm = (permMap == null) ? null : permMap.get(authority);
|
||||
if (perm == null) {
|
||||
return false;
|
||||
}
|
||||
if (authority.equals(selfGroupId)) {
|
||||
return true;
|
||||
}
|
||||
return Boolean.TRUE.equals(perm.getInheritFlag());
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户维度权限判定:用户对指定模块是否有权限(就近原则 + 学校截止 + 角色授权并集 + 超管兜底)。
|
||||
*
|
||||
@@ -921,6 +941,10 @@ public class GroupAuthzService implements IGroupAuthzService {
|
||||
* ② 本组无配置(如英语组为空)→ 取<b>最近</b>的有配置祖先(如教师组)为来源,不再越级到更远的学校组;
|
||||
* ③ 来源组的模块集合即最终集合,更上层同应用模块(如学校组多勾的模块8)一律不合并。
|
||||
*
|
||||
* <p><b>子组继承闸门</b>(修复「父级未勾子组继承仍被继承」的 bug):来源组若是本组,本组勾选的模块直接生效;
|
||||
* 来源组若是祖先,必须该模块记录 {@code inheritFlag=true}(勾选子组继承)才下放到本组,否则不继承——
|
||||
* 即「只过滤勾选了子组继承的模块;若来源组对该应用所有模块都没勾子组继承,则本组对该应用返回空」。
|
||||
*
|
||||
* <p><b>学校截止</b>:祖先链只查到第一个学校组(含)为止,不跨学校到教育局/根。
|
||||
*
|
||||
* <p><b>其余</b>:归属组需已开通该模块所属应用(双保险,防越权)。
|
||||
@@ -947,8 +971,9 @@ public class GroupAuthzService implements IGroupAuthzService {
|
||||
if (authority == null) {
|
||||
continue;
|
||||
}
|
||||
// 权限来源组对该模块有显式记录 → 许可;否则(来源组未勾此模块)不许可
|
||||
if (permMap != null && permMap.get(authority) != null) {
|
||||
// 来源组对该模块有显式记录,且(来源是本组 或 来源是祖先且勾选了子组继承)→ 许可;
|
||||
// 否则(来源组未勾此模块 / 祖先未开启子组继承)不许可。
|
||||
if (isPermEffectiveForSelf(authority, selfGroupId, permMap)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1233,7 +1258,7 @@ public class GroupAuthzService implements IGroupAuthzService {
|
||||
continue;
|
||||
}
|
||||
Map<Integer, SysGroupModulePerm> pm = modulePermMap.get(moduleId);
|
||||
if (pm != null && pm.get(authority) != null) {
|
||||
if (isPermEffectiveForSelf(authority, selfGroupId, pm)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user