File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments