refactor: 将共用代码迁入 lib/ 模块化目录

统一 strategy、key_monitor、trade、hub 等共用库到 lib/ 子包,并补充 lib-structure 文档,便于四所与中控维护。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-02 16:23:09 +08:00
parent 4742a0bb9d
commit 5797d49d8a
190 changed files with 27946 additions and 27499 deletions
+36
View File
@@ -0,0 +1,36 @@
"""中控调用实例 API 时的鉴权(Flask request 头 X-Hub-Token)。SSO 见 hub_sso.py。"""
from __future__ import annotations
import os
from lib.hub.hub_sso import (
HUB_SSO_TTL_SEC,
hub_bridge_token,
mint_hub_sso_token,
safe_next_path,
verify_hub_sso_token,
)
__all__ = [
"HUB_SSO_TTL_SEC",
"hub_bridge_token",
"mint_hub_sso_token",
"safe_next_path",
"verify_hub_sso_token",
"request_allowed",
]
def request_allowed(session_logged_in: bool, auth_disabled: bool) -> bool:
if auth_disabled or session_logged_in:
return True
tok = hub_bridge_token()
if not tok:
return False
try:
from flask import request
except ImportError:
return False
if request.headers.get("X-Hub-Token") == tok:
return True
return False