Expand description
REST API 的 Bearer Token 鉴权
两种模式:
- 未配置 KeyStore:完全不鉴权(保持旧行为,启动日志 warn)
- 配置了 KeyStore:所有
/api/*请求必须带Authorization: Bearer <plaintext>, 且对应 key 必须有下表要求的 scope
路由 → scope 映射(硬编码,后续可做成配置):
| 路径前缀 | 所需 scope |
|---|---|
/api/global-state, /api/user-info, /api/quote-rights, /api/delay-statistics, /api/market-state | qot:read |
/api/quote / /api/kline / /api/orderbook / /api/broker / /api/ticker / /api/rt / /api/snapshot / /api/static-info / /api/plate-* / /api/reference / /api/owner-plate / /api/option-chain / /api/warrant / /api/capital-* / /api/user-security / /api/stock-filter / /api/ipo-list / /api/future-info / /api/history-kline / /api/subscribe / /api/sub-info | qot:read |
/api/accounts / /api/funds / /api/positions / /api/orders / /api/order-fills / /api/history-orders / /api/history-order-fills / /api/max-trd-qtys / /api/margin-ratio / /api/order-fee / /api/sub-acc-push | acc:read |
/api/order (POST = 下单) / /api/modify-order / /api/unlock-trade | trade (super-scope, v1.4.90 P1-A) |
v1.4.90 P1-A: TRADE 列从硬编码 Scope::TradeReal 改为 super-scope
Scope::Trade。middleware 用 [scope_satisfied] 接受持有
TradeReal/TradeSimulate/TradeUnlock 任一即过,handler 层再用真实
scopes 二次校验 env (sim 不允许下真实单等)。修 trade:simulate /
trade:unlock key 调对应 endpoint 被 403 误拒。
Structs§
- Auth
State - REST auth middleware 的组合 state:KeyStore(谁能进)+ RuntimeCounters(限额)
- Rest
Adapter - v1.4.106 D1 5a: REST surface adapter — 把 pipeline
AuthDecision::Reject翻成 axumResponse.
Functions§
- bearer_
auth - axum middleware:Bearer Token + scope 校验