From 15079c356bdf54b147d9950a822e07ad7e6aa0c5 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Mon, 11 May 2026 15:37:23 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81x-api-key=20header?= =?UTF-8?q?=E8=AE=A4=E8=AF=81=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - getAuthenticationUserid增加x-api-key header检查 - 优先调用dapi模块注册的x_api_key_auth处理函数 --- rbac/check_perm.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/rbac/check_perm.py b/rbac/check_perm.py index bcabb20..0d77ed2 100644 --- a/rbac/check_perm.py +++ b/rbac/check_perm.py @@ -222,6 +222,13 @@ async def basic_auth(sor, request): return recs[0].id async def getAuthenticationUserid(sor, request): + # 先检查 x-api-key header (Anthropic 标准认证) + x_api_key = request.headers.get('x-api-key') + if x_api_key: + x_api_key_handler = get_serverenv('x_api_key_auth') + if x_api_key_handler: + return await x_api_key_handler(sor, request) + auth = request.headers.get('Authorization') if auth is None: return None