From c0d4bbcecffda6a23cc14270521d86a9693c3a24 Mon Sep 17 00:00:00 2001 From: hrz <1710360675@qq.com> Date: Mon, 2 Jun 2025 21:24:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=86=E5=B8=83=E5=BC=8F?= =?UTF-8?q?=E9=83=A8=E7=BD=B2=E6=97=B6jwt=E5=AF=86=E9=92=A5=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/xiaozhi-server/app.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main/xiaozhi-server/app.py b/main/xiaozhi-server/app.py index 8c8a728b..2088e183 100644 --- a/main/xiaozhi-server/app.py +++ b/main/xiaozhi-server/app.py @@ -46,8 +46,13 @@ async def main(): check_ffmpeg_installed() config = load_config() - # 生成随机密钥并添加到配置中 - config["server"]["auth_key"] = str(uuid.uuid4().hex) + # 默认使用manager-api的secret作为auth_key + # 如果secret为空,则生成随机密钥 + # auth_key用于jwt认证,比如视觉分析接口的jwt认证 + auth_key = config.get("manager-api", {}).get("secret", "") + if not auth_key or len(auth_key) == 0 or "你" in auth_key: + auth_key = str(uuid.uuid4().hex) + config["server"]["auth_key"] = auth_key # 添加 stdin 监控任务 stdin_task = asyncio.create_task(monitor_stdin())