Browse Source

更新内容

moshaorui 2 months ago
parent
commit
d26f157531
1 changed files with 19 additions and 19 deletions
  1. 19 19
      app/Admin/Services/RpcService.php

+ 19 - 19
app/Admin/Services/RpcService.php

@@ -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());
+        }
     }
 
     /*