refactor(oapi): 收敛 Notice 范式——回调收口+提供方强制验签迁 starter(审计 P1 / L2-7 L2-8)
build / build-push (push) Successful in 1m37s

回调(对齐《子应用流程与消息对接手册-20260929》Notice 线上形态):
- yh.flow-callback.path 迁 /oapi/flow/callback;删 callback-url(改 starter 三段推导:
  base-host+前缀三层回落+path,生产=http://open-gateway-service:10013/svc-hall/oapi/flow/callback)
- verify-flw-signature=false(平台应用签名承担,X-Flw 不启用);reconcile-on-register=true
  (路径漂移自动重注册,160 存量 /callback/flow 行靠它收敛)
- 删 svchall.public-base-url(唯一消费方即 callback-url 拼接)与 yh.open.base-path
  (对齐 Notice 形态;该键代码默认值即 /userbase,删键无行为变化)
- deriveCallbackBasePath 剥尾段口径同步 /oapi/flow/callback(契约测试断言更新)

提供方(flow-center 同款组合链):
- 删自写 OpenApiAuthEnforceConfiguration(starter 版 RequireAppSignFilter 承接,order+11 等价)
- yh.app-auth.server.enforce-patterns=[/oapi/*] + trust-registry=true;trusted-apps 保留
  100005(CMS) 并增 100019(flow-center 回调推送兜底);pom 显式引 data-redis(optional 不传递)
- management.health.redis.enabled=false(Redis 抖动不拉 DOWN 整机健康)

门禁:mvn test 127/127 绿
This commit is contained in:
chenxing
2026-10-05 22:26:22 +08:00
parent f368299eb5
commit eb0a8ded2f
7 changed files with 70 additions and 79 deletions
@@ -6,27 +6,34 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* 回调注册 basePath 推导契约:接收方 context-path 从回调 URL path 段去掉尾部
* /callback/flow 推导(部署带 ctx=签名对齐关键;本地裸地址=空串保持旧形态)。
* /oapi/flow/callback 推导(部署带 ctx=签名对齐关键;本地裸地址=空串保持旧形态)。
* 2026-09-16 修复:注册漏带 basePath,flow-center 推送按整路径签名 →
* FlowCallbackVerifyFilter 剥 ctx 后对不上 → 401(本地无 ctx 掩盖)。
* 验签过滤器剥 ctx 后对不上 → 401(本地无 ctx 掩盖)。
* 2026-10-05:回调端点收敛 Notice 形态(/oapi/flow/callback),剥尾段口径同步。
*/
class FlowCenterClientCallbackBasePathTest {
@Test
void derive_withContextPath() {
assertEquals("/svc-hall",
FlowCenterClient.deriveCallbackBasePath("http://svc-hall-service:10007/svc-hall/callback/flow"));
FlowCenterClient.deriveCallbackBasePath("http://open-gateway-service:10013/svc-hall/oapi/flow/callback"));
}
@Test
void derive_bareLocalAddressIsEmpty() {
assertEquals("", FlowCenterClient.deriveCallbackBasePath("http://localhost:8086/callback/flow"));
assertEquals("", FlowCenterClient.deriveCallbackBasePath("http://localhost:8086/oapi/flow/callback"));
}
@Test
void derive_gatewayForm() {
void derive_containerDirectForm() {
assertEquals("/svc-hall",
FlowCenterClient.deriveCallbackBasePath("http://base.yunhaixingtong.com/svc-hall/callback/flow"));
FlowCenterClient.deriveCallbackBasePath("http://svc-hall-service:10007/svc-hall/oapi/flow/callback"));
}
@Test
void derive_legacyOldEndpointNotStripped() {
// 旧端点尾段不再是合法推导输入:不命中剥尾段即返回空串(显式冻结,不静默兼容旧路径)
assertEquals("", FlowCenterClient.deriveCallbackBasePath("http://svc-hall-service:10007/svc-hall/callback/flow"));
}
@Test
@@ -127,14 +127,14 @@ class FlowCenterClientFacadeTest {
any(FlowCallbackRegBody.class), eq(SvcModels.CallbackRegVo.class))).thenReturn(stub);
String secret = client().registerCallback(3L, "guid-1",
"http://svc-hall-service:10007/svc-hall/callback/flow", null);
"http://open-gateway-service:10013/svc-hall/oapi/flow/callback", null);
assertEquals("secret-1", secret);
ArgumentCaptor<FlowCallbackRegBody> body = ArgumentCaptor.forClass(FlowCallbackRegBody.class);
verify(openCall).post(eq(TARGET), eq("/oapi/flow/callback/reg"), anyMap(),
body.capture(), eq(SvcModels.CallbackRegVo.class));
assertEquals("/svc-hall", body.getValue().getBasePath());
assertEquals("http://svc-hall-service:10007/svc-hall/callback/flow", body.getValue().getCallbackUrl());
assertEquals("http://open-gateway-service:10013/svc-hall/oapi/flow/callback", body.getValue().getCallbackUrl());
assertNull(body.getValue().getEventTypes());
}