修正ERP扫码登录服务签名契约
This commit is contained in:
@@ -51,16 +51,6 @@ def _scene(ticket: str, session_id: int | None) -> str:
|
||||
return scene
|
||||
|
||||
|
||||
def _erp_status_error_detail(response: httpx.Response) -> Any:
|
||||
try:
|
||||
data = response.json()
|
||||
except ValueError:
|
||||
return None
|
||||
if isinstance(data, dict):
|
||||
return data.get("detail")
|
||||
return None
|
||||
|
||||
|
||||
def _action_response(data: dict[str, Any]) -> ErpLoginActionResponse:
|
||||
return ErpLoginActionResponse(
|
||||
status=str(data.get("status") or ""),
|
||||
@@ -72,8 +62,7 @@ async def _read_erp_json(response: httpx.Response) -> dict[str, Any]:
|
||||
try:
|
||||
response.raise_for_status()
|
||||
except httpx.HTTPStatusError as exc:
|
||||
detail = _erp_status_error_detail(exc.response) or "ERP扫码登录服务暂时不可用"
|
||||
raise HTTPException(status_code=502, detail=detail) from exc
|
||||
raise HTTPException(status_code=502, detail="ERP扫码登录服务暂时不可用") from exc
|
||||
try:
|
||||
data = response.json()
|
||||
except ValueError as exc:
|
||||
|
||||
@@ -6,9 +6,9 @@ from uuid import uuid4
|
||||
from fastapi import HTTPException
|
||||
|
||||
|
||||
SERVICE_TIMESTAMP_HEADER = "x-service-timestamp"
|
||||
SERVICE_NONCE_HEADER = "x-service-nonce"
|
||||
SERVICE_SIGNATURE_HEADER = "x-service-signature"
|
||||
SERVICE_TIMESTAMP_HEADER = "X-ERP-QR-Timestamp"
|
||||
SERVICE_NONCE_HEADER = "X-ERP-QR-Nonce"
|
||||
SERVICE_SIGNATURE_HEADER = "X-ERP-QR-Signature"
|
||||
|
||||
_seen_nonces: dict[str, int] = {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user