test(gateway+auth): T1.6 评审收口(I-1 胶水测试/M-2 空 userId/M-1 时效性注释)
- I-1(合 main 前必须):ProcessModelerControllerTest 补 4 个 MockMvc 胶水测试 (standaloneSetup + setControllerAdvice(FlowGatewayExceptionHandler) + 自定义超管参数解析器)—— by-id/by-key 各:①引擎不可达经既有 handler 出 503 通用信封(FlowGatewayExceptionHandler 全仓首测) ②正常路径 200 透传 ③MVC 层把 percent 编码中文 path variable(含冒号 procDefId)正确解码回原串交控制器。 - M-2:EngineContextBinderAdminTest 补「userId 空串/空白/null 且 account 非 admin → false」用例。 - M-1:EngineContextBinder.isSystemAdmin javadoc 补时效性说明(userId/account 取自 JWT claim 签发快照, 非实时查库;token 有效期内 admin 改名/停用/降权不即时生效,由 TTL/吊销兜底)。 测试(mvn -pl platform-flow-gateway,platform-auth -am test 全绿,既有零修改): ProcessModelerControllerTest 6→10 / EngineContextBinderAdminTest 8→9 / FlowableClientTest 12 不变。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -65,6 +65,10 @@ public final class EngineContextBinder {
|
||||
* 无唯一约束、建号去重又区分大小写而把 {@code 'Admin'} 这类变体账号静默提权(安全评审 M-1)。</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p><b>时效性(time-of-check)</b>:userId/account 均取自 JWT claim(token 签发时的身份快照),
|
||||
* <strong>不实时查库</strong>。故在 token 有效期内,若 admin 账号被改名/停用/降权,本判定仍按签发时结果放行——
|
||||
* 由 token TTL 兜底,安全敏感的提权变更需配合短 TTL 或主动吊销 token 方能即时生效。
|
||||
*
|
||||
* <p>公开为 {@code public static} 供网关层复用(流程 Modeler 超管门,flowable-service 裸 8089
|
||||
* 无安全栈 → 超管门唯一落点在网关,T1.6)。{@code null} 主体安全返回 {@code false}(未认证即非超管)。
|
||||
*/
|
||||
|
||||
@@ -60,6 +60,14 @@ class EngineContextBinderAdminTest {
|
||||
assertThat(EngineContextBinder.isSystemAdmin(user("U1", "zhangsan"))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void userId空串或空白且account非admin_非超管() {
|
||||
// principal 非 null 但 userId 空/空白(trim 后非 ADMIN),account 也非 admin → 两分支均判假,不越权
|
||||
assertThat(EngineContextBinder.isSystemAdmin(user("", "zhangsan"))).isFalse();
|
||||
assertThat(EngineContextBinder.isSystemAdmin(user(" ", "zhangsan"))).isFalse();
|
||||
assertThat(EngineContextBinder.isSystemAdmin(user(null, "zhangsan"))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void null主体_null安全返回false() {
|
||||
assertThat(EngineContextBinder.isSystemAdmin(null)).isFalse();
|
||||
|
||||
Reference in New Issue
Block a user