Skip to main content

Scope

Enum Scope 

Source
#[non_exhaustive]
pub enum Scope { QotRead, AccRead, TradeSimulate, TradeReal, TradeUnlock, Admin, Trade, MetricsRead, }
Expand description

API Key 能力分组

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

QotRead

行情只读(11 个工具)

§

AccRead

账户只读(5 个工具)

§

TradeSimulate

模拟交易写

§

TradeReal

真实交易写

§

TradeUnlock

允许自动 unlock_trade(从 keychain 读密码)

§

Admin

v1.4.32+ daemon 管理 (/api/admin/status|reload|shutdown)。 权限危险,只给运维 / 监控 key;LLM key 永远不要加这个。

§

Trade

v1.4.90 P1-A: trade 类 super-scope。仅在 REST middleware scope_for_path 用作“需要任意 trade scope“的占位需求*:持有 Scope::TradeReal / Scope::TradeSimulate / Scope::TradeUnlock 任一即满足。不应写入 keys.json(KeyRecord.scopes 里出现 Scope::Trade 没意义,等价于不分 sim/real/unlock 的旧式权限)。 env 是 sim 还是 real 由 handler 层用 KeyRecord 真实 scopes 二次校验。

§

MetricsRead

v1.4.106 codex 0542 F1 [P2 SECURITY]: /metrics 端点 scope-gated 的 专用 scope. default secure — 不再像 v1.4.105 之前那样无 auth 暴露 key_id 标签 (= API key id 明文 cardinality enumeration channel, 任意本机 process / agent skill 都能 fingerprint).

行为:

  • MetricsRead 的 key → /metrics 通过, key_id= label 仍 redact 为 kh_<8hex> (短 SHA256 hash, 反查 key id 需要离线 dictionary 攻击)
  • 不持 MetricsRead → 401 (legacy 模式) 或 403
  • opt-out: 老用户 dashboard 依赖明文 key_id 时设 FUTU_METRICS_PUBLIC=1 环境变量回退 v1.4.105 行为 (无 auth + 明文 key_id). 此为 backward-compat 边界 trade-off — secure default + 明示 opt-out, 而非 opt-in.

Scope::Admin 区别: Admin 含 mutating endpoint (shutdown/reload), MetricsRead 仅 read-only Prometheus 抓取. dashboard / Prometheus scraper 应持 MetricsRead 而不是 Admin.

Implementations§

Source§

impl Scope

Source

pub const ALL: &'static [Scope]

Source

pub fn as_str(&self) -> &'static str

Source

pub fn trade_super_members() -> &'static [Scope]

v1.4.90 P1-A: super-scope Scope::Trade 的成员集合。REST middleware 在 mutating trade endpoint 的需求侧用 Scope::Trade 占位,持有任一成员即视为满足;handler 层再用真实 scopes 二次校验 env (sim/real/unlock).

Trait Implementations§

Source§

impl Clone for Scope

Source§

fn clone(&self) -> Scope

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Scope

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Scope

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Scope

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Scope> for String

Source§

fn from(s: Scope) -> String

Converts to this type from the input type.
Source§

impl FromStr for Scope

Source§

type Err = ScopeParseError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Scope

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Scope

Source§

fn eq(&self, other: &Scope) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Scope

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<String> for Scope

Source§

type Error = ScopeParseError

The type returned in the event of a conversion error.
Source§

fn try_from(value: String) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for Scope

Source§

impl Eq for Scope

Source§

impl StructuralPartialEq for Scope

Auto Trait Implementations§

§

impl Freeze for Scope

§

impl RefUnwindSafe for Scope

§

impl Send for Scope

§

impl Sync for Scope

§

impl Unpin for Scope

§

impl UnsafeUnpin for Scope

§

impl UnwindSafe for Scope

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,