Skip to main content

Module auth

Module auth 

Source
Expand description

REST API 的 Bearer Token 鉴权

两种模式:

  • 未配置 KeyStore:只读 /api/* 保持 legacy 无鉴权;写交易/admin 路径 仍返回 401(v1.4.86 SEC-003 Q4)
  • 配置了 KeyStore:所有 /api/* 请求必须带 Authorization: Bearer <plaintext>, 且对应 key 必须满足 route 对应的 scope

路由 → scope 映射由 futu-surface-specEndpointSpec 派生,未知 /api/* path fail-closed。新增 REST route 必须先登记 EndpointSpec, 这样 CLI / REST / MCP / Gateway / gRPC 的可见性和权限契约才能共用同一 source of truth。

写类交易 endpoint 在 middleware 层使用 Scope::Trade super-scope, 允许 trade:real / trade:simulate / trade:unlock 进入对应 handler; handler 层再依据解码后的请求做真实 env / unlock 二次校验。

Structs§

AuthState
REST auth middleware 的组合 state:KeyStore(谁能进)+ RuntimeCounters(限额)
RestAdapter
v1.4.106 D1 5a: REST surface adapter — 把 pipeline AuthDecision::Reject 翻成 axum Response.

Functions§

bearer_auth
axum middleware:Bearer Token + scope 校验