Просмотр исходного кода

merge(fix/b69): /api/mind/** 强制登录(O-21 B-69 落码)

将 fix/b69-mind-login-required (63cf7455a) 合入 cfclub:
- JwtInterceptor.java: /api/mind/ 移入 LOGIN_REQUIRED_PATHS,匿名 401
- MindFortuneControllerTest.java: 断言改 401
验证: mvn MindFortuneControllerTest 1/1 绿 + JwtInterceptor* 70/70 绿
复验路径: 线上 /api/mind/fortune 匿名 POST 应由 200 转 401(R121+)
Agnes Agent 3 дней назад
Родитель
Сommit
84239ce220

+ 3 - 4
cfc-backend/src/main/java/com/etotem/cfc/config/JwtInterceptor.java

@@ -76,10 +76,6 @@ private static final String[] PUBLIC_PATHS = {
          "/api/activity/detail",
          "/api/activity/order/notify",
          "/api/content-sections/visible",
-         "/api/mind/alert/active",
-         "/api/mind/alert/checkin-alerts",
-         "/api/mind/traditional/mirror",
-         "/api/mind/traditional/compatibility",
          "/api/mcp/**"
      };
 
@@ -115,6 +111,9 @@ private static final String[] PUBLIC_PATHS = {
         "/api/health/checkin/",             // 健康打卡:成员私有数据
         "/api/xiaomi-health/",              // 小米运动健康:OAuth 授权绑定/同步/撤销,成员私有凭证与数据
         "/api/huawei-health/",              // 华为运动健康:OAuth 授权绑定/同步/撤销,成员私有凭证与数据,必须登录(与 xiaomi-health 对齐)
+        // B-69(O-21 裁决):/api/mind/** 移出匿名白名单——运势/情绪预警/传统测试均为成员私有数据,
+        // 匿名(userId=-1)此前被 PUBLIC_PATHS 放行直通业务层(200/400 口径漂移),整族必须登录,无 token 直接 401。
+        "/api/mind/",                       // 心理解读:今日运势/情绪预警/传统测试/筛查/亲子画像,成员私有数据,必须登录
         "/api/tasks/",                      // 任务:家庭私有数据(今日/历史/审核/完成)
         "/api/energy/",                     // 五维能量:用户私有数据(sandbox/logs/grant/score-history...)
         "/api/wishes/",                     // 心愿:家庭私有数据

+ 5 - 2
cfc-backend/src/test/java/com/etotem/cfc/integration/controller/mind/MindFortuneControllerTest.java

@@ -18,8 +18,11 @@ class MindFortuneControllerTest {
 
     @Test
     void testGetTodayFortuneWithoutAuth() throws Exception {
+        // B-69(O-21 裁决):/api/mind/** 已从 PUBLIC_PATHS 移入 LOGIN_REQUIRED_PATHS,
+        // 匿名(无 token)访问直接由 JwtInterceptor 返回 HTTP 401(writeUnauthorized 写 401 + {"code":401}),
+        // 不再匿名(userId=-1)放行到 controller 后走"业务 400/500"口径漂移。
         mockMvc.perform(post("/api/mind/fortune"))
-                .andExpect(status().isOk())
-                .andExpect(jsonPath("$.code").value(401)); // JWT验证失败
+                .andExpect(status().isUnauthorized())
+                .andExpect(jsonPath("$.code").value(401)); // B-69:/api/mind/ 强制登录,匿名 401
     }
 }