fix: 登录失败按 Halo 登录端点契约判定,不再被 200/302 掩盖

Halo 2.26 登录端点表单提交的成功与失败均为 302 重定向(成功 → /uc,
失败 → /login?error=...&method=...),失败回显页 GET /login?error=...
渲染 HTTP 200;旧逻辑按「2xx 即成功」判定导致:

- 审计列表中失败登录显示绿色 200/302,误读为登录成功
- 登录失败告警把表单成功登录也计为失败,成功清零失效、可误报警

修复:
- 新增 LoginOutcome 纯函数:2xx 成功;3xx 以重定向目标查询串是否含
  error 参数判定(含无值形式);其余(401、状态码缺失)失败
- 失败的登录尝试与失败回显(GET /login?error=...)落库标注语义动作
  login-failure(spec.action),HTTP 状态码仍如实记录
- Console 列表/详情与 CSV:登录失败记录显示红色「失败」而非裸状态码,
  语义动作筛选与「结果=失败」筛选均命中登录失败记录
- LoginFailureAlertService 改由过滤器传入 LoginOutcome 判定结果,
  成功清零、失败累计恢复正常
- 历史局限:升级前落库的表单登录失败(302)无法由路径重新推导,
  仍按登录展示;升级后新记录捕获时标注,不再有此局限

测试:后端 265 例、前端 60 例全部通过;文档与 README 同步更新。
This commit is contained in:
2026-11-22 15:47:47 +08:00
parent 9865149ab3
commit 9e89ed75ed
22 changed files with 743 additions and 100 deletions
@@ -24,9 +24,9 @@ import {
describeOperation,
displayUsername,
formatTime,
isSuccessful,
localDateTimeToInstant,
methodBadgeClass,
resultBadge,
SEMANTIC_ACTIONS,
} from '@/utils/audit'
import AuditLogDetail from './AuditLogDetail.vue'
@@ -382,15 +382,14 @@ onMounted(fetchLogs)
</VEntityField>
</template>
<template #end>
<!-- 结果列:徽标经 #title 插槽渲染(当前版本组件在无 title 时
不渲染 #extra,原先徽标实际不可见) -->
<!-- 结果列:登录失败记录(HTTP 200/302 也可能是失败,语义动作已标注)
显示红色「失败」,避免绿色 200/302 误读为登录成功;
徽标经 #title 插槽渲染(当前版本组件在无 title 时不渲染 #extra,
原先徽标实际不可见) -->
<VEntityField width="4rem">
<template #title>
<span
class="status-badge"
:class="isSuccessful(log.spec.statusCode) ? 'status-ok' : 'status-fail'"
>
{{ log.spec.statusCode }}
<span class="status-badge" :class="resultBadge(log.spec).class">
{{ resultBadge(log.spec).text }}
</span>
</template>
</VEntityField>