refactor(租户): 站点超管判定收成唯一静态出口,看板补第四道门
"super_admin 才算平台超管"这句判断此前在 src/main 里被手抄过 19 遍,2026-10-07 定的 「company_super_admin 在业务数据面同权、只在管理动作收窄」要落地就得一次改到每一处, 漏一处的表现是某一页静默 403 或静默多放行,两边都不报错。现在口径只在 DeviceSessionPolicy.isSuper 比一次: - 出口做成静态谓词而不是 AdminAuthSupport 实例方法——那 18 支测试里 mock 的是 AdminAuthSupport,新增实例方法不会被桩到,默认 false 会把范围静默改窄; - 12 个文件的 15 处调用点改为 DeviceSessionPolicy.isSuper(currentRole(...)), DataReadScope/AdminAuthSupport 只留一个委托包装; - 「客户端任务管理」五个 handler 的成员集计算折进 DataReadScope.superAdminScopedUserIds, 并在 CompanyIdParamGoesThroughReadScopeTest 里补成第四道门(正反探针各一, 判据不会因"抽进私有方法"而失明); - 护栏 SuperAdminPredicateSingleOutletTest 双向钉:出口定义==1、包装==1、调用点==16, 且 banned 掉实例方法形状(自检断言保证它真能红)。 今天口径仍只认 super_admin,这一层是接缝不是开关。Java 全量在本批收口后的那棵树实测 4032 例 0 红 7 skip(7 支是要本地凭据/夹具的回放与实况探测类,历来 skip)。 一并落在这支的文件(同一文件只能进一次提交,故与同批的归属收口混装):ImageVideo/InvalidAsin/ AdminDeviceLog/AdminTaskCenter/DedupeTotalData/AdminShopDataCrawlTasks/AdminShopDataDuplicateCheck/ QueryAsin/ShopManage/SkipPriceAsin 这 10 支控制器的请求身份改走会话出口见 cp-item7 的说明; PermissionMenuService 还删掉了 create/update/delete 三个"operator 传 null 即跳过归属闸门"的 无操作者写重载(src/main 无人调用),判据在 MenuWriteOutletOperatorTest。
This commit is contained in:
+4
-3
@@ -7,6 +7,7 @@ import com.nanri.aiimage.modules.admin.spi.UserSecretCleanupPort;
|
||||
import com.nanri.aiimage.common.security.ShopCredentialCryptoService;
|
||||
import com.nanri.aiimage.config.UserSecretProperties;
|
||||
import com.nanri.aiimage.common.security.AdminAuthSupport;
|
||||
import com.nanri.aiimage.common.security.DeviceSessionPolicy;
|
||||
import com.nanri.aiimage.common.service.ReadScope;
|
||||
import com.nanri.aiimage.modules.notification.service.NotificationDispatchService;
|
||||
import com.nanri.aiimage.modules.notification.service.NotificationService;
|
||||
@@ -205,7 +206,7 @@ public class UserApiSecretService implements UserSecretCleanupPort {
|
||||
|
||||
/** 数据权限:超管可操作全部;其余管理员只能操作自己数据权限范围内的用户。 */
|
||||
private void requireVisibleUser(AdminUserEntity operator, Long userId) {
|
||||
if (operator != null && "super_admin".equals(adminAuthSupport.currentRole(operator))) {
|
||||
if (operator != null && DeviceSessionPolicy.isSuper(adminAuthSupport.currentRole(operator))) {
|
||||
return;
|
||||
}
|
||||
Long operatorId = operator == null ? null : operator.getId();
|
||||
@@ -326,7 +327,7 @@ public class UserApiSecretService implements UserSecretCleanupPort {
|
||||
long pageSize = safeQuery.getPageSize() == null || safeQuery.getPageSize() < 1
|
||||
? 15L : Math.min(safeQuery.getPageSize(), 100L);
|
||||
|
||||
boolean superAdmin = "super_admin".equals(adminAuthSupport.currentRole(operator));
|
||||
boolean superAdmin = DeviceSessionPolicy.isSuper(adminAuthSupport.currentRole(operator));
|
||||
Long requestedGroupId = safeQuery.getGroupId();
|
||||
// 组隔离(主管锁定自己带的分组、超管按 group_id 筛)叠上公司 tab:两条维度取**交集**,
|
||||
// 公司 tab 只能收窄,绝不放大分组看不到的行;范围本身由 controller 经唯一出口算好交下来。
|
||||
@@ -419,7 +420,7 @@ public class UserApiSecretService implements UserSecretCleanupPort {
|
||||
* ({@link ReadScope#userIdsOr}),留着是为了让 service 不依赖出口的内部 ⇒ <b>勿把它当成第二次判公司</b>。
|
||||
*/
|
||||
List<Long> scopedUserIds(AdminUserEntity operator, Long requestedGroupId, ReadScope companyScope) {
|
||||
boolean superAdmin = "super_admin".equals(adminAuthSupport.currentRole(operator));
|
||||
boolean superAdmin = DeviceSessionPolicy.isSuper(adminAuthSupport.currentRole(operator));
|
||||
List<Long> base = null;
|
||||
if (superAdmin) {
|
||||
if (requestedGroupId != null && requestedGroupId > 0) {
|
||||
|
||||
+3
-2
@@ -2,6 +2,7 @@ package com.nanri.aiimage.modules.usersecret.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.nanri.aiimage.common.security.AdminAuthSupport;
|
||||
import com.nanri.aiimage.common.security.DeviceSessionPolicy;
|
||||
import com.nanri.aiimage.common.service.ReadScope;
|
||||
import com.nanri.aiimage.common.mapper.AdminUserMapper;
|
||||
import com.nanri.aiimage.common.model.entity.AdminUserEntity;
|
||||
@@ -99,7 +100,7 @@ public class UserSecretUsageService {
|
||||
long pageSize = safeQuery.getPageSize() == null || safeQuery.getPageSize() < 1
|
||||
? 15L : Math.min(safeQuery.getPageSize(), 100L);
|
||||
|
||||
boolean superAdmin = "super_admin".equals(adminAuthSupport.currentRole(operator));
|
||||
boolean superAdmin = DeviceSessionPolicy.isSuper(adminAuthSupport.currentRole(operator));
|
||||
Long requestedGroupId = safeQuery.getGroupId();
|
||||
// 组隔离(主管锁定自己带的分组、超管按 group_id 筛)叠上公司 tab:取**交集**,公司 tab 只收窄。
|
||||
List<Long> scopedUserIds = scopedUserIds(operator, requestedGroupId, companyScope);
|
||||
@@ -224,7 +225,7 @@ public class UserSecretUsageService {
|
||||
* ({@link ReadScope#userIdsOr}),留着是为了让 service 不依赖出口的内部 ⇒ <b>勿把它当成第二次判公司</b>。
|
||||
*/
|
||||
List<Long> scopedUserIds(AdminUserEntity operator, Long requestedGroupId, ReadScope companyScope) {
|
||||
boolean superAdmin = "super_admin".equals(adminAuthSupport.currentRole(operator));
|
||||
boolean superAdmin = DeviceSessionPolicy.isSuper(adminAuthSupport.currentRole(operator));
|
||||
List<Long> base = null;
|
||||
if (superAdmin) {
|
||||
if (requestedGroupId != null && requestedGroupId > 0) {
|
||||
|
||||
Reference in New Issue
Block a user