作者 竞泽

fix:签名

@@ -66,14 +66,14 @@ class Request @@ -66,14 +66,14 @@ class Request
66 66
67 $body = $this->extract(); 67 $body = $this->extract();
68 68
69 - $this->signature($body); 69 + $this->signature($body, Arr::get($config, 'secret'));
70 70
71 return $body; 71 return $body;
72 } 72 }
73 73
74 - private function signature(&$body) 74 + private function signature(&$body, string $secret)
75 { 75 {
76 - $body['sign'] = Signature::make($body); 76 + $body['sign'] = Signature::make($body, $secret);
77 } 77 }
78 78
79 private function paddingHead(array $config) 79 private function paddingHead(array $config)
@@ -15,11 +15,11 @@ class Signature @@ -15,11 +15,11 @@ class Signature
15 $this->item = $item; 15 $this->item = $item;
16 } 16 }
17 17
18 - public static function make(array $items): string 18 + public static function make(array $items, string $secret): string
19 { 19 {
20 $signature = new self($items); 20 $signature = new self($items);
21 21
22 - return $signature->toString(); 22 + return $signature->toString($secret);
23 } 23 }
24 24
25 protected function sortByASCII() 25 protected function sortByASCII()
@@ -58,15 +58,17 @@ class Signature @@ -58,15 +58,17 @@ class Signature
58 } 58 }
59 59
60 /** 60 /**
  61 + * @param string $secret
  62 + *
61 * @return string 63 * @return string
62 */ 64 */
63 - protected function toString(): string 65 + protected function toString(string $secret): string
64 { 66 {
65 $this->sortByASCII(); 67 $this->sortByASCII();
66 68
67 $string = $this->map($this->item, function ($k, $v) { 69 $string = $this->map($this->item, function ($k, $v) {
68 - return !($v === '' || $v === null || $k === 'service');  
69 - }); 70 + return !($v === '' || $v === null);
  71 + }) . '&key=' . $secret;
70 72
71 return self::encode($string); 73 return self::encode($string);
72 } 74 }