优化Token验证接口

This commit is contained in:
2026-05-06 10:18:26 +08:00
parent 05f2d6f084
commit 04680408e6
11 changed files with 59 additions and 31 deletions

View File

@@ -449,10 +449,10 @@ class Playx extends Api
return $this->error(__('PlayX API not configured'));
}
// 与 angpow-imports 一致HMAC-SHA1 → Base64密钥 hex/base64 兼容;仅 X-Request-Signature
$reportDate = strval(time());
// 与 angpow-imports 同源HMAC-SHA1 → Base64仅 X-Request-SignatureBody 对齐对端必填 request_date + PlayX 文档 request_id/token
$requestDate = strval(time());
$signatureInput = 'merchant_code=' . $merchantCode
. '&report_date=' . $reportDate
. '&request_date=' . $requestDate
. '&request_id=' . $requestId
. '&token=' . $token;
$signature = $this->buildPlayxTokenVerifySignature($signatureInput, $authKey);
@@ -461,14 +461,13 @@ class Playx extends Api
}
$headers = [
'Content-Type' => 'application/json',
'X-Request-Signature' => $signature,
'Content-Type' => 'application/json',
'X-Request-Signature' => $signature,
];
$payload = [
'merchant_code' => $merchantCode,
'report_date' => $reportDate,
'request_id' => $requestId,
'token' => $token,
'request_id' => $requestId,
'request_date' => $requestDate,
'token' => $token,
];
$res = $client->post($targetVerifyUrl, [
'headers' => $headers,
@@ -527,7 +526,7 @@ class Playx extends Api
}
}
if ($remoteMsg === '' || str_contains(strtolower($remoteMsg), '<html')) {
$remoteMsg = 'PlayX verify-token failed: HTTP ' . strval($code) . ' at ' . $targetVerifyUrl;
$remoteMsg = __('PlayX verify upstream failed', [strval($code), $targetVerifyUrl]);
}
$msg = $remoteMsg !== '' ? $remoteMsg : __('Token expiration');

View File

@@ -60,6 +60,7 @@ return [
'nicknameChsDash' => 'Username may only contain letters, numbers, underscores and dashes',
'Invalid token' => 'Invalid or expired token',
'PlayX API not configured' => 'PlayX API is not configured',
'PlayX verify upstream failed' => 'Upstream token verification failed (HTTP %s): %s',
'Duplicate input' => 'Duplicate submission',
'Ok' => 'OK',
'Failed to map playx user to mall user' => 'Failed to map PlayX user to mall user',

View File

@@ -61,6 +61,7 @@ return [
'nicknameChsDash' => 'Nama pengguna hanya huruf, nombor, garis bawah dan sempang',
'Invalid token' => 'Token tidak sah atau tamat tempoh',
'PlayX API not configured' => 'API PlayX tidak dikonfigurasi',
'PlayX verify upstream failed' => 'Pengesahan token hulu gagal (HTTP %s): %s',
'Duplicate input' => 'Penghantaran pendua',
'Ok' => 'OK',
'Failed to map playx user to mall user' => 'Gagal memetakan pengguna PlayX ke pengguna mall',

View File

@@ -62,6 +62,7 @@ return [
// PlayX API v1 /api/v1/*
'Invalid token' => '令牌无效或已过期',
'PlayX API not configured' => '未配置 PlayX 接口地址',
'PlayX verify upstream failed' => '上游 Token 校验失败HTTP %s%s',
'Duplicate input' => '重复提交',
'Ok' => '成功',
'Failed to map playx user to mall user' => '无法将 PlayX 用户关联到商城用户',