pub struct CallerContext {
pub key_id: Option<String>,
pub allowed_acc_ids: Option<Arc<HashSet<u64>>>,
}Expand description
REST caller scope 快照 (一次 build, 多次透传).
触发位置: route handler 入口, 从 Extension<Arc<KeyRecord>> 抽取.
下游消费者 (统一来源, 防漂移):
adapter::proto_request_with_ctx→IncomingRequest.caller_*填充adapter::proto_request_with_ctx→FilterRegistry::apply响应过滤routes::trd::extract_and_resolve_card_num_into_acc_id共用routes::trd::sub_acc_push/routes::sys::unsub_acc_push的 per-acccheck_full_skip_rate共用
legacy 模式: key_id = None + allowed_acc_ids = None (无 keys.json /
未鉴权), handler 不 filter / 不审 per-key.
Fields§
§key_id: Option<String>调用方 API key id (来自 KeyRecord.id). None = legacy mode.
allowed_acc_ids: Option<Arc<HashSet<u64>>>调用方 allowed_acc_ids 硬限额快照 (来自 KeyRecord.allowed_acc_ids,
SIGHUP-aware, route handler build CallerContext 时一次性 clone).
None = 无限制 (legacy / 未配此白名单); Some(non_empty_set) =
受限。Some(empty) 按 futu-auth::RuntimeCounters 历史契约等同
不限制;card_num fail-closed 使用 sentinel {0} 表达 deny-all, 不用
空集合表达 deny-all。
Implementations§
Source§impl CallerContext
impl CallerContext
Sourcepub fn legacy() -> Self
pub fn legacy() -> Self
Legacy mode: 无 caller key, 无 allowed_acc_ids 限制. 用于 unauthenticated route 或 legacy 模式的 fallback 路径.
Sourcepub fn from_key_record(rec: Option<&KeyRecord>) -> Self
pub fn from_key_record(rec: Option<&KeyRecord>) -> Self
从 KeyRecord 构 CallerContext (route handler 入口主用).
rec = None (Extension 缺失, legacy 模式) → 等价 legacy().
Sourcepub fn allowed_acc_ids_borrow(&self) -> Option<&HashSet<u64>>
pub fn allowed_acc_ids_borrow(&self) -> Option<&HashSet<u64>>
allowed_acc_ids 借引用 (let FilterRegistry::apply 等 borrow 接 API
直接吃). 跟 Arc::as_ref 等价但省 caller 写 .as_ref().map(|a| a.as_ref()).
Sourcepub fn caller_allowed_acc_ids_arc(&self) -> Option<Arc<HashSet<u64>>>
pub fn caller_allowed_acc_ids_arc(&self) -> Option<Arc<HashSet<u64>>>
caller_allowed_acc_ids 直接 clone Arc 供 IncomingRequest 字段填充
(Arc::clone 成本极低, 不深拷贝 set).
Sourcepub fn caller_key_id(&self) -> Option<String>
pub fn caller_key_id(&self) -> Option<String>
caller_key_id 直接 clone String 供 IncomingRequest 字段填充.
Sourcepub fn key_id_for_audit(&self) -> String
pub fn key_id_for_audit(&self) -> String
audit log 用的 key_id (None → “
Trait Implementations§
Source§impl Clone for CallerContext
impl Clone for CallerContext
Source§fn clone(&self) -> CallerContext
fn clone(&self) -> CallerContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more