From 703ab4a04e19157a2d64456e78ddeb5481b142f0 Mon Sep 17 00:00:00 2001 From: dekun Date: Thu, 20 Aug 2026 18:12:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=B3=BB=E7=BB=9F=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E4=BF=9D=E5=AD=98500=EF=BC=9A=E9=89=B4=E6=9D=83?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E4=BE=9D=E8=B5=96=E7=BC=BA=E5=A4=B1=E7=9A=84?= =?UTF-8?q?lib.hub=EF=BC=9B=E8=A1=A5=E5=85=A8order=5Fprices=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- lib/instance/instance_settings_register.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/instance/instance_settings_register.py b/lib/instance/instance_settings_register.py index 8369887..3bf6f07 100644 --- a/lib/instance/instance_settings_register.py +++ b/lib/instance/instance_settings_register.py @@ -30,8 +30,6 @@ def _api_login_required(hub_token_write_allowed: bool = False): def decorator(f): @wraps(f) def wrapped(*args, **kwargs): - from lib.hub.hub_auth import request_allowed as hub_request_allowed - logged_in = bool(session.get("logged_in")) auth_disabled = (os.getenv("APP_AUTH_DISABLED") or "").strip().lower() in ( "1", @@ -43,7 +41,20 @@ def _api_login_required(hub_token_write_allowed: bool = False): bridge = (os.getenv("HUB_BRIDGE_TOKEN") or "").strip() if hub_hdr and bridge and hub_hdr == bridge and not hub_token_write_allowed: return jsonify({"ok": False, "msg": "Hub Token 不可修改实例设置"}), 403 - if hub_request_allowed(logged_in, auth_disabled): + + # crypto_okx 可无 lib.hub;鉴权与中控 request_allowed 对齐 + allowed = bool(auth_disabled or logged_in) + if not allowed and hub_hdr and bridge and hub_hdr == bridge: + allowed = True + if not allowed: + try: + from lib.hub.hub_auth import request_allowed as hub_request_allowed + + allowed = bool(hub_request_allowed(logged_in, auth_disabled)) + except ImportError: + allowed = False + + if allowed: return f(*args, **kwargs) return jsonify({"ok": False, "msg": "未登录"}), 401