This commit is contained in:
2026-08-05 16:26:10 +08:00
parent 06f7f9d2f2
commit 5ba9716e12
155 changed files with 2883 additions and 551 deletions
@@ -13,7 +13,7 @@ public final class AuditPlatformScopeGuard {
if (user == null || user.userId() == null) {
throw new BizException(ResultCode.UNAUTHORIZED, "请先登录");
}
if (!"PLATFORM".equals(user.appCode())) {
if (!"PLATFORM".equals(user.appCode()) || !Long.valueOf(0L).equals(user.tenantId())) {
throw new BizException(ResultCode.FORBIDDEN, "仅平台端可查看操作日志");
}
}
@@ -51,6 +51,17 @@ class PlatformAuditLogControllerContractTest {
verifyNoInteractions(service);
}
@Test
void platformApplicationWithCustomerTenantCannotReadLogs() {
AuthenticatedUser malformed = new AuthenticatedUser(7L, 10001L, 10001L, 1L,
"异常平台账号", "PLATFORM", "WEB", Set.of("platform:audit:list"));
assertThatThrownBy(() -> controller.page(malformed, 1, 20, null, null, null, null,
null, null, null, null, null)).isInstanceOf(BizException.class)
.hasMessage("仅平台端可查看操作日志");
verifyNoInteractions(service);
}
@Test
void platformCanReadLogDetail() {
AuditLogResponses.Detail detail = new AuditLogResponses.Detail(8L, "audit-1", "ROLE_UPDATE", "ROLE", "9", null,