1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright (c) 2025-2026 Kirky.X🌠
// SPDX-License-Identifier: Apache-2.0
/// Garrison Principal ↔ crawlrs AuthState 桥接
///
/// auth feature 启用时编译,
/// 提供 `map_perms_to_scope`、`bridge_principal_to_auth_state`、`extract_bearer` 等。
/// auth-off 时 garrison 不编译,走 feature-gate 的 `default_identity_middleware` 路径。
/// 中间件模块
///
/// 提供HTTP请求处理的中间件功能
/// 包括认证、限流、信号量控制等功能
/// 认证共享类型(重构 / 决策 3)
///
/// 抽出 `AuthError` 与 `AuthState` 解决 `auth_bridge` ↔ `auth_middleware` 之间的循环依赖。
/// 两个模块都从此处导入共享类型,避免互相 `use` 形成循环。
// 历史说明:`limiteron_rate_limit_middleware` 与 `distributed_rate_limit_middleware`
// 曾为并行的限流方案,均无路由挂载点(零调用方),已移除。
// 现行唯一限流中间件为 `rate_limit_middleware`(经 RateLimitingService trait 走 limiteron);
// 如需 tower 原生层语义(429/403 + RateLimit 响应头),可评估吸收 limiteron `tower-middleware`。
/// Public endpoints that don't require authentication or rate limiting
pub const PUBLIC_ENDPOINTS: & = &;
/// 唯一公开端点判定:精确名单 + `/health/*` 探针前缀,尾部斜杠归一化。
///
/// 认证与限流必须共用本谓词;两份判定会让 `/metrics/`、`/health/live`
/// 之类路径出现“认证豁免但限流不豁免”的分叉。