fix(gateway): 补齐鉴权测试页并保持旧接口兼容
This commit is contained in:
+4
-1
@@ -686,7 +686,10 @@ async def _face_features_response(request, image_file, image_url, image_base64,
|
||||
image_url = None
|
||||
|
||||
try:
|
||||
feats = await run_in_threadpool(analyze_features, img_bytes, image_url)
|
||||
if include_ratios:
|
||||
feats = await run_in_threadpool(analyze_features, img_bytes, image_url, accept_age_alias=True)
|
||||
else:
|
||||
feats = await run_in_threadpool(analyze_features, img_bytes, image_url)
|
||||
except Exception as ex:
|
||||
logger.exception("接口4 豆包调用失败")
|
||||
return JSONResponse(status_code=200, content={
|
||||
|
||||
@@ -10,7 +10,7 @@ import secrets
|
||||
import time
|
||||
from uuid import uuid4
|
||||
|
||||
from fastapi import APIRouter, Security
|
||||
from fastapi import APIRouter, Depends, Security
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
|
||||
from pydantic import BaseModel, Field
|
||||
@@ -145,3 +145,11 @@ async def client_auth_error(credentials: HTTPAuthorizationCredentials | None = S
|
||||
if not _valid(credentials.credentials, secret, "access"):
|
||||
return _unauthorized("访问令牌无效或已过期")
|
||||
return None
|
||||
|
||||
|
||||
@router.get("/check", summary="验证当前访问令牌")
|
||||
async def check(auth_error=Depends(client_auth_error)):
|
||||
"""检查与 42、52、72 相同的 Bearer 令牌,无需提交图片。"""
|
||||
if auth_error is not None:
|
||||
return auth_error
|
||||
return _response(0, "访问令牌有效")
|
||||
|
||||
Reference in New Issue
Block a user