Skip to content

Commit aac4988

Browse files
committed
1 parent be48fbd commit aac4988

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

app/Http/Middleware/APISecretToken.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ class APISecretToken extends Authorization
4646

4747
protected $permissionAllowed = false;
4848

49+
protected $method = '';
50+
51+
protected $url = '';
52+
4953
public function __construct()
5054
{
5155
//
@@ -102,17 +106,19 @@ public function authenticate(Request $request, Route $route)
102106
throw new HttpException('There was an error while attempting to check your secret key.');
103107
}
104108

105-
if($this->_generateHMAC($request->fullUrl(), $request->getContent(), $decrypted) !== base64_decode($hashed)) {
109+
$this->method = strtoupper($request->method());
110+
$this->url = urldecode($request->fullUrl());
111+
if($this->_generateHMAC($request->getContent(), $decrypted) !== base64_decode($hashed)) {
106112
throw new BadRequestHttpException('The hashed body was not valid. Potential modification of contents in route.');
107113
}
108114

109115
return true;
110116

111117
}
112118

113-
protected function _generateHMAC($url, $body, $key)
119+
protected function _generateHMAC($body, $key)
114120
{
115-
$data = urldecode($url) . '.' . $body;
121+
$data = $this->method . '.' . $this->url . '.' . $body;
116122
return hash_hmac($this->algo, $data, $key, true);
117123
}
118124

0 commit comments

Comments
 (0)