| Conditions | 2 |
| Paths | 2 |
| Total Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 26 | 4 | public function verify($request) |
|
| 27 | { |
||
| 28 | 4 | $token = $request->input('signature.token'); |
|
| 29 | 4 | $timestamp = $request->input('signature.timestamp'); |
|
| 30 | 4 | $signature = $request->input('signature.signature'); |
|
| 31 | |||
| 32 | // check if the timestamp is fresh |
||
| 33 | 4 | if (abs(time() - $timestamp) > 15) { |
|
| 34 | 1 | return false; |
|
| 35 | } |
||
| 36 | |||
| 37 | // returns true if signature is valid |
||
| 38 | 3 | return hash_hmac('sha256', $timestamp.$token, config('services.mailgun.secret')) === $signature; |
|
| 39 | } |
||
| 40 | } |
||
| 41 |