mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-24 04:19:48 +01:00
删掉测试客户端跳过认证的后门
视觉分析接口里写死了 client_id 等于 web_test_client 就放行,等于不用 凭证就能调收费的图像识别,还顺带能拿任意设备号去读私有配置。把这行 删掉。数字人页面原来默认填的就是这个值,也一起清掉,取不到就提示 用户填,避免静默用一个服务端已经不认的值。
This commit is contained in:
parent
ff5aa91417
commit
f87b1b0460
3 changed files with 7 additions and 11 deletions
|
|
@ -155,7 +155,7 @@
|
|||
<div class="config-row">
|
||||
<div class="config-item">
|
||||
<label for="clientId">客户端ID:</label>
|
||||
<input type="text" id="clientId" value="web_test_client" placeholder="client-id">
|
||||
<input type="text" id="clientId" placeholder="client-id(需与设备上报的一致)">
|
||||
</div>
|
||||
<div class="config-item">
|
||||
<label for="deviceName">设备名称:</label>
|
||||
|
|
|
|||
|
|
@ -304,7 +304,10 @@ class App {
|
|||
log(`正在发送图片到视觉分析接口: ${url}`, 'info');
|
||||
|
||||
const deviceId = document.getElementById('deviceMac')?.value || '';
|
||||
const clientId = document.getElementById('clientId')?.value || 'web_test_client';
|
||||
const clientId = document.getElementById('clientId')?.value || '';
|
||||
if (!deviceId || !clientId) {
|
||||
throw new Error('视觉分析失败:请填写设备MAC与客户端ID,两者需与设备上报的一致');
|
||||
}
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('question', question);
|
||||
|
|
|
|||
|
|
@ -29,14 +29,7 @@ class VisionHandler(BaseHandler):
|
|||
|
||||
def _verify_auth_token(self, request) -> Tuple[bool, Optional[str]]:
|
||||
"""验证认证token"""
|
||||
# 测试模式:允许特定测试令牌或跳过验证
|
||||
auth_header = request.headers.get("Authorization", "")
|
||||
client_id = request.headers.get("Client-Id", "")
|
||||
|
||||
# 允许测试客户端跳过认证
|
||||
if client_id == "web_test_client":
|
||||
device_id = request.headers.get("Device-Id", "test_device")
|
||||
return True, device_id
|
||||
|
||||
if not auth_header.startswith("Bearer "):
|
||||
return False, None
|
||||
|
|
@ -155,7 +148,7 @@ class VisionHandler(BaseHandler):
|
|||
)
|
||||
finally:
|
||||
if response:
|
||||
self._add_cors_headers(response)
|
||||
self._add_cors_headers(response, request)
|
||||
return response
|
||||
|
||||
async def handle_get(self, request):
|
||||
|
|
@ -178,5 +171,5 @@ class VisionHandler(BaseHandler):
|
|||
content_type="application/json",
|
||||
)
|
||||
finally:
|
||||
self._add_cors_headers(response)
|
||||
self._add_cors_headers(response, request)
|
||||
return response
|
||||
|
|
|
|||
Loading…
Reference in a new issue