pub struct CallerContext {
pub key_id: Option<String>,
pub allowed_acc_ids: Option<Arc<HashSet<u64>>>,
pub has_auth_setup_scope: bool,
pub is_loopback: bool,
pub legacy_local_mode: bool,
}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。
has_auth_setup_scope: boolPrecomputed central-router admission bit for Verification(1006).
is_loopback: boolTransport-owned peer check. Only the listener may set this bit.
legacy_local_mode: boolNo-key compatibility mode confirmed by the REST auth middleware.
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().
pub fn with_transport(self, is_loopback: bool, legacy_local_mode: bool) -> Self
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 字段填充.
pub fn caller_has_auth_setup_scope(&self) -> bool
pub fn caller_is_loopback(&self) -> bool
pub fn caller_legacy_local_mode(&self) -> bool
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 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CallerContext
impl Debug for CallerContext
Source§impl Default for CallerContext
impl Default for CallerContext
Source§fn default() -> CallerContext
fn default() -> CallerContext
Auto Trait Implementations§
impl Freeze for CallerContext
impl RefUnwindSafe for CallerContext
impl Send for CallerContext
impl Sync for CallerContext
impl Unpin for CallerContext
impl UnsafeUnpin for CallerContext
impl UnwindSafe for CallerContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more