--author:scott--date:20261013--for:【安全 GHSA-8v96-whwg-rf92/GHSA-xpvg-j72w-356p/GHSA-3f75-3wg8-c663/GHSA-23w8-29xc-fpfh】租户拥有者变更与编辑接口校验调用者身份,防止租户被接管

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
zhangdaiscott 2026-10-13 04:58:47 -04:00
parent 3a5f89a9f9
commit 28d47a0109
2 changed files with 16 additions and 0 deletions

View File

@ -487,6 +487,16 @@ public class SysTenantController {
if(sysTenant==null) {
return result.error500("未找到对应实体");
}
//update-begin---author:scott ---date:20261013 for:【安全 GHSA-23w8-29xc-fpfh/GHSA-xpvg-j72w-356p】只有租户拥有者、租户管理员或admin才能编辑,且不允许修改拥有者、状态、删除标记-----------
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if (!loginUser.getUsername().equals(sysTenant.getCreateBy()) && !SecurityUtils.getSubject().hasRole("admin")) {
// 非当前租户的组织账户管理员或超级管理员时抛出异常
sysTenantPackService.izHaveManageUserAuth(tenant.getId().toString());
}
tenant.setCreateBy(null);
tenant.setStatus(null);
tenant.setDelFlag(null);
//update-end---author:scott ---date:20261013 for:【安全 GHSA-23w8-29xc-fpfh/GHSA-xpvg-j72w-356p】只有租户拥有者、租户管理员或admin才能编辑,且不允许修改拥有者、状态、删除标记-----------
if(oConvertUtils.isEmpty(sysTenant.getHouseNumber())){
tenant.setHouseNumber(RandomUtil.randomStringUpper(6));
}

View File

@ -367,6 +367,12 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
if(null == sysTenant){
throw new JeecgBootException("退出租户失败,不存在此租户");
}
//update-begin---author:scott ---date:20261013 for:【安全 GHSA-8v96-whwg-rf92/GHSA-xpvg-j72w-356p/GHSA-3f75-3wg8-c663】只有租户拥有者或admin才能变更拥有者,防止任意成员接管租户-----------
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if (!loginUser.getUsername().equals(sysTenant.getCreateBy()) && !SecurityUtils.getSubject().hasRole("admin")) {
throw new JeecgBootException("只有租户拥有者才能变更拥有者");
}
//update-end---author:scott ---date:20261013 for:【安全 GHSA-8v96-whwg-rf92/GHSA-xpvg-j72w-356p/GHSA-3f75-3wg8-c663】只有租户拥有者或admin才能变更拥有者,防止任意成员接管租户-----------
String createBy = sysTenant.getCreateBy();
Integer count = userTenantMapper.userTenantIzExist(userId, tenantId);
if (count == 0) {