feat: 登录失败告警通知(阈值窗口统计 + Webhook JSON 推送)

- 新增 alert 包:AlertSettings(alerts 配置组,归一校验)、AlertSettingProvider
  (60s TTL 缓存,同审计设置模式)、LoginFailureAlertService(阈值窗口状态机:
  达阈值告警一次并重开窗口防轰炸,登录成功立即清零,2xx 成功/其余失败)、
  AlertWebhookSender(JSON POST fire-and-forget,10s 超时,失败不重试仅记日志)
- 捕获过滤器挂钩:POST /login 请求结束经 CaptureRule.isLoginAttempt 回调告警服务,
  独立于审计开关;登录页 GET 与登出不触发
- 设置新增「告警通知」表单组(开关默认关、Webhook 地址、触发阈值、统计窗口)
- 测试 +32(共 188 全绿):设置归一与 TTL 缓存、阈值窗口推进/告警防轰炸/成功清零/
  3xx 失败归类/降级路径、JDK HttpServer 真实 HTTP 推送与非 2xx/非法 URL 静默降级、
  过滤器告警回调与过滤器行为测试更新
- 文档同步:设计文档 §6 标注 V2 已实现并补 §7 局限,双 README 功能/设置/技术说明
This commit is contained in:
2026-11-21 23:28:28 +08:00
parent 3d1128c254
commit 20a4db5119
16 changed files with 959 additions and 5 deletions
@@ -19,6 +19,9 @@ public final class CaptureRule {
public static final Set<String> AUTH_ENDPOINTS = Set.of("/login", "/logout");
public static final String APIS_PREFIX = "/apis/";
/** 登录端点(告警通道唯一触发路径;登出与登录页 GET 不算登录尝试)。 */
public static final String LOGIN_ENDPOINT = "/login";
private CaptureRule() {
}
@@ -37,4 +40,13 @@ public final class CaptureRule {
public static boolean isAuthEndpoint(String path) {
return path != null && AUTH_ENDPOINTS.contains(path);
}
/**
* 是否为登录尝试(POST {@value #LOGIN_ENDPOINT},产品设计 V2「告警通知」):
* 登录失败告警的触发条件——2xx 为登录成功,其余为失败;
* 登录页 GET 与登出不算。
*/
public static boolean isLoginAttempt(String path, String method) {
return "POST".equals(method) && LOGIN_ENDPOINT.equals(path);
}
}