Skip to main content

Module auth

Module auth 

Source

Re-exports§

pub use refresh::AuthRefresher;
pub use refresh::DefaultAuthRefresher;
pub use refresh::REFRESH_TIMEOUT;
pub use repull::ERROR_CODE_NO_VALID_CID;
pub use repull::repull_auth_code;

Modules§

commconfig
auth/commconfig — 拆 commconfig.rs 1123 → commconfig/{mod, 5 子}.rs (v1.4.110 CC Batch M)
conn_points
Platform 通道后端连接点,按 UserAttribution 分池。
redact
v1.4.84 SEC-001 fix: Auth credential redaction for debug log output.
refresh
v1.4.92 P1-D Tier A1: in-process relogin trigger (AuthRefresher trait + DefaultAuthRefresher). v1.4.92 P1-D Tier A1: in-process relogin trigger.
repull
v1.4.93 G2 (CLAUDE.md C4 audit): RepullAuthCode broker auth_code self-heal. Triggered when broker auth_code expires (typical 30-day window) or kAuthNoValidCid (20029); avoids requiring a daemon restart. v1.4.93 G2 (CLAUDE.md C4 audit): 实装 POST /authority/repull_auth_code, 对齐 C++ FTLogin auth_impl.cpp:715-754 RepullAuthCode + auth_impl.cpp:3308-3376 ParseRepullAuthCodeResponse

Structs§

AuthConfig
v1.4.19:ZeroizeOnDropAuthConfig drop 时自动把 password 字段的 堆内存清零,减少进程 core dump / /proc/<pid>/mem 读到明文的窗口。 其他字段(auth_server / account / device_id)不是秘密,#[zeroize(skip)] 跳过。注意 Clone 每次复制都会产生新堆分配,drop 时各自 zeroize。
AuthResult
BrokerAuth
broker_auth HTTP 响应里提取出的 broker-specific 凭据
BrokerAuthCode
auth_code_list 响应条目——每个 broker 一项。 对齐 C++ FTLogin/Src/ftlogin/auth/impl/auth_impl.cpp:3504ParseAuthCodeList
BrokerAuthRouteCache
C++ FTAuthImpl 的 broker-auth 成功阶段缓存。
BrokerConfig
单个 broker 通道的配置 —— broker_id → (名字 / conn_identity / broker auth HTTP 域名)
RefreshCredentialsReport
v1.4.34: daemon-reload 升级(A’ 方案)的产出。

Enums§

UserAttribution
用户归属地(对齐 C++ FTLogin/Src/ftlogin/ftlogin_def.h:261-270config/impl/user_attr_config.cpp:8-15

Constants§

AUTH_SERVER_PROD
默认认证服务器——CN / HK 归属地账号用这个。 海外账号(US/SG/AU/JP)实际请求时会按 UserAttribution::auth_domain() 切换。
TGTGT_VALIDITY_SECS
v1.4.71: TGTGT 票据有效期(30 天),对齐 C++ auth_cryptor.cpp:135 CreateNewTgtgtInvalidTime = RefreshTime + 30 * 24 * 3600

Functions§

authenticate
完整密码鉴权(优先用保存的凭据跳过验证码)
authenticate_with_callback
完整密码鉴权(带自定义验证码回调)
broker_auth
向 broker auth 域名发 /broker_auth/client_auth POST 请求,换取 broker_client_sig + broker_client_key
broker_config
broker_id → BrokerConfig 映射,对齐 C++ broker_config.cpp:9-18 完整表。 未知 broker_id 返回 None(路由时 skip)。
build_http_client
install_default_rustls_crypto_provider
rustls 0.23 requires an explicit process-level crypto provider when more than one provider feature is present. WebTCP uses rustls directly, so do this before the first ClientConfig::builder() call.
read_or_generate_device_id
读取 device_id;文件不存在则生成新的 16-hex 随机值并持久化。
reauth_via_remember_login
v1.4.94 G4: 用持久化 credentials 重做 remember-login, 拿到 fresh AuthResult (含新 client_sig / client_key).
refresh_credentials_on_disk
v1.4.34: 给 daemon-reload 升级用——用磁盘缓存的 (uid, tgtgt, device_sig, rand_key) 走一次 remember_login,成功则把新 tgtgt 写回 credentials 文件。
reset_device_state
删除 device_id 文件 + credentials 文件(--reset-device 使用)。
tighten_secret_files_at_startup
启动时扫 ~/.futu-opend-rs/ 把已存在的 secret 文件 (credentials-.json / device-.dat) 收紧到 0600. v1.4.101 及以前版本可能创建了 0644 文件, 此 fn 是迁移路径.

Type Aliases§

VerifyCodeCallback
验证码获取回调类型