|
@@ -21,25 +21,25 @@ class RpcService
|
|
|
*/
|
|
|
public function __construct()
|
|
|
{
|
|
|
-// try {
|
|
|
-// $request = request();
|
|
|
-// // 验证签名
|
|
|
-// $apiKey = $request->header('X-API-Key');
|
|
|
-// $clientSignature = $request->header('X-API-Signature');
|
|
|
-// $all = $request->all();
|
|
|
-// $params = isset($all['params'])? $all['params'] : [];
|
|
|
-// $payload = json_encode($params);
|
|
|
-// $payload = $payload.$apiKey;
|
|
|
-// $serverSignature = hash_hmac('sha256', $payload, $this->apiSecret);
|
|
|
-// if ($clientSignature !== $serverSignature) {
|
|
|
-// return $this->responseError('签名验证失败');
|
|
|
-// }
|
|
|
-// if (time() - $apiKey > 100) {
|
|
|
-// return $this->responseError('签名已过期');
|
|
|
-// }
|
|
|
-// } catch (\Exception $e) {
|
|
|
-// return $this->responseError('签名验证失败 e - '. $e->getMessage());
|
|
|
-// }
|
|
|
+ try {
|
|
|
+ $request = request();
|
|
|
+ // 验证签名
|
|
|
+ $apiKey = $request->header('X-API-Key');
|
|
|
+ $clientSignature = $request->header('X-API-Signature');
|
|
|
+ $all = $request->all();
|
|
|
+ $params = isset($all['params'])? $all['params'] : [];
|
|
|
+ $payload = json_encode($params);
|
|
|
+ $payload = $payload.$apiKey;
|
|
|
+ $serverSignature = hash_hmac('sha256', $payload, $this->apiSecret);
|
|
|
+ if ($clientSignature !== $serverSignature) {
|
|
|
+ return $this->responseError('签名验证失败');
|
|
|
+ }
|
|
|
+ if (time() - $apiKey > 100) {
|
|
|
+ return $this->responseError('签名已过期');
|
|
|
+ }
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ return $this->responseError('签名验证失败 e - '. $e->getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/*
|